How to solve module info in jdk9 / java-9 Java compilation error
•
Java
I tried to run under code using jdk-9, but I encountered a problem compiling with the command
command
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..."); } }
The package structure is as follows
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)
Solution
According to jigsaw issues list, module names cannot end with numbers The purpose is to prevent the author from encoding the version number in the module name
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码