I have a jar file having 2 java classes both having Main methods. Is there a way I can specify while running the jar file, which class to call ? I know that manifest file can be modified to specify the Main class but since only one class can be mentioned, that does not help. I checked the below links, but those dint solve the problem:
https://stackoverflow.com/questions/5474666/how-to-run-a-class-from-jar-which-is-not-the-main-class-in-its-manifest-file
manifest-file execute a main class from a jar
It gives NoClassDefFoundError.
java -cp target/your_file.jar your.package.name.YourClass
Have a class that acts as a controller. In its main(), invoke other classes based on arguments passed. Add this as the Main-class in manifest
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With