0
votes

I am trying to create executable jar out of a java project. the java project has the main method in a java file named MainTest.java. To create the executable jar, I did the following:

right click on the project->export->java->runnable jar->next button

Then I get a window with a list asking me to specify the launch configuration, the problem is , despit the java project has a main method in the file namedMainTest.java, this file is not listed in the list

how to solve the problem or how make the java file that contains the main method listed among the others in the list.

Note: the namedMainTest.java has the main method but it is empty "does nothing"

update

I am using Eclipse. and please have a look at the screen shot below. on the left , is the project with the java file that contains the main class "MainTest.java" and on the right, a list of classes and the "MainTest.java" is not among them instead there is another class names "TestMatrix.java" and i do not know why it is there

enter image description here

1

1 Answers

1
votes

I'm assuming you are using eclipse? Your desired main function appears if you ran your program before it. The dialog tells you to select a "run configuration". Since your main has not been run yet it does not appear. Another way to generate an executable jar is by going this way:
Export>Java>JAR file>
At this dialog select the resources to be exported (your project e.g.) and specify the name and destination of your jar file. After that continue (2x next) to the "JAR Manifest Specification" screen. The last option asks you to specify your Main class. Press finish after configuring your project and you are done.