[ZT] About using JAR package (sharing)

xiaoxiao2021-03-06  48

I just saw a friend written in the forum, I feel good, I will learn how to pack it with JAR. Excite. I understand new knowledge. Now collect this article / / / --------------------------------------- -------------------------------------------------- ------------------------------- Yesterday, I probably understood how the app was packaged into JAR, how to be executable. Share with you. The words of the rookie, expert advice!

For the explanation of the principles. Only one simple example. It is our HelloWorld. The purpose is to allow users to double-click the screen to output HelloWorld. In order to explain the role of the package, the package is also included.

Work catalog: D: class: HelloWorld.classhelloWorld.class location: d: /com/meibu/hmchelloWorld.class code as follows:

Package com.meibu.hmc; public class helloworld {public static void main (string args []) {system.out.println ("helloworld");}}

Ok, ready to work here. For simplicity, we use JB to generate JAR1, generating project files under JB. Then generate a Class file. 2. Click Project Properties under Project, select Application under the RUN tab, select the Class file containing public static void main (string args []) in Main Class. In this example is helloworld.class. Then determine. (I am because there is no setting here, I have not succeeded, I hope everyone will pay attention to it) 3, then click on the Archive Builder under Wizards. Select Application in Archive Type. Then I will go next step. A JAR file is generated when you are finished. 4, the JAR file contains our package, class file, and an important file Meta-INF folder, one of the manifest. MF file, this file is responsible for looking up the location of the Class containing Main. 5, this is what we entered in the DOS prompt D:> java-jar helloWorld.jar At this time, helloWorld string 6, if you want to double-click the executed file like Exe. We are with helloworold. New Run is new in the same directory in JAR. BAT file. Edit this file to enter java -jar hello.jar. All right. Double click to see, the result.

The above is a method of generating JAR and BAT. Improper expectation! / / -------------------------------------------------------------------------------------------- -------------------------------------------------- ------------------------- Note: Some hearts when I did it, now I added it, discover the third step above, some When doing it, don't generate .jar files, I just didn't have, depressed for a long time. The results found that in fact, you will generate a new file on the left of JBuilder, and the name of the file is just the name of the name you want to add (I'm default. " Application) This time you just click on this Application file with a mouse, select Make to generate .jar pull. Finally, thank the following authors.

转载请注明原文地址:https://www.9cbs.com/read-82584.html

New Post(0)