• Post Reply Bookmark Topic Watch Topic
  • New Topic

HOW do I define and set environment variables?  RSS feed

 
Herbert Maosa
Ranch Hand
Posts: 289
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, Herbert. How are you? What distribution of Linux are you using?
Regards,
 
Herbert Maosa
Ranch Hand
Posts: 289
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 289
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!