LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 03-20-2008, 07:43 PM   #1
Neztec
LQ Newbie
 
Registered: Aug 2007
Posts: 1

Rep: Reputation: 0
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
 
Old 03-20-2008, 07:50 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
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>".
 
Old 03-20-2008, 08:20 PM   #3
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
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).
 
Old 03-20-2008, 11:15 PM   #4
prad77
Member
 
Registered: Mar 2008
Posts: 101

Rep: Reputation: 15
This could share some light.

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

Fedora Development

Last edited by prad77; 04-17-2008 at 03:20 AM.
 
Old 03-21-2008, 12:04 AM   #5
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 133Reputation: 133
export JAVA_HOME
 
Old 03-21-2008, 07:51 AM   #6
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Quote:
Originally Posted by jay73 View Post
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.
 
Old 03-21-2008, 03:03 PM   #7
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 133Reputation: 133
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.
 
Old 10-22-2009, 06:02 AM   #8
ajay.kumar2
LQ Newbie
 
Registered: Oct 2009
Posts: 1

Rep: Reputation: 0
File where JAVA_HOME is set

Quote:
Originally Posted by jay73 View Post
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
 
Old 10-22-2009, 06:42 AM   #9
thegeek
Member
 
Registered: Oct 2009
Location: Amsterdam
Distribution: CentOS,Fedora,Puppy
Posts: 62

Rep: Reputation: 20
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set JAVA_HOME for Tomcat Technomot1 Linux - Newbie 2 11-26-2007 03:50 AM
How to set JAVA_HOME in catalina.sh rajaniyer123 Linux - Software 1 10-06-2007 04:34 AM
JAVA_HOME in /etc/profile doesn't work in GNOME terminal JoseVilla Linux - Newbie 7 04-09-2006 12:52 AM
How to set JAVA_HOME in REDHAT 9.0 Linux? tejpatil Linux - Newbie 5 05-23-2004 01:17 PM
How to set JAVA_HOME in REDHAT 9.0 Linux? tejpatil Linux - General 1 05-23-2004 06:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration