4

I need to write a school exercise using Java and submit it to an online grading system that runs Java 7. Do i have to download Java 7 on my pc and run my program using this or can i download the latest one(12.0.1) and run it in a Java 7 machine?

Ortomala Lokni
  • 41,102
  • 15
  • 134
  • 190
  • I think you are mixing things a bit. See here: https://stackoverflow.com/questions/4696611/jdk-jre-java-version-confusion the explanation about Java versioning. – Eugene Jul 15 '19 at 13:58
  • 1
    You **might** not have any issues developing on Java 12 and running on Java 7. That said, I'd just download the Java 7 JDK and develop on that. https://stackoverflow.com/a/33483644/3059385 – Christopher Schneider Jul 15 '19 at 16:51

2 Answers2

5

You can use Java 12 to compile Java 7 code with the option --release 7.

Running javac --help shows:

 --release <release>
    Compile for a specific release. Supported releases: 7, 8, 9, 10, 11, 12

If you want to target a specic JVM use --target <release>:

--target <release>, -target <release>
    Generate class files for specific VM version. Supported versions: 7, 8, 9, 10, 11, 12
Ortomala Lokni
  • 41,102
  • 15
  • 134
  • 190
-2

The answer is it is a very low probability. Why? Because in most initial Java education courses the syllabus and content will not touch areas of Java that have been deprecated since version 1.7 (i.e. 7). A deprecation list can be found here: https://docs.oracle.com/en/java/javase/12/docs/api/deprecated-list.html

Please view this a two different considerations, compiling and running. If you are submitting code (via cut+paste or file upload as a .java file), then you are only dealing with compiling (as apposed to the runtime environment). So you're asking a question about the differences between the Java 7 JDK and Java 12 JDK.

There are many improvements to Java since version 7, I encourage you to learn about them when you can.

Jeff Stewart
  • 105
  • 5