4

I've got an ant target ant server that runs a Java application which logs to the console. I need to run a new ant target ant server-gui which also logs to the console. But when I run ant server the logging prevents me from running any new ant targets.

When I enter ^c (which is the only way I know of to get out of situations like that) it kills the Java application. I need both to run. What keystroke will get me out of that "input" mode and able to run new terminal commands?

UPDATE: I haven't found a direct solution to getting out of that mode I mentioned, but opening a new tab/window in terminal does the trick. I can run as many any commands as I'd like that way. Still looking for a good solution to get out the "input" mode, though!

UPDATE 2: @abcdef pointed out another post that has an even more elegant solution.

Clay Ellis
  • 4,960
  • 2
  • 37
  • 45

1 Answers1

1

There are a few ways to do this, assuming you are on *nix

1) Run the ant command with a & at the end to tell *nix to run the command in the background

2) Run the command with nohup at the beginning (https://en.wikipedia.org/wiki/Nohup)

3) when the process is running press ctrl-z then enter the command bg. This manually forces the command to run in the background

I hope this helps you out

abcdef
  • 441
  • 3
  • 13
  • I'm actually using terminal on a Mac. But I assume it'll work out in nearly the same way. – Clay Ellis Mar 08 '15 at 08:47
  • So here's the outcome: 1) Adding & at the end still started the logging but I was able to mix it with method 3 (ctrl-z) to get halfway there but it killed the second application. 2) Adding nohup to the beginning sent the output to nohup.out (I can't find how to get to this output file, though...) but I still had to use ctrl-z to get out of the "input/logger" mode which killed _both_ applications. 3) Ctrl-z pops me out of the "input/logger" mode but kills the applications. So I'm halfway there! I just can't kill the applications—they need to stay up. – Clay Ellis Mar 08 '15 at 08:53
  • Do you use the fork attribute in at so that the spawned Java process runs in its own JVM? Or do you use the spawn attribute? – abcdef Mar 08 '15 at 09:22
  • I'm forking each time. I found a workaround that's overly simple (but still leaves me without an answer to exiting that mode). I just open a new tab/window in terminal. Simple as that, I guess! – Clay Ellis Mar 08 '15 at 20:46
  • Does this help? https://stackoverflow.com/questions/2158937/can-ant-launch-two-java-applications-concurrently – abcdef Mar 08 '15 at 22:02
  • That looks like it'll do it! Great find! Thanks @abcdef – Clay Ellis Mar 08 '15 at 23:05