LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Setting JAVA_HOME after automatic update of Java to the latest version (https://www.linuxquestions.org/questions/linux-general-1/setting-java_home-after-automatic-update-of-java-to-the-latest-version-742322/)

BinDigit1 07-23-2009 05:03 PM

Setting JAVA_HOME after automatic update of Java to the latest version
 
Hello,
I have a problem to run some java application scripts after the automatic update of Sun's JRE from 1.6.0.13 to 1.6.0.14. More specifically, I run a script that initializes the application, setting the variables it uses. I get the following error:

line 93: /usr/lib/jvm/java-6-sun-1.6.0.13/bin/java: No such file or directory

which makes sense, as the new installed version is 1.6.0.14.
Executing:
Code:

java -version
gives me the correct version number.
However,
Code:

echo $JAVA_HOME
still points to /usr/lib/jvm/java-6-sun-1.6.0.13

Anyone knows how to change this?

Vgui 07-23-2009 06:21 PM

Just edit your ~/.bashrc file, and add the line defining your JAVA_HOME variable, such as:

Code:

export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.14/
----
Also a handy way to avoid update problems in the future is to create a symbolic link to your java folder. Basically you point all your variables to a "shortcut", and then you only have to update that shortcut to point to the newest java version, instead of going through all your config files and IDEs to try to find where you defined the java folder. Let me demonstrate what I mean, since I don't think that came off as clear...

Navigate to the parent directory of your java folder, and then run:

Code:

ln -s /usr/lib/jvm/java-6-sun-1.6.0.14/ currentjava
Then if you do an "ls -l" in that directory you'll see something resembling:

Code:

lrwxrwxrwx 1 root root  21 2009-03-04 15:56 currentjava -> /usr/lib/jvm/java-6-sun-1.6.0.14/
drwxr-xr-x 8 root root 4096 2009-03-04 15:55 java-6-sun-1.6.0.14

And now you can point your JAVA_HOME to /usr/lib/jvm/currentjava/, and then just relink it to the newer version whenever an update is released, which as I said is easier than going through all your config files and updated the path manually.


All times are GMT -5. The time now is 09:25 PM.