I was doing a JSP webpage/app within eclipse. Since I had some problems with it, I wanted to change, so I backup my files (*.java and *.jsp) to another folder and forgot about eclipse.
Builds in eclipse: OK
Now, to compile my code without using eclipse, I do something like this:
javac -d ./Server/WEB-INF/classes/ ./src/tfg/lti/Config/TextFileWorker.java
javac -d ./Server/WEB-INF/classes/ -cp ./Server/WEB-INF/classes/ ./src/tfg/lti/Config/Setup.java
javac -d ./Server/WEB-INF/classes/ -cp ./Server/WEB-INF/classes/ ./src/tfg/lti/UI/Painter.java
Builds with my code: OK
But then, if I try to open my application on Web Browser, I get from Tomcat:
Estado HTTP 500 -
type Informe de Excepción
mensaje
descripción El servidor encontró un error interno () que hizo que no pudiera rellenar este requerimiento.
excepción
javax.servlet.ServletException: java.lang.UnsupportedClassVersionError: tfg/lti/UI/Painter : Unsupported major.minor version 51.0 (no puedo cargar clase tfg.lti.UI.Painter)
Translating the spanish parts:
Status HTTP 500 -
type exception report
message
description The server found an internal error () that made it couldn't fill this requeriment
exception
javax.servlet.ServletException: java.lang.UnsupportedClassVersionError: tfg/lti/UI/Painter : Unsupported major.minor version 51.0 (can not load the class tfg.lti.UI.Painter)
Then, based on How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version, I tried to build it changing the target, something like this (to all files):
javac -target 1.5 -d ./Server/WEB-INF/classes/ ./src/tfg/lti/Config/TextFileWorker.java
Notice: the target version was choosen just to try, didn't know what value should be correct
Problem 1: since I was building it with eclipse before, I don't know which target was being used before, but I thought it should be using the last one (1.7). Now I don't understand why it wasn't. Project setup I guess?
Then, when building it again, I got the next error:
javac: target release 1.5 conflicts with default source release 1.7
So now, based on Topic, see last answer please, an -source 1.5
was added to javac, having something like:
javac -source 1.5 -target 1.5 -d ./Server/WEB-INF/classes/ ./src/tfg/lti/Config/TextFileWorker.java
But then, I obtained the last error:
warning: [options] bootstrap class path not set in conjunction with -source 1.5
1 warning
So finally, based on bootstrap class path not set in conjunction with -source 1.6 3, and "learned" that I can ignore this warning if I'm sure I'm not using anything from the new SDK.
Since I'm NOT, I don't want to ignore it, but still don't know how was eclipse building my project, and how should I build it in order to be able to run it again on my tomcat server.
Some data:
Tomcat server: version 6
Java JDK: 1.75
java -version output:
java version "1.7.0_75"
Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
Java HotSpot(TM) Server VM (build 24.75-b04, mixed mode)
I finally managed to solve it. It was as SMA told me, I was building it with JDK 7, and running it with JDK6. But I didn't know how it works, so I had to look for it.
First, I managed to notice that with Unsupported major.minor version 51.0. However, as You can see They had compile with an older version, but I was executing it with the older one.
Then, based on Change the JDK used by Tomcat, I modified the JAVA_HOME (it was not even set on the /etc/default/tomcat6
file) to the JDK7. To do this, I add to the file:
JAVA_HOME=/usr/lib/jvm/jdk1.7.0_75
Then restarted tomcat(6).
With these changes done, It finally worked.