LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to set JAVA_HOME for Tomcat (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-set-java_home-for-tomcat-601714/)

Technomot1 11-22-2007 12:26 PM

How to set JAVA_HOME for Tomcat
 
Hi,

I need to set an environment variable JAVA_HOME for Apache Tomcat to use. I know how do this on Windows but I'm struggling with Fedora 8. I tried entering this in a shell first and got the following:
[user@localhost ~]$ export java_home=/usr/java/jdk
[user@localhost ~]$ export PATH=$java_home/bin:$PATH
[user@localhost ~]$ cd /usr/tomcat5/apache-tomcat-5.5.25/bin
[user@localhost 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
[user@localhost bin]$

Also I opened my /home/user/.bashrc file expecting to see a "PATH="... variable but the following is all that's in there:
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# User specific aliases and functions

I did some more 'Googling' then tried the following with some success however when tried to connect to tomcat using http://localhost:8080 I get a "Problem loading page" error. All suggestions will be welcome as I'm pretty clueless using Linux. Thanks.

[user@localhost ~]$ echo $PATH
/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/user/bin
[user@localhost ~]$ export JAVA_HOME=/usr/java/jdk/bin/java
[user@localhost ~]$ export PATH=$PATH:/usr/java/jdk/bin
[user@localhost ~]$ echo $JAVA_HOME
/usr/java/jdk/bin/java
[user@localhost ~]$ echo $PATH
/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/user/bin:/usr/java/jdk/bin
[user@localhost ~]$ cd /usr/tomcat5/apache-tomcat-5.5.25/bin
[user@localhost bin]$ ./startup.sh
Using CATALINA_BASE: /usr/tomcat5/apache-tomcat-5.5.25
Using CATALINA_HOME: /usr/tomcat5/apache-tomcat-5.5.25
Using CATALINA_TMPDIR: /usr/tomcat5/apache-tomcat-5.5.25/temp
Using JRE_HOME: /usr/java/jdk/bin/java
touch: cannot touch `/usr/tomcat5/apache-tomcat-5.5.25/logs/catalina.out': Permission denied
/usr/tomcat5/apache-tomcat-5.5.25/bin/catalina.sh: line 273: /usr/tomcat5/apache-tomcat-5.5.25/logs/catalina.out: Permission denied
[user@localhost bin]$ su
Password:
[root@localhost bin]# ./startup.sh
Using CATALINA_BASE: /usr/tomcat5/apache-tomcat-5.5.25
Using CATALINA_HOME: /usr/tomcat5/apache-tomcat-5.5.25
Using CATALINA_TMPDIR: /usr/tomcat5/apache-tomcat-5.5.25/temp
Using JRE_HOME: /usr/java/jdk/bin/java
[root@localhost bin]#

harry edwards 11-22-2007 02:51 PM

You show the JAVA_HOME under the user account and then later 'su' to root. I'm pretty certain (not definite) that the users environment settings will not be passed into root's session. Try setting the environment settings as root.

mt83 11-26-2007 03:50 AM

Hi,
Check your box with other jvm installed like "gcj".
If installed, remove them first.

good luck


All times are GMT -5. The time now is 06:46 PM.