How to target older platforms with JDK9? (Target: 1.3)

582 Views Asked by At

I realize this isn't 100% relevant yet, but I'm very curious about this. In JDK8, javac parameters "source" and "target" are deprecated, and will be removed in JDK9. As a JavaME developer, I'm wondering how then I'll be able to target older platforms. For example, I'm using target 1.3 when developing for Blu-ray. How do I compile my Xlets for Blu-ray when JDK9 is out if there's no "target" option? I imagine there must also be other (although we can agree not a lot) people out there still needing to target older devices. What do we do when JDK9 is out?

EDIT: Is it even possible to target 1.3 with JDK9?

2

There are 2 best solutions below

7
On BEST ANSWER

To answer the question "how to compile without the target option", the new -release flag is a safer and more reliable alternative to -source and -target. See JEP-247 for more details. You will target older platforms with -release the same way you would with -source and -target.

The statement "source and target will be removed in JDK9" is sort of true but not quite: the -source and -target flags themselves are not removed, but their use to target specific older versions is deprecated. From JEP-182: "in JDK 9, support for a source or target of 1.5 or earlier will be removed."

To answer the question "is it even possible to target 1.3 with JDK9?" The answer is that with regards to the -release flag, JDK9 will not compile to target 1.3.

From javac -help:

--release <release>
      Compile for a specific VM version. Supported targets: 6, 7, 8, 9

Your best option is to compile with an older version of the JDK. If you need to target 1.3, there's not a lot of reason to use the Java 9 compiler anyway.

3
On

I am unaware of -source and -target being deprecated in Java 8 and removed in Java 9 - the early access build (at least 9-b131) still has them. Do you have a source for that?

The only change in that area I know of is JEP 247, which introduces -release, which is kind of a shortcut for the other two.