Search code examples
javaclassloadermanifest

The 'ol Error: Could not find or load main class os x


I have a program with packages and dependent jars I'm trying to run. I've tried by executable jar but have fallen back to just using bash.

* Yes I have read the multitude of stackoverflow articles on this *

Most said examples refer to simple flat projects

project
 + libs/                     # all my external depends
 + src/main/java/com/blah    # files
 + target/classes            # where I create the class files.

Yes, this is a Jersey servlet. From the command line I run:

   export BIGGIE='./:./target/classes/com/blah/*:libs/activation-1.1.jar:libs/jackson-annotations-2.8.10.jar:libs/jackson-core-2.8.10.jar:libs/jackson-databind-2.8.10.jar:libs/jackson-module-jaxb-annotations-2.8.10.jar:libs/javax.annotation-api-1.2.jar:libs/javax.inject-2.5.0-b42.jar:libs/javax.ws.rs-api-2.1.jar:libs/jaxb-api-2.2.4.jar:libs/jersey-bundle-1.19.4.jar:libs/jersey-common-2.27.jar:libs/jersey-entity-filtering-2.27.jar:libs/jersey-media-json-jackson-2.27.jar:libs/jsr311-api-1.1.1.jar:libs/osgi-resource-locator-1.0.1.jar:libs/servlet-api-2.5.jar:libs/stax-api-1.0-2.jar'

    java -verbose -cp $BIGGIE com.blah.Main

    and receive the error Error: Could not find or load main class com.blah.Main.

And lots of library loaded messages NONE of which are my libs if that is significant.

I've tried using all variants of the Main class package name. I tried moving all the class files into the libs dir,etc.

This all runs fine when run from intellij, but I need a standalone version I can run from a Makefile. Don't ask why.

Mucho thanks.


Solution

  • The path to your folder stops at the folder containing "com". Change your BIGGIE declaration, the part that currently says ./target/classes/com/blah/* should just be ./target/classes/