Reputation: 333
I installed tomcat, set variables CATALINA_HOME=/opt/tomcat and CATALINA_BASE=/opt/tomcat
. in terminal I entered command which java and got response /usr/bin/java
. So how I understand this is path for JAVA_HOME. I set it. When I start tomcat in terminal with $CATALINA_HOME/bin/startup.sh
I get response:
Using CATALINA_BASE: /opt/tomcat
Using CATALINA_HOME: /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME: /usr/bin/java
Using CLASSPATH: /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
Tomcat started.
But when I check, I see that tomcat wasn't started and in logs I found:
/opt/tomcat/bin/catalina.sh: 1: eval: /usr/bin/java/bin/java: not found
I suppose,that something wrong with path to java. How can I fix it? PS everyhing was performed in Ubuntu OS
Upvotes: 8
Views: 18835
Reputation: 5105
I think you should point your JRE_HOME to the directory where your java is installed, not the executable java
itself. An example would be
/usr/lib/jvm/java-7-oracle
where that folder will contain the bin/java
executable...
Upvotes: 7
Reputation: 505
This one solved my issue: https://ubuntuforums.org/showthread.php?t=1018063
PS: I installed tomcat8 by apt-get instead of downloading the compressed tomcat file.
Upvotes: 0
Reputation: 81
When the tomcat is started it is searching for setenv.sh in Catalina home or base.
Quote from Catalina.sh:
# Do not set the variables in this script. Instead put them into a script
# setenv.sh in CATALINA_BASE/bin to keep your customizations separate.
#
# JAVA_HOME Must point at your Java Development Kit installation.
# Required to run the with the "debug" argument.
# Ensure that any user defined CLASSPATH variables are not used on startup,
# but allow them to be specified in setenv.sh, in rare case when it is needed.
CLASSPATH=
if [ -r "$CATALINA_BASE/bin/setenv.sh" ]; then
. "$CATALINA_BASE/bin/setenv.sh"
elif [ -r "$CATALINA_HOME/bin/setenv.sh" ]; then
. "$CATALINA_HOME/bin/setenv.sh"
fi
So best way to set JAVA_HOME in tomcat is through setenv.sh
Start the startup.sh script, it will start the tomcat.
Upvotes: 4
Reputation: 361
In Ubuntu
Set JAVA_HOME in .bashrc as export JAVA_HOME=/usr/lib/jvm/java-8-oracle/ and run . .bashrc then start tomcat server
Upvotes: 0
Reputation: 4910
For C shell (csh), edit the startup file (~/.cshrc):
set path=(/usr/local/jdk1.7.0/bin $path)
For bash, edit the startup file (~/.bashrc):
PATH=/usr/local/jdk1.7.0/bin:$PATH
export PATH
For ksh, the startup file is named by the environment variable, ENV. To set the path:
PATH=/usr/local/jdk1.7.0/bin:$PATH
export PATH For sh, edit the profile file (~/.profile):
PATH=/usr/local/jdk1.7.0/bin:$PATH
export PATH Then load the startup file and verify that the path is set by repeating the java command:
For C shell (csh):
% source ~/.cshrc<br>
% java -version
For ksh, bash, or sh:
% . /.profile<br>
% java -version
Upvotes: 0
Reputation: 41
You can also edit the file ../bin/setclasspath.sh
and have an entry
JAVA_HOME="##path of the java directory##"
This will make sure whenever you try to start the tomcat, the JAVA_HOME
will be enforced.
Upvotes: 4
Reputation: 190
Try to set up JAVA_HOME property in /etc/default/tomcat7:
JAVA_HOME=/usr/bin/java
This will force Tomcat to use JVM located under /usr/bin/java
Upvotes: 0