Hi all

when I run commend :

"C:\LJava\project\KTest2>java -cp .;org.freixas.jcalendar;.\build components.KTest2"
my code runs well

I then made a jar file with the command
"C:\LJava\project\KTest2>jar -cf KTest2.jar .\build\components\*.class"

my MANIFEST.MF 's content is :

Manifest-Version: 1.0
Created-By: 1.7.0 (Oracle Corporation)
Main-Class: components.KTest2

but when I run command

"C:\LJava\project\KTest2>java -jar KTest2.jar"
I got the message
"Error: Could not find or load main class components.KTest2"

will anybody here teach me what i have done wrong ?

thank you
denny

As always, check your spelling.
Look in the jar file with a zip file utility and check its contents.

You jar command doesn't appear to use the manifest file

Hi NormRI
yes firstly I let jar command to create default manifest.
But then I open and added the third lines using winrar

thank you
denny

Have you checked the JAR file to ensure the manifest really is there? Make sure you are invoking a JAR command which "packages" the manifest file in the JAR. Ensure there is a newline after the last manifest attribute. Read this. Follow up if it still doesn't work.

Hi -s.o.s-

yes it is there as I copy from the dos screen below

C:\LJava\project\KTest2>jar -tf KTest2.jar
META-INF/
META-INF/MANIFEST.MF
build/components/FileRead.class
build/components/KTest2$1.class
build/components/KTest2.class

thank
denny

hi -s.o.s-

And also the manifest.mf file end at new line
to make sure all lines executed right

thank
denny

The "build" folder shouldn't be part of your JAR file. Also, make sure that the KTest2 class has a main (entry point) method.

Please also note, that there should be either 1 0r two blank lines after the main class. i always use 2 just in case

hi all

# The "build" folder shouldn't be part of your JAR file. Also, make sure that the #

this is the problem
after moving the jar file to the same directory with the class
it works fines

thank you all

denny

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.