Java 9 error: not in a module on the module source path

后端 未结 2 609
梦谈多话
梦谈多话 2020-12-30 12:05

Project structure

I have a project written in Java 8 and I want to update it to Java 9. So I separated the classes into 2 separate modules. Modules:

2条回答
  •  一生所求
    2020-12-30 12:25

    For completeness sake, the complete javac command is as follows:

    javac -d out --module-source-path "./*/src/main/java/" $(find . -name "*.java")
    

    Based on the official tutorial from OpenJDK (slightly modified directory structure shown below), and OpenJDK version "11.0.1", the above command javac works for me:

    .
    ├── com.greetings
    │   └── src
    │       └── main
    │           └── java
    │               ├── com
    │               │   └── greetings
    │               │       └── Main.java
    │               └── module-info.java
    ├── org.astro
    │   └── src
    │       └── main
    │           └── java
    │               ├── module-info.java
    │               └── org
    │                   └── astro
    │                       └── World.java
    ├── out
    │   ├── classes
    │   │   ├── com.greetings
    │   │   │   ├── com
    │   │   │   │   └── greetings
    │   │   │   │       └── Main.class
    │   │   │   └── module-info.class
    │   │   └── org.astro
    │   │       ├── module-info.class
    │   │       └── org
    │   │           └── astro
    │   │               └── World.class
    │   └── lib
    │       ├── com.greetings.jar
    │       └── org.astro@1.0.jar
    

提交回复
热议问题