2

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?

Community
  • 1
  • 1
Alexander Rumanovsk
  • 2,043
  • 4
  • 21
  • 33

1 Answers1

3

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.

M A
  • 71,713
  • 13
  • 134
  • 174
  • The JTDS on my JBOSS lib is 1.2.2, which is for java 6, not java 7. The only place I found a JTDS version for java 7 was in my .settings from eclipse, but since I compile the code using maven, it still makes no sense to me. – Alexander Rumanovsk Dec 08 '14 at 20:04
  • Are you sure the version that's used in the application is for Java 6? The error clearly shows that the classes have the Java 7 format. Maybe you can run `mvn dependency:tree` to check the version used in Maven. Also from [this link](http://sourceforge.net/p/jtds/news/2012/10/jtds-jdbc-driver-127-and-130-released/), version 1.3.0 is the first version that uses Java 7. – M A Dec 08 '14 at 20:17
  • None of the poms from my application state a specific JTDS version. I've searched all over my workspace and it found occurrences of JTDS only at eclipse .settings files. No other place. – Alexander Rumanovsk Dec 08 '14 at 20:25