JAVA_HOME seems to be getting set somewhere other than /etc/profile
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
PATH=$PATH:$JAVA_HOME/bin:/usr/local/maven-2.0.7/bin
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC JAVA_HOME
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).
I guess I don't see how this helps. The OP stated he is doing an export of JAVA_HOME. It is correct syntax to export multiple variables at once as he is doing.
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.
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.
Unix also creates separate files for applications to load environment variables.
Your JAVA_HOME might be set from
/etc/profile.d/alljava.csh or /etc/profile.d/alljava.sh
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.