Creating jar file

Hi,

I'm trying to create a jar file. I have the tutorial in front of me, but something is messed up. I am typing:

jar cfm MyJar.jar Manifest.txt MyPackage/*.class (obviously with the appropriate package) into the command line.

However, it tells me 'jar' is not recognized as an internal or external command, operable program or batch file.

What does this mean? Do I not have JVM installed or something?

Thanks for any help,

Dan

[473 byte] By [Djaunla] at [2007-10-3 3:29:46]
# 1
the 'jar' executable isn't being found. if you can use 'javac', you should be able to use 'jar'... they're in the same folder.check if you have installed JRE instead of JDK...
lfschucka at 2007-7-14 21:23:39 > top of Java-index,Java Essentials,New To Java...
# 2

Hi,

Hmm, I may have JRE installed instead of JDK. I'll check tomorrow morning when I get to work.

Just wondering, is there a certain directory I need to run the 'jar' command from? I've been trying from my package directory...do I need to run it from the java directory or something?

Thanks,

Dan

Djaunla at 2007-7-14 21:23:39 > top of Java-index,Java Essentials,New To Java...
# 3
Wait no, I know I have JDK installed. Is there something else that could be causing the problem?
Djaunla at 2007-7-14 21:23:39 > top of Java-index,Java Essentials,New To Java...
# 4
does your "javac" command work?coz if it works "jar" command should too, their in the same directory as javac-Nywled
Redxxiva at 2007-7-14 21:23:39 > top of Java-index,Java Essentials,New To Java...
# 5

> does your "javac" command work?

> coz if it works "jar" command should too, their in

> the same directory as javac

>

>

> -

> Nywled

What directory would that be? What directory must I run the commands from? I've been using Eclipse to run my Java apps, not javac. I've tried exporting a jar file with Eclipse, but that hasn't worked for some reason.

Is there a certain directory I must run these commands from?

Djaunla at 2007-7-14 21:23:39 > top of Java-index,Java Essentials,New To Java...
# 6
You can run from any directory. Only make sure that your env PATH variable contains the <JDK Install dir>\bin where all the javac and jar executables would be present.Then you can run jar command from any folder you may be in.Hope this helpsThanksAviroop
aviroopa at 2007-7-14 21:23:39 > top of Java-index,Java Essentials,New To Java...
# 7
set your PATH environment variable with 'bin' folder of your JDKif you are using Linux, ask somebody else =P
lfschucka at 2007-7-14 21:23:39 > top of Java-index,Java Essentials,New To Java...
# 8
Ok, I just have one last question. How do I set the PATH environment variable? Where do I set it from and stuff?Thanks for the help,Dan
Djaunla at 2007-7-14 21:23:39 > top of Java-index,Java Essentials,New To Java...
# 9

Hi,

Never mind the PATH variable, I figured out how to do it.

However, when I create my jar file, it tells me it can't find the main class.

"Exception in thread "main" java.lang.NoClassDefFoundError: jena/GUI"

What does this mean? I can compile the java file into a .class file fine, and I can run it as a java application using Eclipse. What is it talking about?

EDIT: I opened my jar file with winzip, and it includes everything necessary, I think. It has the manifest file, and all my .class files from the jena package. Here is the command I used to create it:

c:\sun\appserver\jdk\bin\jar cfm MyJar.jar c:\kdb\jena\Manfiest.txt c:\kdb\jena/*.class

Message was edited by:

Djaunl

Djaunla at 2007-7-14 21:23:39 > top of Java-index,Java Essentials,New To Java...
# 10
Hi,Sorry to bump this, but I've searched around, and it seems the problem could be a classpath error. Is there any way to check this out?
Djaunla at 2007-7-14 21:23:39 > top of Java-index,Java Essentials,New To Java...
# 11
just a manifest file isn't enough... you need a manifest that specify your main class http://java.sun.com/j2se/1.3/docs/guide/jar/jar.htmlthis one should be more helpful: http://java.sun.com/docs/books/tutorial/deployment/jar/
lfschucka at 2007-7-14 21:23:39 > top of Java-index,Java Essentials,New To Java...
# 12
Hi,Thanks for the links. I have finally succesfully created a .jar file that runs. I am still having a problem, but that is more related to the classpath, so I'm going to create a new thread for that.Thanks for all the help,Dan
Djaunla at 2007-7-14 21:23:39 > top of Java-index,Java Essentials,New To Java...