Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I installed a new jdk 1.6 parallel to that existing 1.5, however I got this error when I run the java binary.

./java -version Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object

I already set my PATH variable to include the new jdk bin directory.

share|improve this question

Try setting your JAVA_HOME variable to the base directory instead.

export JAVA_HOME=/path/to/jdk1.5r8
/path/to/jdk1.5r8/bin/java -version

Java respects JAVA_HOME and JAVA_OPTS for almost everything.

share|improve this answer

This what I setup in the bash profile in our servers.

export JAVA_HOME_8=$HOME/3rd/jdk1.8.0
export JAVA_HOME_6=$HOME/3rd/jdk1.6.0_38

alias j6='export JAVA_HOME=$JAVA_HOME_6;export PATH=$JAVA_HOME/bin:$PATH'
alias j8='export JAVA_HOME=$JAVA_HOME_8;export PATH=$JAVA_HOME/bin:$PATH'

When we need java6 we type j6 in the command prompt to load the java6 environment or j8 to load the java8 environment

share|improve this answer

make sure the jdk version you want to use in PATH and JAVA_HOME are same. you can keep switching between the versions by updating the two fields.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.