Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a java executable run in the background instead of the foreground?

I wrote a shell script to run a set of experiments so I won't have to do it manually. The script runs a java .jar file 30 times, and runs a set of those 30 times 17 times changing a few variables in between.

I invoke the program like this:

java -Djava.library.path=/Users/me/Desktop/Cfiles/DynamicCTGLayout/build/Release  -jar [name of .jar file]

However, I can't do anything in parallel while the program runs because when this line is executed, the java executable pops out at the forefront of the screen. In essence when I work on something else it gets interrupted every 1-1.5 minutes. so I'm looking at a few hours I can't actually use the computer.

Is there a way to invoke an executable so that it doesn't pop out on top of all the other programs?

Sincerely, WhiteTiger

Edit: Basically I'm looking for the Mac OSX equivalent to Windows'

start /min java [arguments]
like image 327
WhiteTiger Avatar asked May 19 '11 21:05

WhiteTiger


2 Answers

Use javaw instead of java (you might need to make sure its on the path). This will run it without any console.

javaw -Djava.library.path=/Users/me/Desktop/Cfiles/DynamicCTGLayout/build/Release -jar [name of .jar file]

like image 88
Femi Avatar answered Oct 07 '22 16:10

Femi


I had the same problem when executing a program encapsulated in a JAR. I fixed it by adding the option -Djava.awt.headless=true to my command line invocation (see oracle docs and this question). So, you would run:

java -Djava.awt.headless=true -Djava.library.path=/Users/me/Desktop/Cfiles/DynamicCTGLayout/build/Release -jar [name of .jar file]
like image 24
pillravi Avatar answered Oct 07 '22 16:10

pillravi