How to generate one jar with different executable classes in maven2?
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.开发者_C百科jar ExecutableClass1 Failed to load Main-Class manifest attribute from library.jar
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".
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.
精彩评论