• Post Reply Bookmark Topic Watch Topic
  • New Topic

running jar file crearted by 1.6 on 1.5  RSS feed

 
srini carry
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jar file which was created using java 1.6 . Now I want to run this using java 1.5 can I run this using java 1.5 ?
 
Greg Charles
Sheriff
Posts: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. Java tries to be backward compatible, so a 1.6 JVM should be able to run classes compiled by a Java 1.5 compiler. The reverse is not true.
 
srini carry
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My project has a third party jar file which is complied by 1.6, my project I am creating a jar file this jar file I want to run on java 1.5 , please advice me how can I use the thirdparty jar built using 1.6 in my project which uses 1.5

Please advice.

 
William P O'Sullivan
Ranch Hand
Posts: 859
Chrome IBM DB2 Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't use those Classes, since the VM has no idea if there are API changes in the 1.6 that will not work on 1.5.

The opposite is true as already mentioned.

WP
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it open source? If so try to build it from the source using 1.5. It is probable though that they use 1.6 classes which would mean you might have to change a thing or two to make it work.
 
Greg Charles
Sheriff
Posts: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been going through this a lot recently because I'm working on a project where I'm forced to use a Java 1.4 VM. (No, I'm not kidding. I wish I were.) I recently was able to find a relatively new vintage of Mockito that's separately maintained as JDK 1.4 compatible by a volunteer (bless him!) If you can't find something like that for your third party jar, and recompiling it from the source yourself (as Bill suggested) isn't working out, then you might have to try getting an earlier version of it and hope your project is not using the new features.

Another option is just upgrading your project to use Java 6. It's ridiculous to still be using Java 5, which is now years out of date. (Hello kettle, I'm pot. Pleased to meet you!)


By the way, here's a little utility that helps you figure out what Java version you will need for a given jar: http://code.google.com/p/versioncheck/
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!