Demo 1: Generate a Console Application
Function: Convert JAR archive into Executive.
Part 1: Build a java program and create a jar charchive
1. Compose a java program D:\test\Hello.java:
package test;
public class Hello { public static void main(String
argv[]) { System.out.println("Hello, world"); } } |
2. Compile, we get Hello.class:
| D:\>javac -target 1.2 test/Hello.java |
3. Use jar.exe to create test.jar:
| D:\>jar cvf test.jar test/Hello.class |
Part 2: Use free tool to create .exe file
1. Download and install this free tool:
[Free Edition Download]
2. Launch J2EWizard, select the jar file, then press next to continue:

3. Select the application type. Here we select "Console Application":

4. Input the main class to start:

5. Type in the exe filename you want to get:

6. Press next, the exe file is generated.
Part 3: Run the Exe file
1. On console, type 'test' and enter:

2. Download the program and result exe in this demo:
[test.zip] - 20kb
More Demos:
Demo 2: How to generate a Windows GUI application in java?
Demo 3: How to build and create a Window NT Service in java?
Demo 4: Window NT Service supports PAUSE/CONTINUE.
Demo 5: System Taskbar Tray Icon and Event Log
|