How to Make A Jar File In JAVA
Step 1: Consider a class
Step 2: Create a manifest file manifest.txt
Main-Class: AwtExample
Uses
Step 3: Create Jar File
Create a Jar file by adding “
Open cmd and type: You can issue following command to create a “
jar -cvfm AwtExample.jar manifest.txt com/*.class
Step 1: Consider a class
AwtExample.java
import java.awt.Frame;
import java.awt.Label;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class AwtExample {
public static void main(String[] args) {
Frame f = new Frame();
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
f.add(new Label("This JAR file is executable!"));
f.setSize(500, 500);
f.setVisible(true);
}
}
Step 2: Create a manifest file manifest.txt
c:\test\classes\manifest.txt
c:\test\classes\com\AwtExample.class
inside manifest file:Main-Class: AwtExample
Uses
Main-Class
as the entry point of this Jar file, when you double click on this Jar file, the “AwtExample.class
” main() method will be launched.Step 3: Create Jar File
Create a Jar file by adding “
AwtExample.class
” and “manifest.txt
” files together.jar -cvfm AwtExample.jar manifest.txt com/awt/*.class
Open cmd and type: You can issue following command to create a “
AwtExample.jar
.jar -cvfm AwtExample.jar manifest.txt com/*.class
0 comments:
Post a Comment