Jump to content
  • Advertisement
Sign in to follow this  
Wutalife37

[java] Creating A JAR

This topic is 4719 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!