Reputation: 315
My existing server is running on Java 1.6 and I cant upgrade it.
I need to use some third party jar/api that is compatible with Java 1.8
, when I write some code to access its API, eclipse throws
Exception in thread "main" java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version
How I can proceed now? Not sure if this is duplicate question, if yes please provide some link on this.
Upvotes: 2
Views: 195
Reputation: 38328
If you must use this 3rd party jar, then you must compile the 3rd party jar using -target 1.6 (to target java 1.6). Maybe you will get the source and compile it yourself or maybe you will get somebody else (the vendor, perhaps) to compile it.
All other options are:
Upvotes: 0
Reputation: 140613
The point is: Java virtual machines are not forward compatible.
A .class file that was generated by an "n+1" compiler can't be used on a "n" JVM. (unless you specifically instruct the compiler to compile for older versions of java)
Your choices:
Option 1 can get pretty ugly - as that library might have dependencies on system classes that Java6 doesn't have.
Upvotes: 2
Reputation: 60046
This is not possible to use multiples Java version or even multiples JVMs
in the same project
If you really need this API, then you have just few choices, the best one is to upgrade all the project to use Java 1.8
Upvotes: 1
Reputation: 2540
As others have pointed out, you can't do this. However, you may be able to find older versions of the libraries you wish to use, and those libraries may support your particular version of Java. This potentially means that you will be adopting bugs into your software, but that's just how software evolves over time.
Upvotes: 0
Reputation: 9624
No, you can't use jars compiled under java 1.8 in an environment running at java 1.6
Upvotes: 0