3

I have an Eclipse workspace with several Java projects (in Maven); these have dependencies on each other. Recently I started changing just some of the projects to target Java 1.7, and other than resolving some new warnings, nothing is different when compiling.

However, it feels like something might go wrong when I try to run everything. How are class files loaded, and are there any issues, in the following situations?

  • Is there a problem when a Java 1.6 project depends on a Java 1.7 project? Will the 1.6 VM just refuse to run any 1.7-generated bytecode, or does something weird happen in order to get it to run?
  • Is there a problem when the reverse happens?
1
  • yes it refuse to deploy . Both the jvm version must be same. Commented Feb 26, 2013 at 4:42

3 Answers 3

6

When you have java 1.6 project depends on a Java 1.7 project or java 1.7 project depends on a Java 1.6 project, you should always run your program on the higher version of JVM, which is java 1.7 in this case. In a nutshell, in most cases, class files built with the Java SE 6 compiler will run correctly in Java SE 7. But there are some exceptions. Please see Incompatibilities between Java SE 7 and Java SE 6 for a list of incompatibilities between Java 6 and Java 7.

Sign up to request clarification or add additional context in comments.

Comments

1

You can build a project with JDK 1.6 that has some libraries that where generated with 1.7

HOWEVER if some of the code from the project 1.7 needs some JDK 1.7 feature (for example, it uses the new Swing combobox with generics) it won't run on a 1.6 JVM.

So this is something to be very careful about, as you can run into compile time trouble (which is at least not silent) but also runtime trouble. If you can avoid this, it might be better for you.

Comments

0

I have also faced a similar problem and as per my knowledge i don't think that 1.6 VM can run any 1.7-generated bytecode but i think the reverse is possible as 1.7 is a upgraded version of 1.6VM.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.