This article a lot of transfer other people's place, the younger brother does the work is to everybody work summary according to this process may save everybody several 10 minutes or longer time ~
Brief process : Export jar files or apply tools to the expory with the eclipse's own, fat jar everywhere. (Tools more convenient)
Then use EXE4J to generate the. exe execution file, which should be noted here: (Summary of predecessors,..)
EXE4J is not allowed to package the JRE directly into the EXE. However, EXE4J provides a search JRE path, which can be a system environment variable, either a registry or a specific path.
Because it is not possible to run on a computer without a JVM, the search environment variable and the registry are naturally useless, so you can only search a path. Take the path of the JRE and add it to the line. But be careful: otherwise use absolute path OH. I was using the absolute path, resulting in invalid, and took a detour. For example, you can use:./jre
This copies the JRE environment to the same directory as the Jar. Use./represent the current directory
When you make the installation package, you package the resulting EXE file with the JRE. In order to confirm the completion of the package, you can use, before packaging, point to the EXE file, to confirm that it can run, or packaging to be white busy.
Packaging tools with Inno Setup. There may be other tools, but I've only tried this one. Very convenient.
Detailed steps:
Export Jar
First, export jar file:
If your program development is nearing completion and you are preparing to build it into your desktop executable without knowing what to do, you can simply follow these steps: Select your item---then right-click the pop-up options list---Select Export---Java---jar File---Next---browser (select the storage path for the jar)---next---next (to continue the next step, no matter how much)---browser (select your program's main class--OK)---finish; 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, however, by default, it opens in a compressed package, and if this is not the result you want, right-click the file---open---Select Java (TM) platform to run. I think you should have seen your software interface. Congratulations first.
Third, together with the Third-party documents exported to the jar file:
If you use the API or other ancillary resources provided by a third party during the development of your program, you must export the Third-party files when you export the build jar file, or your program will not run the results you want.
You can use the Fat jar plugin to generate the download address of the Jar,fat jar: http://sourceforge.net/projects/fjep/downloaded the 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 (Fat jar for short).
Plugin installation: Copy the Fat jar file into the plugins in your Eclipse directory. Restart your eclipse platform, and then look at window---preferences, the pop-up windows have fat jar preferences This means that you have been installed successfully, no this item is not installed successfully, You need to do the following: 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. (No success can go straight to the wall to die).
Packaging with fat jars: Right-click your project, the option list has a build Fat jar, select it, pop-up window you will feel particularly cordial, easy to use, click Browser (Main-class Select your main Class)---next---finish ( Check the resources you need to package together, default to all check. See, the jar file is built into your project. Run it, everything goes well, or you're programmed.
Another: If you don't want to pack with fat jars, there's a quicker way to help you, but it's also flawed.
Step: Place the attached file you need to use in the/lib/ext directory under your JRE installation directory (install the JDK as well as the JRE) and generate the jar by (first, export the jar file). That's it. It has a fatal flaw Such a jar file can only be used on your own computer, if you want to run on another machine must be placed in the/lib/ext the same ancillary resources. [Another method I did not experiment with]
generate an. exe (exe4j software)
Exe4j.
1. After running directly click Next.
2. Select the second item "JAR in EXE mode" and click Next.
3. Enter the name of your application in the general---short name of your application box (casually), and in Directories---output directory box, enter the save path after the build exe. And then next.
4. In the Excutable Name box, enter the name of the EXE to be generated, "icon File" is the application to display the small icon, do not select the line. continue to next.
5. You must first configure Class-path, click the + number to add files, that is, jar files, if useful to other resources need to add resources together.
6.General---Main class to select the main classes.
7.Java Version---Minimum version (which must be filled in at a lower edition), Maximum version (the high version can be empty), if all the values that are filled out so high must be greater than the lower version value.
The JRE path needs to be added at this time. If you want the software to run on a machine that does not have a JRE environment, first copy the JRE environment to a directory with the jar package.
Designate our own JRE as the preferred operating environment, as shown in the figure selection:
Search sequence
By default, the program will go to the system registry, environment variables and related directories to find JRE, because we only need to bring the JRE, so here I remove the default option, and then add the directory path where our own JRE resides, point + number begins:
It is also recommended that you use a relative directory path: The jar package is under the myloading path
Specify the directory in which the JRE resides, as shown in the figure:
Finally my JRE directory path is like this:. \jre1.6
8. Check allow JREs with a beta version number as well as only allow JDKs and no jres. Next, you can finish this step directly. This converts the jar to an EXE file. You can click Here to Start the application button to test the generated file.
This produces the. exe file.
Then use Inno Setup to build the installation package Setup.exe
Download Address: http://download.csdn.net/detail/mamba10/4587518
Extract.. Run Compil32.exe
Inno Setup download, go to the web search, after the installation of the Start Script Wizard, as shown in the figure:
The whole process is simple:
Here specify your program's startup file, that is, just use exe4j to create the EXE file, and your entire program directory is included in it, and then basically continue to press the next step on it, until the Script Wizard completes,
This is important, don't forget to "Add Folder"! Myloading folder contains everything in the program
You can then execute the script:
Then find the default output directory for Inno Setup, and you can see the installation package after the output is compiled, as shown in the following figure: Myloading installation. exe
Use this to quickly and easily install your Java desktop applications.