1. Windows
1. Copy javaw.exe in /jkd/bin in the jdk installation path, and rename the process name corresponding to the jar (you can change whatever you want)
2. Create a run.bar file in the same directory as jar with the following content:
@echo off start [修改后的javaw名称] -jar [jar的全名称]
For example:
Copied a javaw.exe and named it jarDemo; the directory where the jar is located is: d:Demo; so the corresponding content in run.bat is:
@echo off start jarDemo -jar D:演示jarDemo-0.0.1-SNAPSHOT.jar
(Note: jarDemo-0.0.1-SNAPSHOT.jar is the name of the built jarlinux command line startup process, you can change it yourself)
At this time, our jar starts running on the domestic Linux host in the background. We can also view the process corresponding to the jar through the task manager (you need to turn on the display of the process name column, which is not displayed by default)
You can see that the background jar has been successfully run by running run.bat.
2.Linux
It is relatively simple under Linux. Upload the jar to Linux. I use xftp6 to upload files here, and xshell6 for the command line. Friends who need it can leave a message and I will share the cracked version resources.
After the jar upload is completed, start the process using the linux command line, and use the command line input (running in the background as a daemon):
nohup java -jar xxx.jar > xxx.log &
(Note: nohup means daemon running, the first xxx means the specific name of the jar, the second xxx means the log output file qq for linux running the jar, which is stored in the same level directory by default, & means running in the background)
The above is the detailed content of How to implement background running of JAR process under Windows system. For more information, please follow other related articles on the PHP Chinese website!