[java] Creating A JAR

Started by
3 comments, last by role 18 years, 10 months ago
Hello Everyone. I'm trying to create a JAR file but I've run into a very annoying problem. In MS-DOS, I go to the directory containing the files I want to put in the JAR and do "jar cmf jarName.jar *" without the quotes. I then get this error - "'jar' is not recognized as an internal or external command, operable program or batch file." I've read that I need to add ";C:\Program Files\Java\jdk1.5.0_01\bin" under path and Path in my environment variables, but this has not helped. I'd really appreciate any help someone could give.
Advertisement
Quote:Original post by Wutalife37
Hello Everyone. I'm trying to create a JAR file but I've run into a very annoying problem. In MS-DOS, I go to the directory containing the files I want to put in the JAR and do "jar cmf jarName.jar *" without the quotes. I then get this error - "'jar' is not recognized as an internal or external command, operable program or batch file." I've read that I need to add ";C:\Program Files\Java\jdk1.5.0_01\bin" under path and Path in my environment variables, but this has not helped. I'd really appreciate any help someone could give.


Check to see if your JDK is actually installed in that directory ? there should be a bin directory under your main JDK install. Add this bin directory to your path and you should be fine.

D.

BlueJ lets you see a graphical representation of the files and you just choose the files you need and then select make jar file option and it does everything for you. No need to mess with the command line unless you have to.
It turns out that wasn't the directory, thanks! I made the change and I was able to create the JAR file, but now I have another problem. I'm trying to make a JAR file that will run a Java program when it is opened, and I read that I need a manifest text file to specify which class it should open. BattleMapEdit.class is the file containing my main method, and it is packaged in myprojects.battlemapedit. I tried making a manifest file saying "Main-Class: myprojects.battlemapedit.BattleMapEdit" and then doing "jar cmf manifest.txt MyJar.jar *" in the directory, but afterwards when I do "java -jar MyJar.jar" I get an error saying "Exception in thread "main" java.lang.NoClassDefFoundError: myprojects/battlemapedit/BattleMapEdit". Any ideas? I think I'm close enough to finishing with JAR files that I don't need BlueJ, but if it would still be easier for me at this point then I could.
Hello, in case you interest, I made a simple Jar Maker utility.
You can get it at:
http://goldenstudios.or.id/products/utilities/jarmaker/JarMaker.zip

Tell me what you think.
-------------Golden T Game Engine - Java Game EngineGolden T Website | Golden T Forum

This topic is closed to new replies.

Advertisement