Linux - Newbie This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
03-20-2008, 07:43 PM
|
#1
|
LQ Newbie
Registered: Aug 2007
Posts: 1
Rep:
|
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
|
|
|
03-20-2008, 07:50 PM
|
#2
|
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
|
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>".
|
|
|
03-20-2008, 08:20 PM
|
#3
|
LQ Addict
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908
|
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).
|
|
|
03-20-2008, 11:15 PM
|
#4
|
Member
Registered: Mar 2008
Posts: 101
Rep:
|
Last edited by prad77; 04-17-2008 at 03:20 AM.
|
|
|
03-21-2008, 12:04 AM
|
#5
|
LQ Guru
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019
Rep:
|
export JAVA_HOME
|
|
|
03-21-2008, 07:51 AM
|
#6
|
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
|
Quote:
Originally Posted by jay73
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.
|
|
|
03-21-2008, 03:03 PM
|
#7
|
LQ Guru
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019
Rep:
|
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.
Last edited by jay73; 03-21-2008 at 03:05 PM.
|
|
|
10-22-2009, 06:02 AM
|
#8
|
LQ Newbie
Registered: Oct 2009
Posts: 1
Rep:
|
File where JAVA_HOME is set
Quote:
Originally Posted by jay73
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
|
|
|
10-22-2009, 06:42 AM
|
#9
|
Member
Registered: Oct 2009
Location: Amsterdam
Distribution: CentOS,Fedora,Puppy
Posts: 62
Rep:
|
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 02:37 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|