在后端运行Java程序 [英] Run a java program in backend

查看:96
本文介绍了在后端运行Java程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我想运行一个Java应用程序作为后端进程.这类似于tomcat服务器.为此,我开发了一个应用程序.并以一个类作为主类,并从一个脚本文件进行调用.即(startup.sh)在startup.sh文件中,我正在调用一个类.即MainMethodClass.在主要方法类中,我已编写了业务逻辑.当我在Linux服务器上通过使用腻子运行此应用程序时,它会起作用,直到没有关闭腻子窗口为止.由于在腻子窗口关闭后也停止了.但是即使我也关闭了,我也需要运行这个应用程序.我该如何做到这一点.

Hi all i want to run a java application as backend process.that is like tomcat server.For that i had developed one application.and made one class as main class and calling from one script file .i.e(startup.sh) file.in startup.sh file i was calling one class.that is MainMethodClass.In main method class i had written my business logic.when i am running this app in linux server from using putty is is working until putty window is not closed.As closed after putty window it is also stopped.but i need to run this app even i closed also.How can i achieve this.

推荐答案

Nohup 将分离一个您从当前控制台运行的进程,并在关闭终端时继续进行.运行这样的事情.

Nohup will detach a process you run from your current console and let it continue when you close the terminal. Run something like this.

nohup java -jar my.jar &

默认情况下,它将把输出通过管道传输到nohup.out,因此,如果您不希望这样做,可以尝试:

By default it will pipe the output to nohup.out, so if you don't want that you could try:

nohup java -jar my.jar > /dev/null &

这篇关于在后端运行Java程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆