Reputation: 61
I made a Java application with netbeans and i made a jar file of it (with Build project button)
The .jar file is running on my pc.I tried to run it on other pc (i have installed java jre) and i have the error message "Could not find the main class. Program will exit"
my main class is called login.class I opened the manifest.mf of jar file and it look's ok
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.7.0_02-b13 (Oracle Corporation)
Class-Path: lib/mysql-connector-java-3.1.14-bin.jar lib/beansbinding-1
.2.1.jar lib/jcalendar-1.4.1.v201109071408.jar lib/jgoodies-common-1.
2.0.jar lib/jgoodies-looks-2.4.1.jar lib/junit-4.6.jar
X-COMMENT: Main-Class will be added automatically by build
Main-Class: login
Upvotes: 1
Views: 2746
Reputation: 114767
(1) Check, if the application starts if you call it from a console:
java -jar myjar.jar
If that works (and you tried it with starting the application from an explorer window before), then it is most likely a configuration problem with windows (or whatever OS you use)
(2) inspect your jar
file with any zip tool - it needs to contain a file login.class
in the jars root directory.
(3) If you added the last line to your manifest manually: make sure that the manifest file ends with an empty line, otherwise, the last line will not be parsed.
Upvotes: 2