• Welcome to Valhalla Legends Archive.
 

Making a program run in the background with Java.

Started by Tuberload, January 22, 2004, 04:07 PM

Previous topic - Next topic

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.
Quote"Pray not for lighter burdens, but for stronger backs." -- Teddy Roosevelt
"Your forefathers have given you freedom, so good luck, see you around, hope you make it" -- Unknown

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 ;)).
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Tuberload

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.
Quote"Pray not for lighter burdens, but for stronger backs." -- Teddy Roosevelt
"Your forefathers have given you freedom, so good luck, see you around, hope you make it" -- Unknown

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).
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

iago

#4
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 &"
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*



goofy-rhino

'javaw' runs on win32 without a console popping up

run

javaw mypackage.MyClass

iago

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 :)
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Tuberload

#8
Ah a much better solution. I was creating a wrapper executable in C++ to load the Java classes in the background.
Quote"Pray not for lighter burdens, but for stronger backs." -- Teddy Roosevelt
"Your forefathers have given you freedom, so good luck, see you around, hope you make it" -- Unknown