The Mother Board forums. Free tech support, motherboard ID, and more.
It is currently Mon Sep 24, 2018 7:36 pm

All times are UTC - 8 hours

Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sun Dec 26, 2004 7:52 pm 

Joined: Wed Dec 31, 2003 10:22 pm
Posts: 26
I want to know how to make a jar file.
I am able to make one if there is only one java file, but i am having trouble makeing a jar file from 3 classed that are related to eachother.

The three java files names are ...

I also have a pic that goes with this thats called Hospital.png

How would i do this??

Reply with quote  
 Post subject:
PostPosted: Mon Dec 27, 2004 11:13 pm 
Green Belt
Green Belt

Joined: Thu Jun 27, 2002 8:11 pm
Posts: 222
Just done this at school :wink: Here are my notes:

Using JAR Files

See: JAR Basics: your_J2SE_folder/docs/tooldocs/windows/jar.html
See: JAR Tutorial:

A useful technique for organizing class files is to combine them into a single file called a JAR or Java Archive. A JAR file is simply a ZIP compatible file containing a collection of java files (typically, class files, but any other kind of file could be included as well). You can pack a component or a complete application in a single file. Additionally, you can make an GUI application run direct from the JAR file without the console window.

You can combine multiple files into a single JAR archive file with the jar tool.

1. Create a JAR file

In MS Windows environment you run the jar tool on the command prompt:
Start → Run... → cmd.exe

Use the CD command to change the active folder.
For more details, type help cd and press Enter.

The following command,

C:\myfolder> jar -cvf myJarFile.jar abc\*.class

would add to myJarFile.jar all class files within the C:\myfolder\abc folder (the corresponding package name in the JAR file would be abc).
Jar options: c = create a new archive file, v = display verbose output, f = specify the JAR file name.

The following command,

C:\myfolder> jar -cvf util.jar abc\*.class C:\util\*.class

would add to util.jar all class files within the abc and C:\util folder. The corresponding package names in the JAR file would be abc and util.

The following command,

C:\myfolder> jar -cvf utilities.jar folder_1 folder_2

would add to utilities.jar all files and subfolders within the folders folder_1 and folder_2

You could also use a single argument file named "classes.list" to hold the names of the files:
C:\myfolder> dir /b *.class > myclasses.list

Or, if you also want to include class files in the subdirectories:
C:\myfolder> dir /b /s *.class > myclasses.list

Then execute the jar command passing in the argument file:
C:\myfolder> jar -cvf myJarFile.jar @myclasses.list

2. Make CLASSPATH to point to the JAR file

A jar archive can be used as a class path entry.

CLASSPATH: .;%CLASSPATH%;C:\myfolder\myJarFile.jar;

See the JAR documentation for other details.

JAR files in a special folder under current JRE

The Sun JVMs have a special folder (%JAVA_HOME%\jre\lib\ext) for class library "extensions". All JAR files present in this directory are automatically available to all applications using that JRE. No CLASSPATH entry is needed for your JAR file, if you put the JAR file in the following directory: C:\j2sdk1.4.2_04\jre\lib\ext

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group