Recently, a small project, using Java, made an application, but the user does not understand Java at all. It is impossible for the user to install JRE and set the environment variables. Therefore, the JRE is put together into the software, the method is as follows:
Create a directory as a packaging directory, such as the ring directory. Create a Java directory in this directory and copy bin and Lib under the JRE directory to this directory, then create a new lib directory under the ring directory, put the jar used by your project and the jar you wrote in this directory, and create two BAT files under the ring directory.
The first name is setenv. bat. The content of the file is:
Set CP = % CP %; % 1
The second BAT file can be named at will, and you only need to run the BAT file to run the project. The content is:
@ Echo off
Set CP =
For % I in ("./lib/*. Jar") Do call setenv. Bat % I
For % I in ("./JRE/lib/*. Jar") Do call setenv. Bat % I
Rem is the startup class of your project.
Start./Java/bin/Java-classpath % CP % ringpro. frame1
OK, I'm done.