Reputation: 2313
I'm trying to run a java application, but when I start it on JBOSS, I get the error:
java.lang.UnsupportedClassVersionError: net/sourceforge/jtds/jdbc/Driver : Unsupported major.minor version 51.0
I searched around and found out that this is caused by compiling the code with java 7 and running it with java 6, so I started looking for my java configurations.
When I ran javac -version and it returns me:
U:\>javac -version
javac 1.6.0_27
When I run java -version it returns me:
U:\>java -version
java version "1.6.0_27"
Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
Java HotSpot(TM) Client VM (build 20.2-b06, mixed mode)
When I run mvn -v:
U:\>mvn -v
Apache Maven 3.0.4 (r1232337; 2012-01-17 06:44:56-0200)
Maven home: C:\dev\apache-maven-3.0.4\bin\..
Java version: 1.6.0_27, vendor: Sun Microsystems Inc.
Java home: C:\dev\Java\jdk1.6.0_27\jre
I'm not sure why this is happening, since everything is running on java 6 and version 51.0 is from java 7, according to this post: How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
Anyone knows any other way to know how my code may be compiling on java 7, instead on java 6?
Upvotes: 2
Views: 3195
Reputation: 72874
The problem is that the jTDS library itself is compiled in Java 7. You should use Java 7 to run it, not Java 6.
If you cannot change the Java version, you can try using an older version of the library that's compiled in Java 6. Or if you have access to the source code, you can try building it with the -target
compiler flag set to 1.6.
Upvotes: 3