How do I create a jar file? How do I run the. Jar form of a Java program?

Source: Internet
Author: User

How do I create a jar file?

The. jar is a file format used to compress files or extract files, which is characterized by a lossless compression feature. Want to know how to create this program? Please visit http://www.cnblogs.com/yjmyzz/p/executable-jar.html

The. jar can be made executable by organizing the Java program's class file, and the compiler or Java Virtual machine can recognize these formats. The. jar file is executed by JAVAW (Java Application Manager). You need to set the application access point in the. jar file (that is, the file category that contains the program's main feature). You need to set the access point by using the manifest file (Manifest files). The steps are as follows:

1. The Java tool will automatically set the META-INF/MANIFEST.MF to the file path of the. jar. When creating a new manifest file, the name will be created as "manifest-version:1.0, created-by:1.6.0 (Sun Microsystems INC)"

2. Create manifest addition. txt file. Enter Main Class: [Package name].[ Class name], replace [package name], [class name] with your suite name and category name (that is, create a property value pair) and don't forget to add a blank line at the end.

3. Enter this terminal instruction program, adjust the manifest file to include the access point of the application, and change the brackets in the following code to the information of your program. jar CFM [jar file name] [additional manifest file name] [import file]

4. Re-look at the list file. After the access point is set, it will be "manifest-version:1.0,created-by:1.6.0 (Sun Microsystems INC), Main Class: [Suite name]. [Category name] "

5. You can also set the access point with the Jar tool. However, this overrides the main category attribute in the manifest file. Enter the following code (replace the brackets section) jar CFE [JAR file name] [suite name] [type name with main function]

Second, how to run the. Jar Form Java program?

The. jar may be a program or library, and if it is a library (without the executable file type), it is useless to try to run it.

The. jar needs to depend on other programs to run (like. exe). If you are not in your category path, you may not be able to run the program.

Contains Javaw.exe folder, there is a program called Javaws.exe, do not mix these two, the former is used to run Java program in Windows tool, the latter is Java Web s Tart (Java Application Management tool).

1, when the Linux runtime, log on to the remote server, enter the corresponding path, run. Jar (The primary method that the Java application runs): java-jar [Jar file name]. Once this command is printed, the process is turned off as soon as Crtl+c or exiting the terminal. Log Live print

  

  

When the command is changed to Java-jar [jar file name] &, the PID will be printed, again, once the command is started, the process will be turned off as soon as the terminal is closed.

  

  

2. When the Windows system is running,

Run the. jar file and run it with the following code. JAR (The primary method that the Java application runs): java-jar [jar file name]

(1) cmd

(2) Java-jar disk: \ filename \xxxx.jar

Makes it possible to double-click the Execute. Jar program (optional). To double-click to open the. jar file, you need to change the executable file path of the JAVAW (Java Application Manager), enter the following code: C:\Program files\java\j2rex.y.z\bin\javaw.exe "-jar"%1 "%*

How do I create a jar file? How do I run the. Jar form of a Java program?

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.