I want to make work the project with two module inside one package. There is package com.test which include test1 and test2. This code is note compile because:
Error:Multiple module-info files in module 'Java9Test'
What is not correct?
test1 contains module-info.java
module com.test.test1 {}
and Client.java
package com.test.test1;
import com.test.test2.Provider;
public Client {
public static void main(String[] args) {
Provider provider = new Provider();
System.out.printf(provider.getString(), "TestA");
}
}
and package test2 which contains
module-info.java
module com.test.test2 {}
and Provider.java
package com.test.test2;
public class Provider {
public String getString(){
return "Hello, %s!";
}
}
Sorry but I very new in module with java9
The compiler (or the IDE) thinks that you have just one module. One module can only have one module descriptor (module-info.java
).
You could try the following directory structure:
module1/
module-info.java
com/
test/
test1/
Client.java
module2/
module-info.java
com/
test/
test2/
Provider.java
Each of the top-level module1
and module2
directories are module directories, so you would have 2 modules.
First module descriptor
module module1 {
requires module2;
}
Second module descriptor
module module2 {
exports com.test.test2;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With