LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 10-02-2008, 03:03 PM   #1
snowball2
LQ Newbie
 
Registered: Oct 2008
Posts: 5

Rep: Reputation: 0
Installing TOMCAT6.0.14 - JAVA_HOME problem


Hello,

I am totally new to Linux (using Ubuntu) and have been struggling to install Tomcat 6.0.14 on Ubuntu.

The problem I am having is that everytime I try to start the server I get the following error :
Code:
sudo sh /usr/local/tomcat/bin/startup.sh
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
Yet...
Code:
echo $JAVA_HOME
/usr/lib/jvm/java-6-sun
And java-6-sun is a link to the following directory
Code:
java-6-sun$ ls
bin        ext      jre  LICENSE  README.html
COPYRIGHT  include  lib  man      THIRDPARTYLICENSEREADME.txt
I'm tearing my hair out now as I can't find anything wrong anywhere - the links all seem fine yet the server just wont run.. Can anyone suggest anything I could try or somewhere I could look please?

Cheers,
Gordon
 
Old 10-02-2008, 04:32 PM   #2
SkyEye
Member
 
Registered: Sep 2005
Location: Sri Lanka
Distribution: Fedora (workstations), CentOS (servers), Arch, Mint, Ubuntu, and a few more.
Posts: 441

Rep: Reputation: 40
First, welcome to LQ!

How are you actually setting the variable? If you are doing it by defining in a config file (Eg: /etc/profile) make sure to "export" the variable
Code:
Eg: (At the end of /etc/profile)

CATALINA_HOME=/usr/local/tomcat
JAVA_HOME=/usr/lib/jvm/java-6-sun
JRE_HOME=/usr/lib/jvm/java-6-sun
export CATALINA_HOME JAVA_HOME JRE_HOME
What I suspect as happening is, that you might be setting the variable only for a user (Eg: for snawball2 only). If this is the case, make sure your variable value is set in the appropriate user environment your Tomcat server is running as.

Generally
, it's ok to set the variable globally as in the above example (i.e. in /etc/profile).

Last edited by SkyEye; 10-02-2008 at 04:35 PM.
 
Old 10-03-2008, 12:41 AM   #3
snowball2
LQ Newbie
 
Registered: Oct 2008
Posts: 5

Original Poster
Rep: Reputation: 0
Hi,

I'm setting the variable in ~/.bashrc using the line :

export JAVA_HOME=/usr/lib/jvm/java-6-sun

I tried changing that to what you suggested:

JAVA_HOME=/usr/lib/jvm/java-6-sun
export JAVA_HOME


but to no avail

Gordon.
 
Old 10-03-2008, 05:26 AM   #4
SkyEye
Member
 
Registered: Sep 2005
Location: Sri Lanka
Distribution: Fedora (workstations), CentOS (servers), Arch, Mint, Ubuntu, and a few more.
Posts: 441

Rep: Reputation: 40
That's what I said,... If you look at my post, I said:
Quote:
Originally Posted by SkyEye
What I suspect as happening is, that you might be setting the variable only for a user (Eg: for snawball2 only). If this is the case, make sure your variable value is set in the appropriate user environment your Tomcat server is running as.

Generally, it's ok to set the variable globally as in the above example (i.e. in /etc/profile).
So obviously you are setting the variable in your .bashrc.

.bashrc is not a good place to set a variable like this. (what it does is set the variable when ever a bash session is started by you.) You need to put this in a place where the variable would be set globally.

Try putting it in /etc/profile (and you can remove JAVA_HOME from .bashrc). Better to reboot your computer after setting this.
 
Old 10-03-2008, 07:55 AM   #5
snowball2
LQ Newbie
 
Registered: Oct 2008
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by SkyEye View Post
Try putting it in /etc/profile (and you can remove JAVA_HOME from .bashrc). Better to reboot your computer after setting this.
Hi, I've removed the JAVA_HOME variable from .bashrc and tried it in /etc/profile but still exactly the same problem - I've checked java is installed correctly, i'm able to compile and run from my home dir and I've re-downloaded tomcat but still no joy. :`(
 
Old 10-03-2008, 08:27 AM   #6
SkyEye
Member
 
Registered: Sep 2005
Location: Sri Lanka
Distribution: Fedora (workstations), CentOS (servers), Arch, Mint, Ubuntu, and a few more.
Posts: 441

Rep: Reputation: 40
Are you using a Tomcat binary distribution or a source distribution? Try with a binary distribution.

I just downloaded apache-tomcat-6.0.18 and was unable to reproduce your error. Lets try this:
  1. Download a Tomcat binary distribution. Eg: apache-tomcat-6.0.18.tar.gz
  2. Open a terminal and change to your download directory (Eg: $ cd ~/Downloads)
  3. Extract the Tomcat archive (Eg: $ tar xzvf apache-tomcat-6.0.18.tar.gz)
  4. Set the variable JAVA_HOME (or, see Note below) in the same terminal (Eg: $ export JAVA_HOME=/usr/lib/jvm/java-6-sun)
  5. Start the Tomcat server (Eg: $ ./apache-tomcat-6.0.18/bin/startup.sh - please note the "." before the slash)

Note:
  • If you have just the JRE (not the JDK), then set JRE_HOME instead if JAVA_HOME variable.
  • And please remove any tailing slashes (Eg: "~/tomcat" instead of "~/tomcat/") in paths.

This should give an output like this, if it was successful:
Using CATALINA_BASE: /home/snowball2/Downloads/apache-tomcat-6.0.18
Using CATALINA_HOME: /home/snowball2/Downloads/apache-tomcat-6.0.18
Using CATALINA_TMPDIR: /home/snowball2/Downloads/apache-tomcat-6.0.18/temp
Using JRE_HOME: /usr/lib/jvm/java-6-sun

This worked for me. I just tested it. Give it a try, if it still persists please try to extract more info about the system/setup.

Last edited by SkyEye; 10-03-2008 at 08:31 AM.
 
Old 10-03-2008, 02:52 PM   #7
snowball2
LQ Newbie
 
Registered: Oct 2008
Posts: 5

Original Poster
Rep: Reputation: 0
Hi,

SkyEye, thanks a lot for all of the assistance! I really appreciate it.. I'll give you the story so far - things have improved but the tomcat server isn't quite running yet (at least I can't access it over network yet).

I followed your instructions to the letter but get the following output :

Code:
snowball2@ubuntu:/$ sudo /usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:       /usr
JRE_HOME is the only thing which is different and I'm still struggling with.. I've defined JAVA_HOME and JRE_HOME in /etc/profile and if I echo $JRE_HOME in shell I get :
Code:
snowball2@ubuntu:/$ echo $JRE_HOME
/usr/lib/jvm/java-6-sun
Even if I export immediately before running startup.sh I still get :
Code:
snowball2@ubuntu:/$ export JRE_HOME=/usr/lib/jvm/java-6-sun
snowball2@ubuntu:/$ export JAVA_HOME=/usr/lib/jvm/java-6-sun
snowball2@ubuntu:/$ sudo /usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:       /usr
It's weird..

Gordon

Last edited by snowball2; 10-03-2008 at 02:53 PM.
 
Old 10-03-2008, 11:55 PM   #8
SkyEye
Member
 
Registered: Sep 2005
Location: Sri Lanka
Distribution: Fedora (workstations), CentOS (servers), Arch, Mint, Ubuntu, and a few more.
Posts: 441

Rep: Reputation: 40
Quote:
Originally Posted by snowball2 View Post
Hi,

I followed your instructions to the letter but get the following output :

Code:
snowball2@ubuntu:/$ sudo /usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:       /usr
JRE_HOME is the only thing which is different and I'm still struggling with..
It doesn't matter if your server starts.

After running the startup script, try
$ sudo ps aux | grep java

If it's running you'll get a java process with lot of parameters in the output.
 
Old 10-04-2008, 03:39 PM   #9
snowball2
LQ Newbie
 
Registered: Oct 2008
Posts: 5

Original Poster
Rep: Reputation: 0
Thumbs up

Quote:
Originally Posted by SkyEye View Post
It doesn't matter if your server starts.
SkyEye, thanks very much for all your help - got it up and running ! IOU 1 beer!
 
Old 10-07-2008, 10:35 AM   #10
SkyEye
Member
 
Registered: Sep 2005
Location: Sri Lanka
Distribution: Fedora (workstations), CentOS (servers), Arch, Mint, Ubuntu, and a few more.
Posts: 441

Rep: Reputation: 40
Really glad to know you got it working!

Hope to see you around LQ.
 
Old 11-10-2008, 03:44 PM   #11
gogoabc
LQ Newbie
 
Registered: Nov 2008
Posts: 5

Rep: Reputation: 0
Quote:
Originally Posted by snowball2 View Post
SkyEye, thanks very much for all your help - got it up and running ! IOU 1 beer!
Dear snowball2,

I have exact the same problem with you.

after I follow the following steps:
1. Download a Tomcat binary distribution. Eg: apache-tomcat-6.0.18.tar.gz
2. Open a terminal and change to your download directory (Eg: $ cd ~/Downloads)
3. Extract the Tomcat archive (Eg: $ tar xzvf apache-tomcat-6.0.18.tar.gz)
4. Set the variable JAVA_HOME (or, see Note below) in the same terminal (Eg: $ export JAVA_HOME=/usr/lib/jvm/java-6-sun)
5. Start the Tomcat server (Eg: $ ./apache-tomcat-6.0.18/bin/startup.sh - please note the "." before the slash)


I got the result:
tai@ubuntu:/$ sudo /usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr

After I run: $ sudo ps aux | grep java
I got:
root 9196 0.3 1.2 1069760 45012 pts/0 Sl 16:18 0:02 /usr/bin/java -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=/usr/local/tomcat6.0/conf/logging.properties -Djava.endorsed.dirs=/usr/local/tomcat6.0/endorsed -classpath :/usr/local/tomcat6.0/bin/bootstrap.jar -Dcatalina.base=/usr/local/tomcat6.0 -Dcatalina.home=/usr/local/tomcat6.0 -Djava.io.tmpdir=/usr/local/tomcat6.0/temp org.apache.catalina.startup.Bootstrap start
dror 9325 0.0 0.0 3008 772 pts/0 S+ 16:29 0:00 grep java

Can anyone give me hint? Thank you!
 
Old 11-11-2008, 02:37 AM   #12
SkyEye
Member
 
Registered: Sep 2005
Location: Sri Lanka
Distribution: Fedora (workstations), CentOS (servers), Arch, Mint, Ubuntu, and a few more.
Posts: 441

Rep: Reputation: 40
Quote:
Originally Posted by gogoabc View Post
After I run: $ sudo ps aux | grep java
I got:
root 9196 0.3 1.2 1069760 45012 pts/0 Sl 16:18 0:02 /usr/bin/java -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=/usr/local/tomcat6.0/conf/logging.properties -Djava.endorsed.dirs=/usr/local/tomcat6.0/endorsed -classpath :/usr/local/tomcat6.0/bin/bootstrap.jar -Dcatalina.base=/usr/local/tomcat6.0 -Dcatalina.home=/usr/local/tomcat6.0 -Djava.io.tmpdir=/usr/local/tomcat6.0/temp org.apache.catalina.startup.Bootstrap start
dror 9325 0.0 0.0 3008 772 pts/0 S+ 16:29 0:00 grep java

Can anyone give me hint? Thank you!
This means your Tomcat server is running. It's not an error message. So try loading the tomcat test page in your browser.

The steps you followed were steps used temporarily to make sure that there is nothing wrong. Those steps did not set the necessary variables permanently. You can do the final setup by following the steps in, post 6 of this thread.

Good luck.
 
  


Reply

Tags
environment variable, java, javahome, tomcat



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
problem in writting the java_home path to /etc/profile. fayezderya Linux - Software 1 03-24-2008 12:50 PM
problem setting JAVA_HOME pkpro1 Linux - General 5 11-25-2007 08:49 AM
Ant problem with JAVA_HOME manolakis Linux - Software 1 03-22-2007 12:02 PM
Java - JAVA_HOME problem after upgrade ssa2204 Linux - Newbie 5 08-24-2006 06:32 PM
Problem setting JAVA_HOME when installing jdk1.5 RVDowning Mandriva 4 08-02-2006 07:38 AM

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

All times are GMT -5. The time now is 04:01 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