Reputation: 67
This should be straight forward yet I do not see why the commons-logging-1.2.jar is not being located after an apparently successful compile. But I am not sure why the commons-logging-1.2.jar library not being found by java when it is run this way.
$ javac -classpath commons-logging-1.2:pdfbox-2.0.24.jar:xmpbox-2.0.24.jar org/example/app/App.java
$ jar cfm app.jar MANIFEST.MF ./org/example/app/App.class
$ java -cp ./* -jar app.jar
Error: Could not find or load main class ..commons-logging-1.2.jar
Caused by: java.lang.ClassNotFoundException: //commons-logging-1/2/jar
I also tried running as:
$ java -cp ./* org.example.app.App
Error: Could not find or load main class ..commons-logging-1.2.jar
Caused by: java.lang.ClassNotFoundException: //commons-logging-1/2/jar
I intend to ultimately use Maven, but for now I just want to be able to understand the process manually. I was able to get this to compile and run on Windows using the same setup (folders/tools/etc). Not sure what I am missing here.
All java commands are run from the dir where org/example/app is located. And the jar files are located in the same directory. So I have all jars (including the app.jar when it was created) in dir A and under dir A is where org/example/app/App.class is created.
I purposely did an incremental build where first, pdfbox was only included and receive the appropriate error that xmpbox classes were missing. Then I added xmpbox. Yet when I did not add commons-logging-1.2.jar in the class path, there were no errors reported.
Any help is very much appreciated. Thanks!
Upvotes: 1
Views: 423
Reputation: 67
The following, commented on by user chrylis -cautiouslyoptimistic solved the problem.
"Try putting an echo in front of that command and see what it expands to."
After trying that suggestion it showed that the expansion was causing the problem. Under Windows I did not use expansion but under linux, when looking at the expansion it showed that there were spaces between the filenames instead of ":" as required by the -cp syntax.
Upvotes: 1