Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] JAR

Started by OctDev Oct 5, 2001 at 4:10 AM 10 replies 700+ views
Original Post
OctDev
OctDev
Hi-- I''m trying to make a JAR archive. I have the JDK installed. ''java'' and ''javac'' commands work fine (from command shell). ''jar'' is not recognized. All the documentation leads me to believe that it should be included with the jdk. I''m wondering if someone can give me some advice before I download and reinstall the jdk...I''d rather not do that, as I don;t even know that it will fix the problem. jar isn''t stand alone is it? Thanx for any and all suggestions. --OctDev
The Tyr project is here.
soehrimnir
soehrimnir
No, jar is a standalone executable located at the same directory as where you can find the java.exe and javac.exe files. It''s very strange that you can use java and javac, but not jar. Is it really saying that the command ''jar'' was not found or does it give an other error. Maybe if you tell us exactly what you are doing, we can help further.
Supercytro
Supercytro
To create a JAR archive, use jar cf jar-file input-file(s).
It strange that the command is not recognised since java/javac commands are recognised which seems to suggest all path references are correct.

The JAR file-format has been around since JDK 1.1 so I''m surprised it isn''t there.

Check in the bin directory where your JDK is stored and see if JAR.exe exists.

-- Supercytro
OctDev
OctDev
Well...I am following an online tutorial exactly, that after researching properly follows sun''s doc''s on jar...

But to try and diagnose the error I did the following (on a windows machine):

Confirm java and javac are working properly in my current directory:

D:\...\...\...\java

It spouts out a bunch of usage information...good, I know how to use it, just wanted to make sure it was recognizing the command.

D:\...\...\...\javac

Similar usage info...great.

D:\...\...\...\jar

Big old error...ok let me go see what it says exactly...

''jar'' is not recognized as an internal or external command, operable program or batch file. So as I said, and as you reiterated, jar is not being found. How that is possible, I fail to see. But I will search around for answers tomorrow.

--OctDev
The Tyr project is here.
OctDev
OctDev
AHHH!!!

After looking, I find that jar.exe is in my bin dir, which makes things even stranger....

I want to throw my computer through the window; I don''t have the patience for this silly error right now...

Thanx for trying to help though guys....

--OctDev
The Tyr project is here.
OctDev
OctDev
Ok, so I can run the command from the /jdk/bin dir...the lame hack is to move the jar.exe to my dir with all my class files and stuff...but anyone know how to make it a globally recognized command? THX!!!!!


--OctDev
The Tyr project is here.
Supercytro
Supercytro
After reading what you''ve just written, it seems to be that you''ve copied the java executables to your class/source files directory.
If so, I definitely don''t recommend doing that. Leave everything where they are i.e. \bin of your JDK directory and setup the PATH and CLASSPATH appropriately.

It is best explained on http://developer.java.sun.com/developer/onlineTraining/Programming/BasicJava1/windows.html

Hope that helps.
-- Supercytro
Supercytro
Supercytro
This might also be useful:
http://java.sun.com/j2se/1.3/install-windows.html#Environment
-- Supercytro
OctDev
OctDev
Well, I have left everything where it is, in the jdk\bin\ dir. I know this sounds like some idiot newbie error, but the reason I post it here is that I use java frequently, including different modules for it (java3D, some misc media packages), and do not have problems of this nature, and this should not be an error. Traditionally, my big assignments are executed in a Unix environment; however, after completing some personal projects, I want to create some self-executing .jar''s to make it easy for ANYONE to run the program. I can compile and run things fine through my editor or through command line, but that is besides the point. And I mentioned that I could move the jar.exe simply as a one time hack; I have not done so yet nor have I done so with any other pieces of the jdk. I will look at my classpath vars, and research for the solution more thoroughly at sun; I only posted to see if someone had some similar experience, because as I said--based on the documentation, and based on the fact that java and javac and multiple extra packages/API''s are working, this should not be an error. Anyway, thanx for the help, I''ll let you know if I ever find out if it was my error or what....but I think I am going to have to go through the hassle of removing and reinstalling everything.
The Tyr project is here.
wrenhal
wrenhal
quote:
Original post by OctDev
Well, I have left everything where it is, in the jdk\bin\ dir. I know this sounds like some idiot newbie error, but the reason I post it here is that I use java frequently, including different modules for it (java3D, some misc media packages), and do not have problems of this nature, and this should not be an error. Traditionally, my big assignments are executed in a Unix environment; however, after completing some personal projects, I want to create some self-executing .jar''s to make it easy for ANYONE to run the program. I can compile and run things fine through my editor or through command line, but that is besides the point. And I mentioned that I could move the jar.exe simply as a one time hack; I have not done so yet nor have I done so with any other pieces of the jdk. I will look at my classpath vars, and research for the solution more thoroughly at sun; I only posted to see if someone had some similar experience, because as I said--based on the documentation, and based on the fact that java and javac and multiple extra packages/API''s are working, this should not be an error. Anyway, thanx for the help, I''ll let you know if I ever find out if it was my error or what....but I think I am going to have to go through the hassle of removing and reinstalling everything.



I''m still learning Java and had an instance where trying to RUN a jar was giving me errors about a setting in registry being set to 1.3, but needed to be 1.2?? I looked around and checked my paths and classpaths and finally I figured it out. a copy of java.exe was under my windows folder and was of an older version. My IDE''s had the direct path to the jdk\bin folder and the JRE of course was using the JRE path under Program Files, so I had never had need to check for other versions of java.exe on my system. I actually found 2 copies of that and one of javac.exe that didn''t belong. So when I renamed those rogue exe''s the system defaulted to my jdk\bin which was in the path variable.
It''s possible that your PATH= is not correct and you''ve never known it because of some rogue copies of java.exe and javac.exe.

I hope this helps.

BeS
It''s Da BOMB Baby!!!
. o O ~
A little nonsense now and then,
is relished by the wisest men
~ O o .
-- Willy Wonka
Kaijin
Kaijin
It sounds like you may have not have added the Java tools to your PATH. Add the following line to your autoexec.bat:

PATH=%PATH%;"C:\JDK1.3\BIN"

NOTE: Your JDK path may be different to mine

- Kaijin

"If you find a job that you love you''ll never have to work again."
brettporter
brettporter
that last one won''t work on some Windows systems due to the fact there is a java.exe in c:\windows\system that runs the JRE version and then there can be more problems. Either delete the winnt\system32 or windows\system java.exe, or but c:\jdk1.3\bin at the front of the path.

To create a runnable JAR file, you need a manifest.mf in META-INF/ under the JAR file, with an option to set the class to run as main. You''ll find more info on the sun site.


Hope this helps!

~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
Community Service Announcement: Read How to ask questions the smart way before posting!
~~~Cheers!Brett PorterPortaLib3D : A portable 3D game/demo libary for OpenGLCommunity Service Announcement: Read How to ask questions the smart way before posting!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.