What version of Java is needed for JUnit 4.8

I try to run a JUnit test with a 1.5 JRE, but I get an error:

  java.lang.UnsupportedClassVersionError: Bad version number in .class file 

When upgrading to JRE 1.6 (actually in the JDK, but that doesn't matter, right?) Everythings works fine.

So the questions are:

  • Do we really need Java 6 for the current version of JUnit?
  • What is the latest version of JUnit that works with Java 5?
+7
java junit version
source share
3 answers

A spot check of several classes shows that the jar file JUnit 4.8.2 was compiled with java 5 or with the java 6 compiler with the -target option, so it creates class files compatible with java5.

A more likely explanation is that you accidentally compiled a test that you want to run with the Java 6 JDK. What is he doing:

 javap -verbose -classpath YOUR_TOP_DIRECTORY com.yourname.YourTest 

they say at the top of their output for the "main version"? If he says 50 , then the problem is that you compiled your test class only for java 6. You need to either use the JDK 5 compiler, or pass the -target 1.5 option to your compiler.

+6
source share

The current .jar file for JUnit 4.8.2 has been compiled with / for Java 5 (version version number is 49.0).

I remember that the previous version was accidentally built using Java 6 (and without the -target switch), but it was just a mistake.

+5
source share
+3
source share

All Articles