Nowadays, windows will be equipped with j2se parser, so this means that if it is packaged into a jar file, it can be opened with this j2se parser and can be double-clicked to run. **********************The following is the packaging method of the jar package************************ ***1. Create MANIFEST.MF (in the root directory of the class file) The following content is the basic content of the file ================== Manifest-Version: 1.0 Main-Class : a (path to the main class) Created-By: Abc Company (name of the creator) ================== 2. Package in the class file directory according to the conditions given by lz Execute jar cvfm classes.jar MANIFEST.MF *.* The above command will package all the files under the class into classes.jar and generate it in the class directory. 3. Double-click to execute under Windows. ----------------------------------This is the solution I recommend because it is simple. ****************************MANIFEST.MF file details********************** *******When opening a Java JAR file, we can often see that the file contains a META-INF directory. There will be some files in this directory, among which there must be a MANIFEST.MF. This file describes the Jar file. A lot of information, the contents of the MANIFEST.MF file will be introduced in detail below. Let’s first look at the contents of the MANIFEST.MF file contained in struts.jar: Manifest-Version: 1.0Created-By: Apache Ant 1.5.1Extension-Name: Struts FrameworkSpecification- Title: Struts FrameworkSpecification-Vendor: Apache Software FoundationSpecification-Version: 1.1Implementation-Title: Struts FrameworkImplementation-Vendor: Apache Software FoundationImplementation-Vendor-Id: org.apacheImplementation-Version: 1.1Class-Path: commons-beanutils.jar commons-collections .jar commons-digester.jar commons-logging.jar commons-validator.jar jakarta-oro.jar struts-legacy.jar If we classify the configuration information in MANIFEST, we can summarize it into the following categories: 1. General Attribute 1. Manifest-Version is used to define the version of the manifest file, for example: Manifest-Version: 1.02. Created-By declares the generator of the file. Generally, this attribute is generated by the jar command line tool, for example: Created-By: Apache Ant 1.5.13. Signature-Version defines the signature version of the jar file 4. Class-Path The application or class loader uses this value to build the internal class search path 2. Application related properties 1. Main-Class defines the jar file The entry class must be an executable class. Once this attribute is defined, the jar file can be run through java -jar x.jar.
3. Applet related attributes 1. Extension-List This attribute specifies the list of extension information required by the applet. Each name in the list corresponds to the following attributes 2.
b) Create a new exe4j project c) Select "JAR in exe" mode d) Configuration in Configure application: i. Short name: Write whatever you want. ii. Ourput Directory: Select the output path. e) Configuration in Configure Executable: i. Executable type: There are three options, graphics, console. or service. Let’s start simple. Here we choose console ii. Executable name: Fill in the name of the destination output source. Such as test.exe iii. Icon file: exe icon file, but it must be an .ico file f) Configuration in Configure Java invocation: i. Classpath: Select the jar package we generated and the class library required to run the jar file ii. Main-Class: Select the main class we need to run. iii.Arguments (optional): input parameters. We don't need it here yet. g) Configuration in Configure JRE: i. Minimum Version: Write the minimum JVM version required to run the program, such as 1.4 h) Keep next, and default the options for the steps encountered until finish: OK. After the compilation is successful, there will be a brand new exe program in your output directory. Just enjoy it. 3 Summary and Comparison There are many tools for generating exe from Java. The above two are the two that I personally find more convenient to use. The principles of the two are basically the same, but the specific use is still a little different: 1. Similarities a) The biggest similarity is of course that their principles are interoperable. All are done by packaging executable java programs into executable jar packages. Convert again. b) The generated exe executable program needs to be run in a JVM environment with a higher version than the minimum version. 2. Differences a) When generating an exe, if you want the exe to run, you only need a pure JVM environment (no third-party class library is required). In JSmooth, you need to compress all the third-party libraries used into a jar package (because it has an embedded jar option), which is more troublesome, because when more than one jar is needed, these jar packages need to be First use jar –xvf to decompress, then use jar –cvf to create a new jar file, and then put it in the embedded jar option; exe4J will also compile the jar package used in the classppath into the exe. b) JSmooth is free; exe4J is a free software and requires registration, otherwise a very annoying prompt box will pop up when executing the exe. c) Selection of ico files: exe4J requires strict ico files, while JSmooth is compatible with jpg and other types of pictures.
The above is a transfer