I have two main classes in the app. When I package it to a runnable jar (using Eclipse export function) I have to select a default main class.
Is there a way to access the non-default main class from the jar at runtime?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can access both via
java -cp myapp.jar com.example.Main1andjava -cp myapp.jar com.example.Main2. The default main class in the jar is for when you invoke your app viajava -jar myapp.jar.See JAR_(file_format) for more details. When you select the main class in Eclipse this is what gets set in:
Main-Class: myPrograms.MyClassinside of the jar manifestMETA-INF/MANIFEST.MFin side of the jar file.