This article is intended to help people who have just contacted J2SE or do not know how to package jar files, but also to keep their knowledge in the form of articles.
First, export the jar file:
If your program development is nearing completion and you are ready to build the desktop executable without knowing what to do, simply follow these steps: Select your project---then right-click the pop-up options list---Select Export---Java---jar File---Next---browser (choose the storage path for the jar)---next---next (no matter how much further)---browser (choose your program's main class--OK)---Finish; View the directory where you store the jar Whether it has been generated. If not, you must not follow the steps.
Second, run the jar file:
The generated jar file you can double-click to run it, but by default it will be opened as a compressed package, if this is not the result you want, right-click on the file---open mode---Select Java (TM) platform to run. I think you should have seen your software interface. Congratulations first.
C. Export to the jar file together with a third-party file:
If you use the API or other ancillary resources provided by the third party during the development of the program, you must export the files of the third party when you export the generated jar files, or your program will not run to the desired results.
You can use the Fat jar plugin to generate the download address for the Jar,fat jar: http://sourceforge.net/projects/fjep/downloaded file is Net.sf.fjep.fatjar_0.0.31.zip, After decompression you will see the Net.sf.fjep.fatjar_0.0.31.jar file in the Plugins folder (called The Fat Jar).
Plug-in installation: Copy the Fat jar file to the plugins in your Eclipse directory. Restart your Eclipse platform and look at window---preferences, with the Fat jar preferences in the pop-up window indicating that you have successfully installed, without which the installation was unsuccessful. Take a few more steps: Go to the configuration---org.eclipse.update in your eclipse directory, delete the Platform.xml file, and then restart Eclipse. View Window---Preferences , you will find the Fat jar preferences this item. Congratulations on your installation success. (not successful can go directly to the wall to die).
Package with Fat jar: Right-click on your project, the option list has the build Fat jar item, select it, pop-up window you will feel particularly friendly, easy to use at a glance, click Browser (Main-class choose your main Class)---next---finish ( Tick all the resources you need to pack together, by default. Look, the jar file is generated in your project. Run it, everything goes well, otherwise you are programming the problem.
Another: If you don't want to pack a fat jar, there's a quicker way to help you, but it's also flawed.
Steps: Place the attached file you need to use in the/lib/ext directory in your JRE installation directory (the JRE is installed at the same time as the JDK is installed), and then generate the jar by (one, export the jar file). That's it. It has a fatal disadvantage, Such a jar file can only be used in your native computer, if you want to run on another machine it is necessary to place the same subordinate resources in/lib/ext.
D. Convert the jar file to exe executable file:
EXE file is easy to use, but also can improve the source code and resource security, but also lost the original intention of Java-cross-platform.
If you insist on converting to an EXE file, proceed as follows:
Using exe4j this software to convert jar file to exe file, exe4j download address: http://www.ej-technologies.com/download/exe4j/files.html, (currently the latest version is 4.2) http:/ /download.csdn.net/source/2393519 some need to install, and some as long as the decompression can be used. I usually install the EXE4J software, they are no different, so find a can use on the line. After downloading the installation, run it, and then follow the steps:
1. Click Next directly after running.
2. Select the second "JAR in EXE mode" and click Next.
3. In the general---the short name of your application box, enter the name of your application (whatever you want), enter the save path after generating EXE in the directories---Output directory box. Then next.
4. In the Excutable Name box, enter the name of the EXE that will be generated, and "icon File" is the small icon that the application displays, not the same. Continue next.
5. You must first configure the Class-path, click the + sign to add the file, that is, the jar file, if useful to other resources need to add resources together.
6.General---Main class is selected.
7.Java Version---Minimum version (the low version must be filled in), Maximum version (the higher version can be empty), if all are filled then the value of the higher version must be greater than the lower version value.
8. Tick enable JREs with a beta version number as well as the only allow JDKs and no jres. Next, you can finish it directly. This will convert the jar to an EXE file. You can click Here to Start the application button to test the generated file.
It's over here and it's not going to help you. I think how much to solve some people's annoyance is some.