I've got regression tests of a Java system that don't bring up any graphical elements but do make use of the AWT event thread. Is there any way I can set things up to run this test suite in the background on my workstation without it constantly grabbing focus from whatever else I'm working on? (I'm running this on a mac.)
Asked
Active
Viewed 276 times
3 Answers
1
Try running java with -Djava.awt.headless=true parameter. This should work for you if you are not using any graphical elements. Hopefully, it will prevent the program from grabbing focus while it is running.
java -Djava.awt.headless=true
Here are some links with more information:
http://www.macosxhints.com/article.php?story=20071208235352641

Eric Bronnimann
- 941
- 7
- 8
-
The codebase has too many historical dependencies on AWT to do make the necessary refactoring practical. – Joshua Goldberg Dec 14 '10 at 22:11
0
You could execute these tests with a virtual desktop, virtual machine (like VMWare) or virtual frame buffer. I'm not sure about Mac, but on Linux it works great with xvfb
.

Konrad Garus
- 53,145
- 43
- 157
- 230
-
This is the first answer I looked into because it seemed the lowest-overhead. There's an additional stackoverflow thread that makes me think it might not be easy. Doesn't seem like there's a good way to ask Mac's java to use X11 instead of the native UI components. http://stackoverflow.com/questions/897054/how-to-display-java-swing-on-x11-when-running-on-mac – Joshua Goldberg Aug 05 '10 at 01:10
0
If your on a Mac: Run Tests - Without Focus Loss!

Bill the Lizard
- 398,270
- 210
- 566
- 880

Thierry Roy
- 8,452
- 10
- 60
- 84
-
What I wound up with, for now, is like a simplified version of this answer. I created a second user on the machine, ssh to the new user (who must be logged in via fast-user-switching) and run the tests as the other user in the terminal window. It works and saves me the thrashing, but there are a lot of little issues, like juggling permissions (I use a lot of chmod -R g+rw .) I'll post again if we do better. – Joshua Goldberg Dec 14 '10 at 22:13