Hi all,

I want to make an executable JAR file, and am facing some problems.

Here's what I have tried:

My program is in the following folder C:\extract\ExportTest.class

I created a Manifest (Manifest.mf) file in the same directory and the content of it is:

Main-Class: ExportTest

There's also a carriage return after that one line.

I created the jar file, using the following command

C:\extract>jar cmf Manifest.mf extract.jar *.*

Now I have the extract.jar file in my C:\extract\extract.jar

But when I open the jar file, if complains that it can't find the main class.... this is the error "Could not find the main class, Program will exit"

Am I doing something not correctly? please advise...


Looks mostly fine to me. Do you have any package statements in that class file?

No, I don't have package statements.

Are you running it from the command line with

java -jar extract.jar

Are you running it from the command line with

java -jar extract.jar

From command line it doens't work either

D:\>java -jar extract.jar
Exception in thread "main" java.lang.NoClassDefFoundError: ExportTest


I'm not seeing any problem with how you have built the jar, nor with the manifest. If you had a package statement in ExportTest.java, it would cause that kind of class path error, but beyond that it would come down to spelling errors, etc.

Nothing really stands out as a problem.

which IDE are you using? I recommend you download Blue J. its free and will let you JAR your file from within its interface without the need of command prompt. you just load up your classes into blue j and select "create JAR" or something similar (not using blue j right now) and you choose which main method (if you have more than one) you would like to execute primarily. Hope this helps