Tomcat 7 with Java 8 on Windows and Linux
Thank you, everyone, I found what happened. It turned out that JAVA_HOME was not defined in a proper way (as logoff and Marko Topolnik mentioned). I opened /etc/default/tomcat7 and changed this section:
# The home directory of the Java development kit (JDK). You need at least
# JDK version 6. If JAVA_HOME is not set, some common directories for
# OpenJDK, the Oracle JDK, and various Java SE 6+ versions are tried.
#JAVA_HOME=/usr/lib/jvm/openjdk-6-jdk
JAVA_HOME=/path/to/my/jdk
... and everything starts to work! Does Tomcat really use an internal JDK smth like OpenJDK by default?
How to change Java version used by TOMCAT?
When you open catalina.sh / catalina.bat, you can see :
Environment Variable Prequisites
JAVA_HOME Must point at your Java Development Kit installation.
So, set your environment variable JAVA_HOME
to point to Java 6. Also make sure JRE_HOME
is pointing to the same target, if it is set.
Update: since you are on Windows, see here for how to manage your environment variables
Tomcat: How to find out running Tomcat version?
if you can upload a JSP file you may print out some info like in this example: bestdesigns.co.in/blog/check-jsp-tomcat-version
Save this code into a file called tomcat_version.jsp:
Tomcat Version : <%= application.getServerInfo() %><br>
Servlet Specification Version :
<%= application.getMajorVersion() %>.<%= application.getMinorVersion() %> <br>
JSP version :
<%=JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion() %><br>
When you access, http://example.com/tomcat_version.jsp, the output should look similar to:
Tomcat Version : Apache Tomcat/5.5.25
Servlet Specification Version : 2.4
JSP version: 2.0
How to configure Tomcat to use Java 7
You answered your own question.! :)
All You need to do is link java 7 in your JAVA_HOME
.!
More Info Here
Edit : (Based on alfabravo's comment :
You can definitely change the pointer to JAVA_HOME
in your catalina.bat/sh
Tomcat7 Starts with Incorrect Java Version
Even though both java -version
and javac -version
were showing up as 1.8 in my Ubuntu server, I noticed that for some reason Tomcat was still using 1.7 when I visited its Manager-GUI (near bottom).
This issue was fixed with the help of this question on Ask Ubuntu. Basically, JAVA_HOME
needs to be updated for Tomcat as well using vi /etc/default/tomcat7
. I set mine to /usr/lib/jvm/java-8-oracle
, restarted Tomcat, and now it shows the correct version in Tomcat.
How can I changed tomcat app server to version 8 with jdk 1.7 and spring 3.0.4?
Its a Spring 3.0 method which should work in your case as it works on localhost. I guess your linux tomcat has pre-3.0 Spring versions somewhere in classpath- which could be from this project or legacy project. On linux tomcat check your classpath, search for spring 2* jars and try deleting work/temp folders..
which java version does tomcat use
You can look up the Java version Tomcat is really running with in the manager app, which is installed by default. Go to http://hostname:8080/manager/html
(replace hostname by hostname or localhost), scroll to the bottom, there you will find "JVM Version".
Which JVM is selected depends a lot on the OS and way to install, maybe http://tomcat.apache.org/tomcat-7.0-doc/setup.html will help.
E.g. if you are running Windows with Tomcat with the service wrapper (I would recommend this for Windows), you can set the path to the JVM directly in the tray icon -> Configure Tomcat. In the Java tab e.g. set Java Virtual Machine to "D:\java\jdk1.6.0_35\jre\bin\server\jvm.dll" (disabled "use default") or where your JVM resides -> you need to specify the complete path to the jvm.dll.
Regarding getting to know which Java the system is running on: That's difficult to answer, there isn't really one Java version that the system is running as such. E.g. for Windows there may be one Java version set in the PATH, a potentially different one in JAVA_HOME / JRE_HOME / ..., one (or more) set in the registry, a certain version plugin active in each web browser used for applets etc. You have to check in the part you are interested in. Most good Java apps will display the version used somewhere, in logs, about dialogs or so. For Firefox you can check in the add-ons / plug-ins list. A Java exe wrapper like JSmooth can search for Java in different places and choose the most suitable, e.g. the newest, not necessarily the most "exposed".
Set java version to two different Tomcat instances
change JAVA_HOME
to the explicit path of your java installation in tomcat\bin\catalina.bat
for windows or tomcat\bin\catalina.sh
for linux
for java7 the path could be C:\Program Files\Java\jre7
Related Topics
Print on Terminal and into File Simultaneously
Service Doesn't Support Chkconfig
Get Rid of "Gcc - /Usr/Bin/Ld: Warning Lib Not Found"
Running Docker on Ubuntu: Mounted Host Volume Is Not Writable from Container
Docker Not Responding to Ctrl+C in Terminal
Dynamic Loading and Weak Symbol Resolution
How to Get the Exit Status a Loop in Bash
Can Inode and Crtime Be Used as a Unique File Identifier
Deceive the Jvm About the Number of Available Cores (On Linux)
Solution for Git Gui Client for Remote Ssh
How to Find All of the Distinct File Extensions in a Folder Hierarchy
How Is the Address of the Text Section of a Pie Executable Determined in Linux
How to Get the Interface Name/Index Associated with a Tcp Socket