How to set environment variable JAVA_HOME that will be saved on exit?
69,964
Solution 1
Set environment variables in ~/.profile
, e.g. by adding this line:
export JAVA_HOME=/usr/java/jdk1.7.0_05
Solution 2
Add to /etc/profile.local
:
export JAVA_HOME=/usr/java/latest
That way it will be set for all users and will be independent of the release or patch-number. /usr/java/latest
is a link to the latest installed version and exists since JDK/JRE 1.6
Related videos on Youtube
Author by
user710818
Updated on September 18, 2022Comments
-
user710818 over 1 year
Possible Duplicate:
How do I set a user environment variable? (permanently, not session)I use Suse. First I had jdk7 installed, so
JAVA_HOME
was:/usr/java/jdk1.7.0_05/
I uninstalled jdk7 and installed jdk6, but I cannot figure out how to change
JAVA_HOME
..bashrc
and.profile
don't contain anything aboutJAVA_HOME
.Is there another file?
-
Admin almost 12 yearsyes, it is, I forgot about profile in my home directory. thanks. Please answer I will close the question
-
-
Courtney Miles almost 12 yearsI don't know Suse, but wouldn't it be better to define this in the system profile? JAVA_HOME is defined in /etc/profile on my Solaris server (a system with many accounts).
-
jw013 almost 12 years@BobDuell Yes, you are right. If the java install was intended for all users system-wide, then
/etc/profile
would be the more appropriate place.