0

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?

Dave Stein
  • 8,653
  • 13
  • 56
  • 104

1 Answers1

0

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.

Dave Stein
  • 8,653
  • 13
  • 56
  • 104
  • Can't answer due to hold but [a _directory_ in the classpath is only used to find class files](http://docs.oracle.com/javase/8/docs/technotes/tools/unix/classpath.html#A1100592) while a jarfile name _or_ [a wildcard (NOT in manifest) is used to find jarfiles](http://docs.oracle.com/javase/8/docs/technotes/tools/unix/classpath.html#A1100762). Thus `.` finds classes but `./*` or `../plugin/target/*` finds jars, and your Q only mentioned wanting to find jars – dave_thompson_085 Aug 26 '17 at 00:05