How to solve module-info.java compilation error in Jdk9 / java-9

I am trying to run the code below using jdk-9 but encountering a problem while compiling with the command

Team

 javac -d mods .\module-info.java com\nirav\modi\Test.java

Error

.\module-info.java:1: error: class, interface, or enum expected
module module1 { }
^
1 error

module-info.java

module module1 { 

}

Test.java

package com.nirav.modi;

class Test {

    public static void main(String args[]){

        System.out.println("Hello Modular...");

    }

}

Package structure looks below

module1\module-info.java
module1\com\nirav\modi\Test.java

JDK Version

java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+153)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+153, mixed mode)
+6
source share
3 answers

In the Jigsaw Issues List , a module name cannot end with a number. The goal is to prevent authors from encoding version numbers in module names.

+7
source

JSR 376 is not yet final, and there are several topics that are still under discussion. The latest suggestion for #VersionsInModuleNames is here:

http://mail.openjdk.java.net/pipermail/jpms-spec-experts/2017-March/000659.html

+2

, -jigsaw jdk build ... , jigsaw

, , .

java -version :

java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+153-jigsaw-nightly-h6003-20170124)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+153-jigsaw-nightly-h6003-20170124, mixed mode)

, -. ( 149)

EDIT2 , jdk-9 build 153 :

javac -d mods module-info.java Modules.java
module-info.java:1: warning: [module] module name module1 should avoid terminal digits
module module1 {
      ^
1 warning

"1" , , mods , .

+1

Source: https://habr.com/ru/post/1014410/


All Articles