3

Other developer had pushed the code and we are building it on a build machine. I was getting Unsupported Major.minor version 52 error.

Is there any way to find the version of JDK used while developing the Java file.

Could some one please help

manu endla
  • 301
  • 4
  • 19
  • 1
    Possible duplicate of http://stackoverflow.com/questions/1096148/how-to-check-the-jdk-version-used-to-compile-a-class-file – racraman Feb 24 '17 at 09:14

1 Answers1

2

By developing you probably mean compiling the java file.

Take the .class file and look inside it with javap:

javap -c -verbose ConstructorReference.class

Output (at the beginning of the output)

 public class org.ConstructorReference
 minor version: 0
 major version: 53

53 - means java 9

52 - means java 8

You get the error because the build machine is using most probably jdk-7 and your class files were compiled with jdk-8 (evidence of 52).

Eugene
  • 117,005
  • 15
  • 201
  • 306
  • No, not by comipling. Other developer has created a .java file on his PC and shared me the repo . I have to build this code on a build machine. So was wondering how to get to know the JDK version used on the developers PC – manu endla Feb 24 '17 at 09:33
  • 2
    @manuendla when are you getting the exception then? at which point? when you compile it? when it runs somewhere? – Eugene Feb 24 '17 at 09:35
  • This is a TestNG project, I have just copied the code, running it on a build machine – manu endla Feb 24 '17 at 09:38
  • 4
    @manuendla so the build machine is *compiling* the code with jdk-8, but it runs the tests with jre-7. Check the settings of those. – Eugene Feb 24 '17 at 09:43