Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (4k points)

I'm trying to debug a

"Bad version number in .class file'

error in java, is there a way for me to check which version the .class files are?

I'm using JRE1.5.0_6, but my JDK is version 1.6.0_13.

I'm compiling with compatibility mode set to 1.5 in eclipse which I thought would work...

1 Answer

0 votes
by (46k points)

You're seeing for this toward the center line (for a class named MyClass):

On Unix/Linux:

javap -verbose MyClass | grep "major"

On Windows:

javap -verbose MyClass | findstr "major"

You require the major version from the samples. Here are some example values:

  • Java 1.2 uses major version 46
  • Java 1.3 uses major version 47
  • Java 1.4 uses major version 48
  • Java 5 uses major version 49
  • Java 6 uses major version 50
  • Java 7 uses major version 51
  • Java 8 uses major version 52
  • Java 9 uses major version 53
  • Java 10 uses major version 54
  • Java 11 uses major version 55

Related questions

0 votes
1 answer
0 votes
1 answer
asked Feb 6, 2021 in Java by dante07 (13.1k points)
+6 votes
2 answers
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...