Current location - Health Preservation Learning Network - Slimming men and women - How to run a java program?
How to run a java program?
Of course, it can also be compiled into exe to introduce 3:

1, using JBuilder software, which has tools for exe files everywhere.

2. package it into a jar file first. Pay attention to specify the entry class, that is, the class where the main method is located, and make the exe4J package together with the dependency package, but this exe file can only run on the system with JRE installed.

3. This method is a bit troublesome, that is, the JRE is packaged together and can be run on a system without JRE installed.

1. After typing the above contents into the jar package, it will be put into jre\lib\ext together with the dependent jar package.

2. Write the startup batch in the upper directory of the jre folder. The function of% 1 is described as follows.

@SET PATH=。 /JRE/bin; % 1; % PATH %

@ start javaw com. Main (change it into your own program entry according to the actual situation)

3. Compile the batch into an exe program by using the fast batch file compiler.

This type of exe can be larger, because JRE is inherited. In fact, JRE can be slimmed down, and only the classes you want to use are kept, so I won't say much here. You can go and play if you are interested.