How to resolve module-info.java compile error in Jdk9/java-9

后端 未结 4 1276
傲寒
傲寒 2021-01-05 03:06

I am trying to run below code using jdk-9 but facing problem when compile using command

Command

 javac -d mods .\\module-info.java c         


        
4条回答
  •  囚心锁ツ
    2021-01-05 03:34

    Seems like you are compiling with non-jigsaw jdk build here... here is the link were they are jigsaw

    With that compiler these same samples that you have compile just fine on my laptop.

    This is how java -version looks like for project jigsaw:

    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)
    

    EDIT It works with both jigsaw and non-jigsaw build. I have just tried it (build 149)

    EDIT2 So i've tried with jdk-9 build 153 and here is what I got:

    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
    

    removing the "1" and running the same command compiled OK and mods directory was created with both class files compiled just fine.

提交回复
热议问题