File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes JAR file problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JAR file problem" Watch "JAR file problem" New topic

JAR file problem

Vijay Chandran
Ranch Hand

Joined: Jan 07, 2007
Posts: 178
Dear friends,

I am creating a JAR file which contains the necessary class files and the MANIFEST file. All classpaths and environemnt variables are set perfectly.

But still when i execute the jar file, i am getting the traditional error "MAIN CLASS not found. Program will exit"

Kindly provide your help.

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074

What does your JAR file contain exactly (you can get a list with jar tvf myjarfile.jar)?
What does the manifest file contain exactly?
Does the manifest file end with an empty line?

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Vijay Chandran
Ranch Hand

Joined: Jan 07, 2007
Posts: 178
Dear Jesper,

The Manifest file ends with a new line. The JAR file contains some Swing components and other core java classes.

Another problem is, the jar files run in one computer but not in another computer. In one computer, its executing by simply double clicking the jar.

In another computer, its not working when i double click it, right click open with javaw. But it works with right click open with Java(TM) Platform Standard Edition Binary.

Using JDK 5.0!!
Thanks & Regards,
Rob Spoor

Joined: Oct 27, 2005
Posts: 19654

What happens when you type in the following command in a console:

This should show you a stack trace that should be much clearer than just "MAIN CLASS not found. Program will exit". That error is also wrong most of the times; the main class can be found perfectly but some other class cannot.

How To Ask Questions How To Answer Questions
Vijay Chandran
Ranch Hand

Joined: Jan 07, 2007
Posts: 178
Dear Rob,

When i executed that commmand java -jar <jar-file>, the jar EXECUTED perfectly!! which will display a GUI developed in Swing.

Its not working when i double click it or right click open with javaw.

It is sorta covered in the JavaRanch Style Guide.
subject: JAR file problem
Similar Threads
i am facing problem in creating jar file
java.sql.SQLException: No suitable driver
How to find the jar file which contains a certain class.
Class HibernateUtil cannot be resolved
Classpath and Jar file