If you are like me, you have multiple versions of java installed on your machine. There was an initial version that shipped with Ubuntu, followed by the Sun JDK and if you have other applications installed then additional versions as well.
I ran into a similar issue on my machine when I had the right version of Java compiler being referenced but the compiled application was not running as it was picking the wrong version of Java run time.
$ javac -version
javac 1.7.0_07
$ java -version
java version "1.6.0_27"
Here is the screenshot...
I was baffled and an initial attempt at adding JAVA_HOME to .bashrc did not produce the desired results.
Finally, I learnt the right way was to update using update-alternatives in Ubuntu
Typing the following command on the terminal window lists the current version as well as the alternatives.
$ sudo update-alternatives --config java
I selected the option 2, as I needed to execute the compiled classes using Sun JDK.
Checking the java -version confirmed that the correct java had been selected.
There we go.... nicely done!
I ran into a similar issue on my machine when I had the right version of Java compiler being referenced but the compiled application was not running as it was picking the wrong version of Java run time.
$ javac -version
javac 1.7.0_07
$ java -version
java version "1.6.0_27"
Here is the screenshot...
I was baffled and an initial attempt at adding JAVA_HOME to .bashrc did not produce the desired results.
Finally, I learnt the right way was to update using update-alternatives in Ubuntu
Typing the following command on the terminal window lists the current version as well as the alternatives.
$ sudo update-alternatives --config java
I selected the option 2, as I needed to execute the compiled classes using Sun JDK.
Checking the java -version confirmed that the correct java had been selected.
There we go.... nicely done!
No comments:
Post a Comment