1

I updated my system to run off of Java 9 primarily and my spring projects are also supporting Java 9. I have an issue however with my Spring Tool Suite (Eclipse 4.7.2) where the program is saying that my code is incompatible with my source level compatibility settings and must be JRE 1.5 and up (parameterized types for example).

In my Project properties my Compiler Compliance Level and Source Compatibility is set to '9'. In my Window->Preferences, I have set my checked installed JRE to the location of my Java jdk-9.0.1 folder.

Here is my sts.ini (eclipse.ini) file:

STS.ini

-startup
plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.551.v20171108-1834
-product
org.springsource.sts.ide
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.8
--add-modules=ALL-SYSTEM
-Xms40m
-Dosgi.module.lock.timeout=10
-Xverify:none
-Dorg.eclipse.swt.browser.IEVersion=10001
-Xmx768m
--launcher.appendVmargs
-vm
C:\Program Files\Java\jdk-9.0.1\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.8
--add-modules=ALL-SYSTEM

Any help solving this problem would be greatly appreciated.

4

3 回答 3

2

The JVM that you specify in your STS.ini is not related in any way to the projects and their compiler levels in your workspace. You can easily run STS on top of a JDK8 and still have projects in your workspace that compile for Java9.

In order to compile projects against a certain level, you have to have a related JDK configured in your preferences. Sounds like that you said that you did that already. There is also a sub-section called "Execution Environment", where you can specify which JDK on your machine should be used for which Java language level. Make sure that you have the right JDKs selected there.

于 2018-01-07T17:25:47.293 回答
1

Your STS.ini looks broken: there should be only a single -vmargs section; -vm and --launcher.appendVmargs must be above -vmargs:

Remove the last three lines (which are duplicated lines) and move --launcher.appendVmargs, -vm and the following line above -vmargs:

-startup
plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.551.v20171108-1834
-product
org.springsource.sts.ide
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vm
C:\Program Files\Java\jdk-9.0.1\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.8
--add-modules=ALL-SYSTEM
-Xms40m
-Dosgi.module.lock.timeout=10
-Xverify:none
-Dorg.eclipse.swt.browser.IEVersion=10001
-Xmx768m
于 2018-01-06T14:32:21.820 回答
0

For those who come across the same issue in the future: I solved the issue, but neither of the previously posted corrected the issue (although they were helpful). I followed the steps here and added the '-clean' line to my sts.ini file and restarted eclipse.

于 2018-01-08T16:58:02.180 回答