views:

270

answers:

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?

+11  A: 

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

You'll be fine.

MBCook
+1  A: 

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

jodonnell
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.
Alex Beardsley
if you want to allow your code to run on older versions of java you can give javac the -target parameter. See http://java.sun.com/javase/6/docs/technotes/tools/windows/javac.html
Catchwa
Problem is, that won't work if you're using any of the newer language features.
Michael Borgwardt