I've gotten this to work in the past, but now whenever I choose File > Export... > Runnable JAR File
and select the drop-down menu "Launch Configuration"
, all I get is a blank bar.
How can I get my main class to show up?
To export your project, right-click it and select Export. Select Java > Runnable JAR file as the export destination and click Next. On the next page, specify the name and path of the JAR file to create and select the Launch configuration that includes the project name and the name of the test class.
A launch configuration is a description of how to launch a program. The program itself may be a Java program, another Eclipse instance in the form of a runtime workbench, a C program, or something else. Launch configurations are manifested in the Eclipse UI through Run > Run....
FYI: In simple terms, the difference between a JAR file and a Runnable JAR is that while a JAR file is a Java application which requires a command line to run, a runnable JAR file can be directly executed by double clicking it.
In Eclipse, select File → Export, then Java → Runnable JAR File. Launch Configuration identifies which program should be exported. Find the one that runs the class containing your main() method. Export Destination is the name and location of the JAR file you want to generate.
Launch configurations are presumably used because they describe the main class you want to run, and the libraries the main class needs. They are created automatically when you run your main class inside Eclipse.
In the Package Explorer panel, right-click on the class you want to have main(...) executed in and choose Run as -> Java Application
to run your program.
This process creates a launch configuration you can use (and save too, if you make it shared)
I came across this same issue today as I have many times in the past, and although I've usually corrected it as Thorbjorn has posted, for some reason it was not working for me today.
Typically I would just browse to the project, search for the main class, and hit apply then run, but it wasn't working. Still wouldn't show main class while trying to export runnable jar.
I actually had to go run configurations, and right click on the window to the left under Java Application and click 'new'. It then created a new configuration item where I could browse to the project, and add the main class. Then it would show up while trying to export runnable jar.
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