Getting java.lang.UnsupportedClassVersionError: : Unsupported major.minor version 52.0 In Team City version- 2017.1.3 (build 46961)

Team city version  TeamCity Enterprise 2017.1.3 (build 46961)

When trying to execute a jar file, getting the below error

[Step 1/1] java.lang.UnsupportedClassVersionError: com/rsys/rsysTest/invoker/RSYSInvoker : Unsupported major.minor version 52.0
[17:48:40][Step 1/1] at java.lang.ClassLoader.defineClass1(Native Method)
[17:48:40][Step 1/1] at java.lang.ClassLoader.defineClass(Unknown Source)
[17:48:40][Step 1/1] at java.security.SecureClassLoader.defineClass(Unknown Source)
[17:48:40][Step 1/1] at java.net.URLClassLoader.defineClass(Unknown Source)
[17:48:40][Step 1/1] at java.net.URLClassLoader.access$100(Unknown Source)
[17:48:40][Step 1/1] at java.net.URLClassLoader$1.run(Unknown Source)
[17:48:40][Step 1/1] at java.net.URLClassLoader$1.run(Unknown Source)
[17:48:40][Step 1/1] at java.security.AccessController.doPrivileged(Native Method)
[17:48:40][Step 1/1] at java.net.URLClassLoader.findClass(Unknown Source)
[17:48:40][Step 1/1] at java.lang.ClassLoader.loadClass(Unknown Source)
[17:48:40][Step 1/1] at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
[17:48:40][Step 1/1] at java.lang.ClassLoader.loadClass(Unknown Source)
[17:48:40][Step 1/1] at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
[17:48:40][Step 1/1] Exception in thread "main"
[17:48:40][Step 1/1] Process exited with code 1
[17:48:41][Step 1/1] Process exited with code 1
0
4 comments

Hi Bhavitha,

how are you trying to execute the jar file?

The issue seems to be that you are trying to do it with the wrong java version: https://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-versi

1
Avatar
Permanently deleted user

Hi Denis,

Thanks for your reply!

I am using the command line as build command to execute the jar file.

Actually jar was compiled using java 8 and also made sure Agent(VM) on which i am trying to execute had proper java, but i guess the TeamCity version which i am using supports 7.

I recompiled the jar using lower 7 version and then observed that was able to execute successfully.

 

 

 

 

 

0

Hi Bhavitha,

you should be able to keep the java-8 compiled version, but if you are running a command line, you are probably running "java -jar <path-to-jar>". This "java" call won't use the agent's, but will use whatever is on the path. If you have both version 7 and 8 installed, version 7 might be on the path before 8 and this might be being used by the runner. Try either uninstalling 7, removing it from the path, specifying the full path to java 8 or making sure that the path prioritizes the installation of 8, and it should work with the java-8-compiled jar.

1
Avatar
Permanently deleted user

Hi Denis,

You were absolutely right. Issue was the path reference on the agents. 

Have added the path pointing to Java 8 and it works amazingly. Thanks a lot! it made the work easy.

Thanks,

Bhavitha

 

0

Please sign in to leave a comment.