How to get JUnit version

To upgrade to a newer version of JUnit, you just have to download the new version and replace the old version with the new jar. It's as simple as that.

There isn't really a nice way to tell which version of JUnit you're currently using, unless you're using maven or something like that. In general, you can tell between

  • JUnit 3: if you're using the junit.framework.* classes
  • JUnit 4: if you're using the org.junit.* classes (the tests have @Test annotations on them)

In general, JUnit is backward compatible (JUnit 3 tests can be run under JUnit 4), but JUnit 4 is recommended.


This will print the version of jUnit.

java -cp <path-to-junit-folder>/junit.jar junit.runner.Version

The version that you are running depends on the classpath of the running application. It's possible to have multiple versions on the same machine, but if this is in question you can just write a test for it:

import junit.runner.Version;

class SomeTests {

    void testJUnitVersion() {
        assertEquals("4.8.2", Version.id());
    }
}