LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   JAVA_HOME seems to be getting set somewhere other than /etc/profile (https://www.linuxquestions.org/questions/linux-newbie-8/java_home-seems-to-be-getting-set-somewhere-other-than-etc-profile-629561/)

Neztec 03-20-2008 07:43 PM

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


Result of echo $JAVA_HOME (after login again):

Code:

/usr/java/jdk1.6.0/bin

Thanks for any input!
- Mike

MensaWater 03-20-2008 07:50 PM

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>".

bigrigdriver 03-20-2008 08:20 PM

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).

prad77 03-20-2008 11:15 PM

This could share some light.

http://www.cyberciti.biz/faq/linux-u...path-variable/

Fedora Development

jay73 03-21-2008 12:04 AM

export JAVA_HOME

MensaWater 03-21-2008 07:51 AM

Quote:

Originally Posted by jay73 (Post 3095621)
export JAVA_HOME

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.

jay73 03-21-2008 03:03 PM

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.

ajay.kumar2 10-22-2009 06:02 AM

File where JAVA_HOME is set
 
Quote:

Originally Posted by jay73 (Post 3096249)
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

thegeek 10-22-2009 06:42 AM

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.