LinuxQuestions.org
Register a domain and help support LQ
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 04-24-2008, 08:19 AM   #1
xpucto
Member
 
Registered: Sep 2005
Location: Vienna, Austria
Distribution: Mint 13
Posts: 522

Rep: Reputation: 31
JAVA_HOME and JRE_HOME for sudo


Hi!

I have just installed jre-1_5_0 that I need for the chandler project http://chandlerproject.org/.
when I try to start it, I get the message:
Quote:
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program
But I did defined those 2 variables in /etc/profile
Quote:
JAVA_HOME=/usr/java/jre1.5.0_15
JRE_HOME=/usr/java/jre1.5.0_15


export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC JRE_HOME JAVA_HOME
the problem is that it works when I use su but not when I use sudo. How can get sudo the value of those variables?

Last edited by xpucto; 04-24-2008 at 08:30 AM.
 
Old 04-24-2008, 08:41 AM   #2
duryodhan
Senior Member
 
Registered: Oct 2006
Distribution: Slackware 12 Kernel 2.6.24 - probably upgraded by now
Posts: 1,054

Rep: Reputation: 46
what does $JAVA_HOME say before running the program?

Also in most programs, you can create a symlink to your jre and it will work.

For e.g in my eclipse.. in the dir which contains eclipse I have created a symlink to my actual jre (in /opt/jre1.6/ ) with the name jre.

ln -s /opt/jre1.6/ ~/eclipse/jre
 
Old 04-25-2008, 06:10 AM   #3
xpucto
Member
 
Registered: Sep 2005
Location: Vienna, Austria
Distribution: Mint 13
Posts: 522

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by duryodhan View Post
what does $JAVA_HOME say before running the program?

Also in most programs, you can create a symlink to your jre and it will work.

For e.g in my eclipse.. in the dir which contains eclipse I have created a symlink to my actual jre (in /opt/jre1.6/ ) with the name jre.

ln -s /opt/jre1.6/ ~/eclipse/jre
well $JAVA_HOME and JAVA_JRE are enpty under sudo.

I made a link in the bin chandler's bin directory
Code:
sudo ln -s /usr/java/jre1.5.0_15/ jre
but it doesn't help.
 
Old 04-25-2008, 06:17 AM   #4
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591

Rep: Reputation: 79
Either the two variables are unset after, or the /etc/profile is not executed at all.
 
Old 04-25-2008, 09:08 AM   #5
duryodhan
Senior Member
 
Registered: Oct 2006
Distribution: Slackware 12 Kernel 2.6.24 - probably upgraded by now
Posts: 1,054

Rep: Reputation: 46
Quote:
sudo ln -s /usr/java/jre1.5.0_15/ jre
are you running as root? why did you do sudo ?

what does echo $JAVA_HOME , echo $JRE_HOME say as normal user?
 
Old 04-28-2008, 07:02 AM   #6
xpucto
Member
 
Registered: Sep 2005
Location: Vienna, Austria
Distribution: Mint 13
Posts: 522

Original Poster
Rep: Reputation: 31
echo $JAVA_HOME and echo $JRE_HOME give me
/usr/java/jre1.5.0_15/ jre
as normal and as root user. The 2 variables are empty only whenI use sudo. Of course I still can use root, but I would rather user sudo. And other users with sudo-permissions don't have the root's password.
 
Old 04-28-2008, 07:38 AM   #7
Jay_Drummond
Member
 
Registered: Jul 2005
Location: Ohio
Distribution: CentOS 4 & 5, Ubuntu 7.04 & 7.10
Posts: 38

Rep: Reputation: 15
On RedHat you can add files to your /etc/profile.d directory.

add two files something like these:
javaProfile.csh
javaProfile.sh

the file javaProfile.sh contains (update for your directory structure):
Code:
# Java initialization script (sh)
if [ -z "$JAVA_HOME" ] ; then
        JAVA_HOME="/usr/java/jdk_latest"
        PATH=$PATH:"/usr/java/jdk_latest/bin"
fi
export JAVA_HOME
export PATH
#javaProfile.sh

the file javaProfile.csh contains (update for your directory structure):
Code:
# Java initialization script (csh)
if ( $?JAVA_HOME ) then
         exit
endif
setenv PATH $PATH:/usr/java/jdk_latest/bin
setenv JAVA_HOME /usr/java/jdk_latest
These files are owned by root:root and permissions are set to 755
 
1 members found this post helpful.
Old 06-21-2010, 06:30 AM   #8
Gkarthikeyan007
LQ Newbie
 
Registered: May 2009
Posts: 3

Rep: Reputation: 0
solution

Hey All! I have got a sloution

As we want to run Tomcat by sudo User just make an edit at only one line in startup.sh & shutdown.sh

Details:

export JAVA_HOME=/usr/java/jdk

Add the above line at the top on both of your scripts

Thats it!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Neither JAVA_HOME nor the JRE_HOME variable defined Raakh Linux - Newbie 9 06-02-2007 07:40 AM
Tomcat5 doesn't find JAVA_HOME environment variable isra_mv Linux - Software 4 09-23-2006 02:42 PM
my JAVA_HOME environment variable changes automaticly petertavenier Linux - Newbie 3 04-20-2006 03:30 AM
# ./startup.sh Neither the JAVA_HOME nor the JRE_HOME environment variable is defined Niceman2005 Linux - Newbie 3 06-29-2005 02:58 PM
JAVA_HOME Variable yea420 Linux - Software 6 08-29-2004 07:37 PM


All times are GMT -5. The time now is 01:36 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration