2

Is there any way I can run class files (i.e. with main as the entry point) on JDK 6 that were compiled with Java 5?

1
  • You cannot go backward to run 6 on 5 or 4, but it should be forward compatible. Like running i386 code on i686. Commented May 18, 2009 at 0:37

2 Answers 2

13

Yes. Old java code can be executed on newer JVMs, but not the other way around.

You'll be fine.

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

Comments

1

Sure, that should work with no trouble at all. Why, are you having a problem? Be more specific.

3 Comments

I am not having problems doing it; admittedly I have not tried it yet. I wanted to make sure this is possible before I start heading down that road. I just remember having problems running Java 5 code on different versions, I don't remember if it was 6; I guess I was trying to run 5 on 1.4.
if you want to allow your code to run on older versions of java you can give javac the -target parameter. See java.sun.com/javase/6/docs/technotes/tools/windows/javac.html
Problem is, that won't work if you're using any of the newer language features.

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.