I'm trying to run the main() method of a class contained within a JAR file. Here's the error message I get:
Exception in thread "main" Could not find the main class: com.mycompany.package1.MyClass. Program will exit.
Here's what the manifest file looks like:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: some_user
Build-Jdk: 1.6.0_26
Package: com.mycompany.package1
Main-Class: com.mycompany.package1.MyClass
Class-Path: lib/JARfile1.jar lib/JARfile2.jar ...
Just to be clear, there are a number of JAR files contained within the 'Class-Path' value in the manifest file. And there is a blank line at the end of the manifest file. I mention this because I've seen that this has been an issue for others.
I've 'unjar-ed' the original JAR file, here is the directory structure:
- 'com' directory - this folder contains subfolders containing .class files, one of which has been specified as the 'Main-Class' within the manifest file
- 'lib' directory - this folder contains multiple required JAR files
- 'META-INF' directory - this folder contains the manifest file, as well as 2 subfolders
- 'org' directory - this folder contains subfolders containing .class files
- multiple XML files in support of the Spring framework
- several .properties files
When I run this command
java -jar -verbose myjarfile.jar > javaCmdOutput.txt
to get verbose messages re-directed to a text file, I see that the specified 'Main-Class' does get loaded, but one of the classes (from the 'com' package) it imports does not.
Any ideas as to what I can try next to resolve this problem?
Exception in thread "main" Could not find the main class: com.mycompany.package1.MyClass. Program will exit.
Here's what the manifest file looks like:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: some_user
Build-Jdk: 1.6.0_26
Package: com.mycompany.package1
Main-Class: com.mycompany.package1.MyClass
Class-Path: lib/JARfile1.jar lib/JARfile2.jar ...
Just to be clear, there are a number of JAR files contained within the 'Class-Path' value in the manifest file. And there is a blank line at the end of the manifest file. I mention this because I've seen that this has been an issue for others.
I've 'unjar-ed' the original JAR file, here is the directory structure:
- 'com' directory - this folder contains subfolders containing .class files, one of which has been specified as the 'Main-Class' within the manifest file
- 'lib' directory - this folder contains multiple required JAR files
- 'META-INF' directory - this folder contains the manifest file, as well as 2 subfolders
- 'org' directory - this folder contains subfolders containing .class files
- multiple XML files in support of the Spring framework
- several .properties files
When I run this command
java -jar -verbose myjarfile.jar > javaCmdOutput.txt
to get verbose messages re-directed to a text file, I see that the specified 'Main-Class' does get loaded, but one of the classes (from the 'com' package) it imports does not.
Any ideas as to what I can try next to resolve this problem?