Directory Layout for Java 9 Modules

I am trying to write a Java 9 module, but no matter what I do, I get the error message "package is empty or does not exist." I tried searching the Internet for the expected catalog layout and tried every option in the catalog layout that I can think of, but nothing works.

For example, here is one layout I tried

bar.foo/module-info.java

module bar.foo {
    exports bar.foo;
}

bar.foo/bar/foo/wtf.java

package bar.foo;

public class wtf {
}

However, compilation still gives the same error as usual.

> javac bar.foo/module-info.java 
bar.foo/module-info.java:2: error: package is empty or does not exist: bar.foo
    exports bar.foo;
               ^
1 error
+4
source share
1 answer

Instead, the command should work:

javac bar.foo/module-info.java bar.foo/bar/foo/wtf.java

The reason is because you are trying to compile a class that requires an ie package bar.fooin your case. But since you did not create it, the compiler throws the indicated error.

, .class, . (bar.foo/bar/foo/wtf.java) wtf.class , , , module-info.class.

+3

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


All Articles