A method of packaging Java programs into jar packages and executing them

This paper introduces the method of packaging Java programs into jar packages and executing them, which is shared with you as follows:

1. First of all, confirm whether the program you write has reported an error.

2. I wrote web project for the first time. Up to now, I have not successfully executed it, so the best thing to create is java project

Packaging steps:

1. Right click the project and select export.

2. Enter the following interface and select jar file under Java

3. Select the project, confirm whether the necessary files are selected, and select the path to save the jar package, as shown in the following figure

4. After completing step 3, click next to enter the interface shown in the following figure:

5. Directly click next to enter the following interface:

6. Click Finish to finish the jar package.

remarks:

1. You can choose some conditions according to your needs. 2. Open meta-inf \ manifest.exe under the jar package MF this file to see if the information is correct.

Class path: This imports some other jar packages required by the project

Main class: This is the name of the class where the main () method is located Class file, and there is a carriage return at the end (for example, as shown above, the main () method is in the postgressqlsync class under the test package.)

Run the jar package under windows to confirm whether there is a problem with the exported jar package:

1. Open DOS command: switch to the project path through CD, and then enter Java - jar XXX jar。

If the input information is the same as the information output on the console when running the project, it indicates that the jar package has been completed.

Here are some of my problems:

1. In the DOS command, the following error indicates that the main class is not in meta-inf \ manifest MF is configured in this file.

2. In the DOS command, when the following error occurs, it means that no space is entered after class path: or main class:.

Note: of course, this is only the problem I encountered. If there are some errors in the documents written above, please point them out. Or if there are other problems during the operation, you can also communicate with me. (thank you!)

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>