javajarjava-package

How come my classpath isn't being used?


I have projects/plugin/target/mypackage.jar

Then I have projects/runner/Runner.java

When I run jar tf mypackage.jar, it doesn't have some classes it relies upon. Runner.java wants to import mypackage.MyClass

When I do javac -cp '.:../plugin/target/*' Runner.java from the runner folder, it complains that some dependencies of MyClass aren't available.

My runner folder contains the appropriate JAR files. If I copy-paste those JAR files into target folder, the compilation works. Considering I'm using . in my classpath, why wouldn't the package know where to find the correct JARs?


Solution

  • After some advice and shenanigans I found that this works:

    javac -cp './*:../plugin/target/*' Runner.java.

    The key difference being ./* rather than .

    If anyone can better explain why that is the case, I will gladly mark them as the answer.