Advertisement

What is JAR format?

Started by June 17, 2002 11:21 PM
7 comments, last by jen6677 22 years, 6 months ago
Hello Im a beginner. I need to open Java source code. The source code is in JAR format. What is the benefit of Jar format? I have tried to open the file using Code warrior but I get an "Can not open unknow error"? I know there is nothing wrong with the JAR file. Can someone help me. Thank-you
A jar file is a convenient means for delivering multiple class files across the internet for use by an applet.

A jar file can be opened with winzip. However, it''s not likely that you will find any java source code inside of one. Most likely what you will find is a manifest file of the jar file contents and java class files (*.class) not java source (*.java).
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
Advertisement
Wasn''t the source code for the JDK distributed in a .jar at one time? Or am I just insane?

/*=========================================*/
/* Chem0sh */
/* Lead Software Engineer & Tech Support */
/* http://www.eFaces.biz */
/*=========================================*/
/*=========================================// Chem0sh// Lead Software Engineer & Tech Support// http://www.eFaces.biz=========================================*/
Sometimes people give the sources alongside the class files in the jar.

You can use the jar utility which comes with the JDK to extract files from a jar archive. It works a lot like the UNIX tar utility, so a command-line like the following should work:

jar -xvf jarfile.jar

This''ll extract the jar into the current directory.

codeka.com - Just click it.
quote: Original post by Chem0sh
Wasn''t the source code for the JDK distributed in a .jar at one time? Or am I just insane?


The oldest version of the JDK that I could find quickly was for 1.17B - and it was shipped as an exe (win32). I know I have 1.15 someplace, but I don''t feel much like digging around for it.

There''s nothing to stop a jar file from containing java source files - notice that I didn''t rule that possibility out. It''s just much more likely that an arbitrary jar file won''t contain source - just the manifest and the class files and maybe some gifs too.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
In your jdk directory, there is a file called src.jar. It has the java code for every java class. Just open it with winzip and go nuts. Its great for seeing how things are implemented.


University is a fountain of knowledge, and students go there to drink.
Advertisement
winrar also open .jar files
Just to clarify - a .jar file is a zip file - there are no special extensions in Winzip or Winrar to provide for .jar files.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
quote: Original post by Arild Fines
Just to clarify - a .jar file is a zip file - there are no special extensions in Winzip or Winrar to provide for .jar files.


Hey you''re right! I always assumed they were different formats, but you can use the jar tool to unzip .zip files as well

You learn something every day

codeka.com - Just click it.

This topic is closed to new replies.

Advertisement