javaeclipsemodulejava-9eclipse-oxygen

Eclipse oxygen gives syntax error warning in module-info file


I am trying to learn new concept of modules in JAVA. I am using Eclipse oxygen 4.7.3a with JDK 11.0.1.

I am getting syntax error warning on my module-info.java file. It seems that compiler is not able to parse new keywords of module-info.java file.

enter image description here

I performed following solution to fix this issue :

  1. Installed all JAVA 11 updates from Eclipse JAVA 11 updates URL : http://download.eclipse.org/eclipse/updates/4.9-P-builds

  2. Added JVM argument "--add-modules=java.se.ee" to eclipse.ini file.

enter image description here

But issue is still there . Any suggestions/inputs appreciated !


Solution

  • Java 11 requires

    or Eclipse 2018-12 (4.10) which will be released on December 19, 2018.

    Eclipse Oxygen was released before Eclipse Photon, Eclipse 2018-09 and Java 11 and therefore cannot detect a Java 11 JDK/JRE yet.

    In addition, the Java compiler compliance level must set to 9 or higher (Project > Properties: Java Compiler) to have a module-info.java file with its own syntax which has been introduced with the Java Platform Module System (JPMS) in Java 9. If the compiler compliance level is lower than 9 the token module at the beginning of a .java file is a syntax error because module-info.java is a regular Java file in Java <= 8.

    Please note that the setting in eclipse.ini refers to the JRE/JDK that is used to run Eclipse. The JREs or better (to see the source code) JDKs to use for development have to be specified in Window > Preferences: Java > Installed JREs.