开发者

Execute Command Line Java program in background

Is it possible to execute a Java program in the开发者_如何学编程 background so the user can execute other commands in front of it?

For instance, here is how the console might look for said program:

$ myProgram (executes program)

Program Started! (output from myProgram)

$ (the user can enter another UNIX command while myProgram is still running)

Thanks in advance!


Background execution is part of the shell. You can add & at the end of the command line to run it in the background.

The background output does not go to the current shell. If that happened, it would be confusing to the user, having to type input while the terminal is still producing output.

EDIT: I just tried "ls &" on cygwin, and the ls output appears in the console. Seems there is a lot of conflicting information on the net! :)


Best way is to use screen if you dont have it type

sudo apt-get install screen

type

screen

run the command like

java MyClass

press ctrl + (a + d)

to view this window again, type screen -x


I beleive it's possible to start the program and allow access to the shell... but the user would not see the output.

I do not think its possible to achieve the example scenario you have given.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜