To package a java file into a jar package
Set the FrameDemo in the mypackage. package the java file into a jar package. Step 1: first package all classes in the program into a package and compile the mypackage package FrameDemo. java file. Save the class file to javac-d: \ Jar FrameDemo under the jar file on the d disk. java Step 2: Create a Main function in the same-level directory of the java package to introduce the text format as follows: (Note: ":" There is a space, you need to press Enter) Main-Class: mypackage. frameDemo Step 3: Package the class file in the following jar package format: jar-cvfm my. jar 1.txt mypackage code:
Package mypackage; import java. awt. *; import java. awt. event. *; public class FrameDemo {private Frame f; // constructor FrameDemo () {init () ;}// c initializes the form public void init () {f = new Frame ("My forms"); f. setBounds (300,200,700,500); myEvent (); f. setVisible (true);} // event function private void myEvent () {f. addWindowListener (new WindowAdapter () {public void windowClosing (invalid wevent e) {// System. out. println ("asdasd"); System. exit (0) ;}}) ;}public static void main (String [] args) {new FrameDemo ();}}