| View previous topic :: View next topic |
| Author |
Message |
adroga Initiate

Joined: 31 Dec 2003 Posts: 26
|
Posted: Sun Dec 26, 2004 7:52 pm Post subject: How to make jar files ??? |
|
|
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 ...
Hospital.java
ConnectII.java
PatientInfo.java
I also have a pic that goes with this thats called Hospital.png
How would i do this??
thanks |
|
| Back to top |
|
 |
olly Green Belt

Joined: 27 Jun 2002 Posts: 217
|
Posted: Mon Dec 27, 2004 11:13 pm Post subject: |
|
|
Just done this at school Here are my notes:
| Quote: | Using JAR Files
See: JAR Basics: your_J2SE_folder/docs/tooldocs/windows/jar.html
See: JAR Tutorial: http://java.sun.com/docs/books/tutorial/jar/
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 |
|
|
| Back to top |
|
 |
|
|
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 vote in polls in this forum
|
|
|