To package a java file into a jar package

Source: Internet
Author: User

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 ();}}

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.