Reputation: 2211
I have a big project that uses maven and I'm creating the project's jar. The problems is that the project has several classes that can be executed. How can I accomplish this?
Every time that I try to execute a class I get this message
java -jar library.jar ExecutableClass1 Failed to load Main-Class manifest attribute from library.jar
Upvotes: 2
Views: 463
Reputation: 57777
A possible alternative to using the -jar
switch is to explicitly start one of the "executables":
java -cp library.jar ExecutableClass1
If your jar has dependencies, then these will need adding to the classpath as well.
Upvotes: 3
Reputation: 52390
The manifest.mf file in your JAR can only have one Main-Class entry.
Main-Class: classname
The jar would then by executed by running below.
java -jar library.jar
If you have several "executables" that could be run then you can either pass command line parameters to the JAR and then run the correct code or you can generate multiple JAR files for each "executable".
Upvotes: 5