David B
David B

Reputation: 3581

Building Jar file using Eclipse Indigo

I have this project on Eclipse 3.7 (Indigo) and planning to build the *.jar. I am to build the project by File > Export > Java.Runnable JAR File > Named the filename of the jar file > Finish. An error always return to me when running the jar file.

Could not find the main class: [package nmame].[Class name of Main class (PSVM) is located].
Program will exit.

In addition, MySQL Connector 5.1 was included as Referenced Library for JDBC use.

How can I resolve and be able to build a jar file that is running as runned on Eclipse as Java Application?

Thanks in advance.

Upvotes: 2

Views: 1923

Answers (1)

aleroot
aleroot

Reputation: 72676

When you export the project try selecting the option :

Copy required libraries into a sub-folder next to the generated jar

Screenshot

This will create a lib folder containing the required dependency libraries ..

You have also to select a valid launch configuration for the program, to make sure that the MANIFEST file will be created with the MAin class attribute populated correctly .

When you run the generated jar you should run it with this command line (READ the MANIFEST.MF) :

java -jar yourjar.jar

or with Main class specified in the command line :

java yourjar.jar MainClass

Upvotes: 2

Related Questions