Home  >  Article  >  System Tutorial  >  How to implement background running of JAR process under Windows system

How to implement background running of JAR process under Windows system

WBOY
WBOYOriginal
2024-07-17 01:21:14599browse

Windows 系统下如何实现 JAR 进程的后台运行

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的全名称]

启动进程的命令_起进程命令_linux 命令行启动进程

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:

启动进程的命令_linux 命令行启动进程_起进程命令

@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)

linux 命令行启动进程_启动进程的命令_起进程命令

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)

linux 命令行启动进程_启动进程的命令_起进程命令

启动进程的命令_linux 命令行启动进程_起进程命令

You can see that the background jar has been successfully run by running run.bat.

启动进程的命令_起进程命令_linux 命令行启动进程

linux 命令行启动进程_起进程命令_启动进程的命令

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn