Valhalla Legends Forums Archive | Java Programming | Making a program run in the background with Java.

AuthorMessageTime
Tuberload
I find it really annoying that the command prompt is in my taskbar when I create a program I just want running in the background. I have been searching for sometime now for a way to do this in java but haven’t found one, or any info on whether or not this is even possible.
January 22, 2004, 10:07 PM
Kp
Well, the somewhat hackish way that I think should work (albeit requiring non-Java code) : write something to spawn the java interpreter for you, without a console of its own. It'd be totally invisible, though. Alternately, you could redirect stdin/stdout/stderr beforehand to pipes controlled by your process, which could then provide an alternate UI for it (perhaps add a systray icon and pop up a tooltip if the Java interpreter prints anything "interesting"). The possibilities are endless (once you give up on Java ;)).
January 22, 2004, 10:17 PM
Tuberload
[quote author=Kp link=board=34;threadid=4851;start=0#msg40709 date=1074809835]
Well, the somewhat hackish way that I think should work (albeit requiring non-Java code) : write something to spawn the java interpreter for you, without a console of its own. It'd be totally invisible, though. Alternately, you could redirect stdin/stdout/stderr beforehand to pipes controlled by your process, which could then provide an alternate UI for it (perhaps add a systray icon and pop up a tooltip if the Java interpreter prints anything "interesting"). The possibilities are endless (once you give up on Java ;)).
[/quote]

I never thought of that. I guess I will have to sit down and figure out how to do that in C++.

I know, I know... I am working on learning C/C++, but I like Java. For the first time I am actually understanding programming concepts and theories. Not to say this is because of Java, but Java is the language I have been learning with recently so I am sticking with it. From here I will move on to bigger and better things.
January 22, 2004, 10:20 PM
Kp
Look into CreateProcess, in particular the creation flags. You'll want to create the java process detached from the console. If you go for having a systray icon, look into Shell_NotifyIcon and the TaskbarCreated window message (which has a dynamically assigned ID you can get from RegisterWindowMessage).
January 22, 2004, 10:25 PM
iago
I would recommend a program called, "Window Hider". I know I posted a thread about this once, but to save time you can get it at http://www.twilightutilities.com.

The way I prefer to do it, however, is by typing:
"java MyProgram &"
January 22, 2004, 11:23 PM
Chopz
Thanks Iago
January 28, 2004, 1:50 AM
goofy-rhino
'javaw' runs on win32 without a console popping up

run

javaw mypackage.MyClass
June 27, 2004, 6:21 PM
iago
[quote author=goofy-rhino link=board=34;threadid=4851;start=0#msg67429 date=1088360519]
'javaw' runs on win32 without a console popping up

run

javaw mypackage.MyClass
[/quote]

oops, yeah, I know that now, but I forgot about this topic :)
June 27, 2004, 9:54 PM
Tuberload
Ah a much better solution. I was creating a wrapper executable in C++ to load the Java classes in the background.
June 27, 2004, 10:07 PM

Search