JAVA_HOME seems to be getting set somewhere other than /etc/profile
So I'm having this frustrating issue where I am setting my JAVA_HOME variable in my /etc/profile as one thing, and ending up with another. Can anyone shed some light on where else JAVA_HOME is set or how I can find out what is doing it?
Relevant part of my /etc/profile: Code:
JAVA_HOME=/usr/java/jdk1.6.0 Result of echo $JAVA_HOME (after login again): Code:
/usr/java/jdk1.6.0/bin Thanks for any input! - Mike |
Which shell are you using?
/etc/profile is used by sh, ksh and bash. /etc/bashrc is ALSO used by bash. Also the above are GLOBAL files (all users with the given shells executed these first). There are also LOCAL files in each user's home directory such as .profile for sh/ksh and .bashrc and bashrc_local. These local files get executed/sourced AFTER the global files. Finally ANY of the foregoing files might execute or source another shell script or environment file that sets variables. To execute another file one simply runs it (e.g. "/home/mydir/envfile.sh"). To source it one runs it with a dot (e.g. ". /home/mydir/envfile.sh). The JAVA_HOME might be set by any of these things. To go to a specific user's home directory simply type "cd ~<user>". |
To see what your shell sees as Java Home, open a console, and enter 'echo $JAVA_HOME'.
To set Java Home, do 'export $JAVA_HOME=/path/to/java' (substituting the path to your java installation). |
This could share some light.
http://www.cyberciti.biz/faq/linux-u...path-variable/ Fedora Development |
export JAVA_HOME
|
Quote:
His question isn't HOW to set the variable but rather WHAT is overriding what he has set. |
My guess is that there is a conflict between JAVA_HOME and PATH, which includes a reference to JAVA_HOME/bin. I export them in separate statements (JAVA_HOME and JAVA_BIN) and it works.
|
File where JAVA_HOME is set
Quote:
Your JAVA_HOME might be set from /etc/profile.d/alljava.csh or /etc/profile.d/alljava.sh |
Use grep and find out where it is set ...
[root@cowfister ~]# grep -r JAVA_HOME /etc/* | grep JAVA /etc/java/java.conf:#JAVA_HOME=$JVM_ROOT/jre /etc/java/java.conf:#JAVA_HOME=$JVM_ROOT/java /etc/rpm/macros.jpackage:%java_home %(. %{_javadir}-utils/java-functions; set_jvm; echo $JAVA_HOME) /etc/rpm/macros.jpackage:%ant JAVA_HOME=%{java_home} ant /etc/sysconfig/hsqldb:JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/jre} /etc/sysconfig/hsqldb:JAVA_EXECUTABLE=${JAVA_HOME}/bin/java |
All times are GMT -5. The time now is 04:55 PM. |