Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat 7 with Java 8 on Windows and Linux

I got the following trouble:

I wanna use Java Servlet built on target Java-8 with Apache Tomcat 7.0.54.

When I run it on my local machine (Win-64, jdk build 1.8.0-b132) it works perfectly.

But when I deploy it on production (Debian GNU/Linux 7.5 (wheezy), jdk build 1.8.0-b132, Tomcat 7.0.54-2) it throws:

Unsupported major.minor version 52.0 (unable to load class ru.tomtrix.fvds.servlets.ItemServlet)

... that means unsupported Java-8 classes. So what's going wrong to Windows and Linux instances of the same version of Tomcat?

like image 715
Mitrakov Artem Avatar asked Jul 01 '14 07:07

Mitrakov Artem


1 Answers

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?

like image 181
Mitrakov Artem Avatar answered Oct 21 '22 01:10

Mitrakov Artem