Start jar mode (Windows and Linux)
Related links
https://blog.csdn.net/gelinwangzi_juge/article/details/127258536
windows start
View process
wmic process where caption="java.exe" get processid,caption,commandline /value
only view java task list
tasklist | findstr "java"
First prepare a jar package that can be run, and put any disk on it. The
first startup method (direct startup)
starts directly, and the log is output to the console.
java -jar slipper-backstage-2.0.0.jar
Effect:
start directly, log output to the specified file
java -jar slipper-backstage-2.0.0.jar > D:\测试jar包\server.log 2>&1 &
Notes:
表示日志输出到其他地方。
D:\测试jar包\server.log 日志输出的具体的路径。
2>&1 这个自己去百度查下,0,1,2都有表达的意思【0标准输入一般是键盘,1标准输出,2错误输出】
2>&1就是用来将标准错误2重定向到标准输出1中的。
& 表示后台运行
Effect:
Disadvantage : This startup mode, after the current command window is closed, the program stops
The second startup method (background startup)
starts in the background, starts the jar in the form of a service, after startup, closes the service that needs to be clocked in, or kills the process
javaw -Xms128m -Xmx1024m -jar slipper-backstage-2.0.0.jar
Start in the background, start the jar as a service, and output the log to the specified file
javaw -Xms128m -Xmx1024m -jar slipper-backstage-2.0.0.jar > D:\测试jar包\server.log 2>&1 &
Advantages : This startup method, after the current command window is closed, the program is still running
The third way to start (make it into a .bat file, simply encapsulate the command: double-click it),
specify the jar package as a bat batch file, and then double-click to start it, or make the bat file into a service self-starting method
in the same project Create a new run.bat in the level directory and copy the following content into it
@echo off
start javaw -Xms128m -Xmx1024m -jar slipper-backstage-2.0.0.jar > D:\测试jar包\server.log 2>&1 &
exit
Then double click to start
It is also possible to make bat into a service self-starting
1, Windows+R to run, enter gpedit.msc to enter the Group Policy Editor, select Windows Settings-Start, and then click Add Script.
can