user3016945
user3016945

Reputation: 265

is it possible to execute java 1.7 compiled code file in local machine which contains java 1.6

I have java program compiled with java 1.7 and I need use this compiled file in another machine which contains java 1.6.

When I am running 1.7 java compiled file with java 1.6 "unsupported class version exception" getting.

Is their any backward compatibility to execute java 7 compiled file in java 1.6.

Upvotes: 1

Views: 1316

Answers (4)

Afsun Khammadli
Afsun Khammadli

Reputation: 2068

There are some reason for exception.If you use library and it is not in jdk 1.6 it's problem for compile code in 1.6 because 1.6 does not contain libraries which is in 1.7

Upvotes: 0

Jorge_B
Jorge_B

Reputation: 9872

It will always fail when trying to check version number. Check your requirements and talk to your operators. If your only option is to run in a box with 1.6, then you should recompile and make sure you have all the information on your execution environment before running into any more problems when going real (for example, make sure you know about JDK provider, production machine dependent paths...)

Upvotes: 0

Leos Literak
Leos Literak

Reputation: 9474

Sorry, as far as I know, this is not possible. You can compile 1.6 compatible class files on JDK7, but you cannot run JDK7 class files on older virtual machines.

Upvotes: 1

peter.petrov
peter.petrov

Reputation: 39457

  • If it was compiled with -target >= 1.7 then you would have a problem. That is because the compiler was instructed to generate bytecode to run on a JVM with version >= 1.7. But then you ran it on JVM 1.6.
  • If it was compiled with -target <= 1.6 then you should have no problem.

Upvotes: 0

Related Questions