tags:

views:

29

answers:

2

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

+3  A: 

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".

Taylor Leese
+2  A: 

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.

mdma