0

I have an old jar file with my library which use jdk 1.7.0_03. But on my new computer I did't have applicable version of jdk. My current version is 1.6. Is it possible to downgrade version of jar file (1.7 -> 1.6) without project source files so that my jar file could run on java 1.6?

Alex
  • 2,091
  • 6
  • 31
  • 49

4 Answers4

1

You can't possibly downgrade a .jar file since it contains compiled code. If that code uses 1.7 features you are stuck. You can try running it on 1.6 though. If you have luck it will work.

Adam Arold
  • 29,285
  • 22
  • 112
  • 207
1

You can try to unpack a jar file with the "jar" CLI Tool and change the Version in the Manifest file. Then you need to Repack the file again. This worked for me once with an OSGi Bundle.

0xAffe
  • 1,156
  • 1
  • 13
  • 29
  • 1
    This is unlikely to work. Or more precisely, it would only work if the classes were already compiled for a Java 1.6 target. – Stephen C Nov 20 '13 at 03:52
0

Is it possible to downgrade version of jar file

No. you need to recompile the JAR

without project source files

You need the source-file to recompile. you can decompile the class files, but it's not that easy

Philipp Sander
  • 10,139
  • 6
  • 45
  • 78
0

What you are looking for is a bytecode backporting tool. While such tools exist, there isn't one (AFAIK) that converts Java 7 bytecodes to Java 6 or earlier.

By the way, using the jar command to replace the manifest won't help. The Java classfile format is versioned, and the version number changed between 1.6 and 1.7. A Java 6 JVM cannot cope with a Java 1.7 (or later) classfile, irrespective of the JAR manifest.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216