import java.awt.*;
import java.awt.event.*;
public class MyClass {
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("Hello world"));
f.setSize(200,200);
f.setVisible(true);
}
}
cmd: Path:> javac MyClass.java
Create manifest.mft using notepad
Manifest-Version: 1.0
Main-Class: MyClass
Class-path: .
Main-Class specifies the entry point with the main(String args[]) method.
The Class-path is used to specify the dependency of this jar (if any). You add the directories and jars separated by a space. It is important because when running a jar , the CLASSPATH definition (as defined by the environnement variable) is overridden.
cmd: Path:>jar cvfm myjar.jar manifest.mft *.class
cmd: Path:>java -jar myjar.jar
myjar.jar will be created, double-click to run.
2 comments:
thank a lot
very short and precise
very nice example
very good
Post a Comment