The Jar tool?

S

snape

How do I get the JAR tool? I installed the latest JDK, but to no
avail. I need to package my application, but I need that executable!
I can't find it anywhere. Thanks for any and all help.
 
A

Antti S. Brax

How do I get the JAR tool? I installed the latest JDK, but to no
avail. I need to package my application, but I need that executable!
I can't find it anywhere. Thanks for any and all help.

The "jar" program is in $JAVA_HOME/bin.
 
J

Joan

Antti S. Brax said:
The "jar" program is in $JAVA_HOME/bin.
That is UNIX notation, for windows the env. var is not
automatically
set during installation. On my laptop the jar.exe is in:

C:\Program Files\Java\jdk1.5.0_03\bin
 
J

jan V

How do I get the JAR tool? I installed the latest JDK, but to no
avail. I need to package my application, but I need that executable!
I can't find it anywhere. Thanks for any and all help.

Note that JAR files are just ZIP files with the .zip extension renamed to
..jar. A JAR file also needs to contain a MANIFEST.MF file... you can do this
with any ZIP-compatible tool.
 
A

Andrew Thompson

Note that JAR files are just ZIP files with the .zip extension renamed to
.jar. A JAR file also needs to contain a MANIFEST.MF file...

No it doesn't. The manifest adds some useful things,
but a jar file does not need it, and sometimes it makes
little/no sense to add one.
 
T

Thomas Weidenfeller

jan said:
Note that JAR files are just ZIP files with the .zip extension renamed to
.jar.

AFAIR jars support less compression schema than zip.
A JAR file also needs to contain a MANIFEST.MF file

Some do, some don't. It really depends on what you put in the jar, if
you want to sign it, etc.

There is also the option to place an index file in a jar. This is highly
recommended, since it speeds up the lookup of the jar contents.

/Thomas
 
J

jan V

Note that JAR files are just ZIP files with the .zip extension renamed
to
No it doesn't. The manifest adds some useful things,
but a jar file does not need it, and sometimes it makes
little/no sense to add one.

Can you give some examples of when the manifest.mf entry is not needed?
 
A

Antti S. Brax

Can you give some examples of when the manifest.mf entry is not needed?

When the bytecode in the JAR file or the user of the JAR file
do not need any of the information in the manifest file then
the manifest file is useless. Good enough? :)

I have the following manifest file. The information is pretty
much useless and the program will work just fine without it.

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.4.2_07-b05 (Sun Microsystems Inc.)
 
S

snape

Sorry, that file doesn't exist on my computer. I went to that folder,
and there is no jar.exe. No jar.* for that matter.
 
S

snape

I tried this. I put my class files and a MANIFEST.MF file into a zip
and renamed it .jar. I got an error: Invalid or Corrupt jarfile.
 
A

Andrew Thompson

I tried this. I put my class files and a MANIFEST.MF file into a zip
and renamed it .jar. I got an error: Invalid or Corrupt jarfile.

jan may well have been suggesting *looking* at a jar file
by renaming it to .zip.

Going the other way is possivble, but there are pitfalls.

As Thomas mentioned, there are some zip 'schema' unsupported
by jars, and the manifest file must be the first file in the
archive (as I understand it).

I recommend that when *making* jar files, use the jar tool.

...Once you find it.

BTW - are you positve that you downloaded the JDK/SDK,
rather than the JRE? Your posts are thus far lacking
detail. What is the *exact* name and size of the
downloadable you have?
 
J

jan V

I tried this. I put my class files and a MANIFEST.MF file into a zip
and renamed it .jar. I got an error: Invalid or Corrupt jarfile.

You know, there is such a thing as the Jar File Specification (on Sun's
website). Just Google for it, it's not such a huge document either (though
it's grown since I last looked at it - didn't know about the index feature).

The spec tells you all about what should and can be in a JAR file, and how
you can create JAR files (e.g. using the java.util.jar APIs.)
 
I

IchBin

Sorry, that file doesn't exist on my computer. I went to that folder,
and there is no jar.exe. No jar.* for that matter.
Yes, as Andrew suggest, it sounds like you downloaded the JRE and not
the JDK. You will find it in 'JDK Home\bin\jar.exe'.

--


Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.servebeer.com
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
T

Thomas Fritsch

Sorry, that file doesn't exist on my computer. I went to that folder,
and there is no jar.exe. No jar.* for that matter.
For you to compare with:

After installing Java 5.0, I found two new product entries in my "Control
Panel - Software":
"J2SE Runtime Environment 5.0"
"J2SE Development Kit 5.0"
As others already have pointed out, you probably have installed only the
first, but not the second.

The set-up has created two different directories trees, one for each
product:
"C:\Programme\Java\jre1.5.0"
"C:\Programme\Java\jdk1.5.0"
The jar-tool is "C:\Programme\Java\jdk1.5.0\bin\jar.exe".

HTH
 
A

Andrew Thompson

I downloaded and installed the SDK, j2sdk-1_4_2_08-windows-i586-p.exe.

...hmm. Last time I checked, 1.4.2 was up to _06, but
_08 does not surprise me, and yes, that does sound like the
correct donwload for 1.4 development.

Try this.. (I'm starting to swim here)
- Double click (open) 'My Computer'
- Right-click on your system drive (C: most probably) and
- 'Search' the drive for '1.4.2'.

...that search *should* locate the 'Java\j2re1.4.2_..'
folder/directory.

If that shows up nothing, it might be a sign of a failed
installation (shudder).
 
S

Steve Sobol

Andrew said:
Try this.. (I'm starting to swim here)
- Double click (open) 'My Computer'
- Right-click on your system drive (C: most probably) and
- 'Search' the drive for '1.4.2'.

..that search *should* locate the 'Java\j2re1.4.2_..'
folder/directory.

Make sure to check under c:\program files. That's where my 1.5 JDK and JRE
are, but I make sure to install everything under Program Files for sanity's
sake, and I'm not sure whether that's the default or not.
 
T

Thomas Weidenfeller

I tried this. I put my class files and a MANIFEST.MF file into a zip
and renamed it .jar. I got an error: Invalid or Corrupt jarfile.

The manifest has to be the first file in the zip/jar. Physically, not
what WinZip displays after some sorting.

/Thomas
 
C

Chris B.

I found the directory, but no jar.exe in \bin, so I installed again,
and this time I got it. Thanks so much for all your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,085
Members
48,773
Latest member
Kaybee

Latest Threads

Top