简体   繁体   中英

Does “Hello World!” program compiled by JDK 7u3 runs with an older JREs (eg. JRE 6)?

Does Hello World! program compiled by JDK 7u3 runs with an older JREs (eg. JRE 6)?

If the answer is YES , When a java program doesn't run with an older JRE?

By default the class files produced by javac will have a version number appropriate for the JDK they were produced on. To produce class files for earlier versions you will need to specify -target and to do that you will also need -source . -source 1.6 -target 1.6 say.

However, you will still be picking up the current Java library, which contain classes, methods (possibly overloads), etc., that were not in the previous version. To sort that out, use -bootclasspath to point to the rt.jar of the target JRE.

Nope. You will get classloader exception complaining about non supported class version. Unless of course you specifically target lower version when compiling

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM