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.
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 from: Kp on January 22, 2004, 04:17 PM
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 ;)).
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.
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).
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 &"
Thanks iago
'javaw' runs on win32 without a console popping up
run
javaw mypackage.MyClass
Quote from: goofy-rhino on June 27, 2004, 01:21 PM
'javaw' runs on win32 without a console popping up
run
javaw mypackage.MyClass
oops, yeah, I know that now, but I forgot about this topic :)
Ah a much better solution. I was creating a wrapper executable in C++ to load the Java classes in the background.