This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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: 186

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: 14956

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 8 API documentation
Vijay Chandran
Ranch Hand

Joined: Jan 07, 2007
Posts: 186

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: 20079

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: 186

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.

I agree. Here's the link:
subject: JAR file problem
It's not a secret anymore!