How do I change the value of JAVA_HOME in Ubuntu to point to Oracle's Java?
Should it point to java-6-sun or java-6-sun-1.6.0.24 ?
Join Stack Overflow to learn, share knowledge, and build your career.
|
|
I put the line:
in my
The reason it's a symbolic link is that in case there's a new version of the JVM, you don't need to update your If you want to set JAVA_HOME environment variables globally and at system level means use should set in /etc/environment file. For More. |
|||||||||||||||||||||
|
|
If you want to change it globally and at system level; In
add this line:
|
|||||||||||||||||||||
|
|
to set Oracle's Java SE Development Kit as the system default Java just download the latest Java SE Development Kit from here then create a directory somewhere you like in your file system for example
now to set your
make sure the Oracle's java is set as default java by:
you get something like this:
pay attention to the asterisk before the numbers on the left and if the correct one is not set choose the correct one by typing the number of it and pressing enter. now test your java:
if you get something like the following, you are good to go:
also note that you might need root permission or be in sudoers group to be able to do this. I've tested this solution on both ubuntu 12.04 and Debian wheezy and it works in both of them. |
|||||||||||||||||||||
|
|
If you want this environment variable available to all users and on system start then you can add the following to /etc/profile.d/java.sh (create it if necessary):
Then in a terminal run:
It should always point to |
||||
|
|
|
java 6
or java 7
|
||||
|
|
|
If you're doing any sort of development you need to point to the JDK (Java Development Kit). Otherwise, you can point to the JRE (Java Runtime Environment). The JDK contains everything the JRE has and more. If you're just executing Java programs, you can point to either the JRE or the JDK. You should set
If you want to set up JAVA_HOME to JDK you should go up one folder more:
|
||||
|
|
|
If you want to use specific version of Java when multiple JDKs are installed, just setting JAVA_HOME may not work. You need to use Refer to https://askubuntu.com/questions/121654/how-to-set-default-java-version. |
||||
|
|
|
See this; run
to list off all the Java installations on a machine by name and directory, and then run
to choose which JRE/JDK to use. If you want to use different JDKs/JREs for each Java task, you can run update-alternatives to configure one java executable at a time; you can run
to see the Java commands that can be configured (java, javac, javah, javaws, etc). And then
will associate that Java task/command to a particular JDK/JRE. You may also need to set JAVA_HOME for some applications: from this answer you can use
for JREs, or
for JDKs. |
|||||
|