1

I am using some client jars in my component the client jars are compiled and run with java 7.I am not able to move to java 7 due to some management decisions .I want the client jars to work (compile/run) in my java 6 any way i can achieve this?

Thanks

constantlearner
  • 5,157
  • 7
  • 42
  • 64
  • Do you have access to the source code of the classes? – nanofarad Jul 15 '13 at 11:48
  • No I dont have access to these source code they are shipped to me as jar.. – constantlearner Jul 15 '13 at 11:49
  • [This question](http://stackoverflow.com/questions/17347589/verify-java-version-compatibility/17347680#17347680) might help. – selig Jul 15 '13 at 11:51
  • @selig Still requires recompilation. – nanofarad Jul 15 '13 at 11:51
  • [This question](http://stackoverflow.com/questions/6699347/jdk-7-class-file-backward-compatibility-with-jdk-6) might be interesting as well (that's about the class file backward compatibility) – gaborsch Jul 15 '13 at 11:54
  • 1
    The management has decided that you shouldn't be using Java 7. I would inform them that they have decided you won't be using the library. BTW Java 6 is end of free service and Java 8 will be available in less than a year. – Peter Lawrey Jul 15 '13 at 12:13
  • On which version does the software eventually run (Java 6 or 7)? – Matt Jul 15 '13 at 12:15
  • It will run on java 6.Also one more doubt I had can 1.7 java load jars compiled on 1.6 jvm? – constantlearner Jul 15 '13 at 12:23
  • Yes it can. The problems are with running new JARs on old JVMs, not the other way around. – Stephen C Jul 15 '13 at 13:02
  • @constantlearner Applications still on Java 6 should be considered critical production risks. Oracle have EOL'd 6, and it is no longer receiving any updates, including to the TZ updates. – kittylyst Jul 22 '13 at 12:55

1 Answers1

2

I want the client jars to work (compile/run) in my java 6 any way i can achieve this?

If you have source code, you can try compiling the code on a Java 6 build platform. However, there are no guarantees it will compile and run as-is:

  • The code may use Java 7 language constructs.

  • The code may use Java 7 specific classes or methods.

The bad news is that there is no magic way to deal with any compilation errors arising from the above. You will need to hand translate the Java 7-isms into Java 6 compatible source code.

But the good news is that if the code does compile on Java 6 JDK, there is pretty good chance that it will run on Java 6 JRE.


If you don't have access to that source code, then the problem is much, much harder

It is theoretically possible to translate bytecode to an earlier version, but the tools for doing this are tend to have significant limitations. Here are some possible leads:

Note that I've not managed to find a "retro" tool that translates Java 7 to Java 6. (Either nobody has done the work, or there is something about Java 7 makes the problem intractable.)

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