IntelliJ Java IDE
The moose likes Linux / UNIX and the fly likes HOW do I define and set environment variables? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Reply Bookmark "HOW do I define and set environment variables?" Watch "HOW do I define and set environment variables?" New topic
Author

HOW do I define and set environment variables?

Herbert Maosa
Ranch Hand

Joined: May 03, 2000
Posts: 289
Hello Guys,
I am trying to set the JAVA_HOME and CATALINA_HOME environment variables to work with my tomcat. But I don't know how to define these, since they are not part of the predefined variables.

Can you help?
Herbert.
Shane Roylance
Ranch Hand

Joined: Aug 29, 2001
Posts: 72
I am not sure if this works in LINUX, but in most UNIX systems to set an environment variable you use the command:
export JAVA_HOME="dir_name"
Is that what you are looking for?
[ March 13, 2002: Message edited by: Shane Roylance ]
Donald Nunn
Ranch Hand

Joined: Nov 11, 2000
Posts: 200
Hello, Herbert. How are you? What distribution of Linux are you using?
Regards,


<b>Donald Nunn</b><br />Sun Certified Programmer for the Java 2 Platform
Herbert Maosa
Ranch Hand

Joined: May 03, 2000
Posts: 289
Hello Guys,
I am using Red Hat Linux 7.2.
I tried to use the export command, and it only worked for the predefined variables like PATH. But for any of the non existent ones like CATALINA_HOME and JAVA_HOME, it is not working.....

Herbert.
Guy Allard
Ranch Hand

Joined: Nov 24, 2000
Posts: 776
Herbert - I think we need some more detail on exactly what you are doing.
In general, if you export variables in a shell script, there is a big difference between:
script.sh
and
. ./script.sh
You should experiment with that to get a feel for it.
Use 'printenv | sort | less' to see current stuff.
Regards, Guy
[ March 14, 2002: Message edited by: Guy Allard ]
Herbert Maosa
Ranch Hand

Joined: May 03, 2000
Posts: 289
Hi,
I am using RedHat Linux 7.0.
All I am doing is trying to set up my JAVA_HOME and CATALINA_HOME directories.
To do this, I issue the following commands from the command prompt:
export JAVA_HOME =/usr/java/j2sdk1.4.0 and
export CATALINA_HOME=/bin/tomcat.
Both do not work. I however managed to successfully export my PATH using the same way.... and my guess was that maybe it is because PATH is predefined, so that I have to define JAVA_HOME and CATALINA_HOME somewhere..... but I dont know. I have been trying this for 2 days now....pretty embarassing!!
Herbert.
Guy Allard
Ranch Hand

Joined: Nov 24, 2000
Posts: 776
Herbert - OK, down and dirty.
Edit /etc/profile.
Place the export commands in there.
Logout/login, they should be there, and any processes you start will inherit them.
They will also be there for **any** user that logs in to the system.
An alternative way: if you want to control this for individual users is to edit .bash_profile in each user's individual home directory, and place the export commands there.
Regards, Guy
[ March 14, 2002: Message edited by: Guy Allard ]
Deepti Tewari
Greenhorn

Joined: Mar 21, 2002
Posts: 14
Hi,
I think to define new environment variable
following should be used.
1. setenv CATALINA_HOME "c:\PATH"
2. setenv CATALINA_HOME="c:\PATH"
I think one of them should work.(which one i'm not sure)
whichever command works you should put it in your .profile file
regards
Deepti
Jason Kretzer
Ranch Hand

Joined: May 31, 2001
Posts: 280
Herbert,
I had this exact same problem with RH 7.0. No matter what I tried, nothing worked.
You need to upgrade to 7.2. RH7.0 has known issues with Java and this is one of them.
HTH,


Jason R. Kretzer<br />Software Engineer<br />System Administrator<br /><a href="http://alia.iwarp.com" target="_blank" rel="nofollow">http://alia.iwarp.com</a>
 
 
subject: HOW do I define and set environment variables?
 
Threads others viewed
environment variables in grep command
Tomcat installation Problem
Path
how to use the environment variables ?
weblogic
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture