1830366 Members
2185 Online
110001 Solutions
New Discussion

Environment Variables

 
SOLVED
Go to solution
Kyle D. Harris
Regular Advisor

Environment Variables

I'm trying to start up Tomcat on RH 9.0 and after doing the ./startup.sh i'm getting the error message below.

"The JAVA_HOME environment variable is not defined correctly. This environment variable is needed to run this program."

Can somebody tell me the exact way to set this? I want the variable to be JAVA_HOME=/usr/java/j2sdk1.4.1

Thanks,
Kyle


7 REPLIES 7
Martin P.J. Zinser
Honored Contributor
Solution

Re: Environment Variables

export JAVA_HOME=usr/java/j2sdk1.4.1

in the .bashrc of the account running Tomcat.
(This assumes bash as the shell, other shell will require other syntax/login scripts)

HTH, Martin
Sergejs Svitnevs
Honored Contributor

Re: Environment Variables

Just use:
export JAVA_HOME=/usr/java/j2sdk1.4.1

Regards,
Sergejs
Steven E. Protter
Exalted Contributor

Re: Environment Variables

in /etc/profile or .bash_profile

JAVA_HOME=/usr/java/j2sdk1.4.1
export JAVA_HOME

Done

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Olivier Drouin
Trusted Contributor

Re: Environment Variables

or in startup.sh ... for greater flexibility. IE: if you need more than 1 jvm version.
Kyle D. Harris
Regular Advisor

Re: Environment Variables

Oddly, i had it set up like you all said in /etc/profile and still get the error when trying to start up tomcat.

When i cd to $JAVA_HOME it works fine and goes to the correct directory. I'm not sure why it's displaying that error when trying to start tomcat....?
Mic V.
Esteemed Contributor

Re: Environment Variables

It sounds as though it's not set in the environment where Tomcat is trying to run.

If you haven't restarted Tomcat's processes, you should, because generally speaking, applications and processes won't re-read system configuration files. So if you edited /etc/profile after starting Tomcat (which it sounds like is NOT the case), the changes would not be seen.

Since it sounds like you had the definitions in place before Tomcat was started, you might try to do some debugging in the environment where Tomcat is running. For example, if you start it with startup.sh, then put some debugging into it:

echo "before start, JAVA_HOME is ${JAVA_HOME}"

That way you'll see how things stand. Of course, it may be buried more deeply in other levels (calls) of scripts.

HTH,
Mic
What kind of a name is 'Wolverine'?
Martin P.J. Zinser
Honored Contributor

Re: Environment Variables

Hello Kyle,

first check which shell the account for Tomcat is using (info to be found in /etc/passwd). It might be it is not sourcing the file you changed.

Alternatively either change startup.sh (maybe not ideal since you have to do so everytime you install a new Tomcat version) or write a little wrapper script that sets the variable and then calls startup.sh.

Have a nice weekend,

Martin