How do I make a jar package run directly by double-clicking?
Test: Mymenu.java class Name: MyMenu
After writing the Java code, we find that the physical path is:
When I hold down the SHIFT key and travel here, open a command-line window:
Execute command:javac Mymenu.java
Build Result:
A bunch of. class files were generated:
Optimization method:
First, add the code to the Mymenu.java: package Mymenubao;
Second, add the custom class MyMenu to the public property
Package Mymenubao; import java.awt.*; import java.awt.event.*; import java.io.*; Public class mymenu{ // constructor MyMenu () { init (); } ... Public Static void Main (string[] args) { new MyMenu ();} }
Third, with package compilation
Javac-d the location of the package storage Xxx.java
Four, switch to the C drive:C:
Go to root directory:cd\
Build jar Package: JAR-CVF The name of the source package that generated the jar package
My.jar Decompression Open discovery, so many classes, you must indicate the main function class name
V, configure the Ingress information for the jar package
Build 1.txt (1.ini all Can), write:
Main-class: Package name. class Name
Main-class:mymenubao.mymenu
Main-class: (There must be a space, the primary key value is separated) Mymenubao.mymenu (there must be a carriage return, the next line)
Note: I have been here to make a mistake, suddenly found that because the direct establishment of the 1.txt, and their own computer is the default hidden txt extension properties, so, the file name is actually 1.txt.txt, so the error
This opens the profile discovery:
There are already ingress attributes (package name, class name) Note None. java
The third part, how to make your computer can double-click Run Jar Package:
Win7 flagship 64-bit operating system how to find "File type"? Many users from the XP operating system update to the Win7 flagship 64-bit operating system, found that there are a lot of different locations, like "file type", in the XP operating system we can directly in the folder options inside the file type is set, but in Win7 flagship 64-bit operating system inside is unable to find the "file type", for such a question to do? The following is the specific operation steps: 1, first we have to double-click on the win7 operating system computer icon to open the Control Panel, 2, and then to the "view type" to the small icon, to find the "default program" option; 3, followed by everyone click and then click " The file type or protocol and program associated ", this side of the" file type "of the entrance, 4, and finally after the opening to see the file format list, and then to find the file you want to fix the format of the re-association. Since the image jar package is Javaw.exe open, set the jar open mode: Set the success, double-click to open the Run effect: Bi Xiangdong TeacherThe final emphasis:1.txt Hollow Lattice and return must not be lessMain-class: (There must be a space, the primary key value is separated) Mymenubao.mymenu (there must be a carriage return, the next line)
Java double-click Jar Package operation