Re: Execute Java in a new window
From: Raymond DeCampo (rdecampo_at_spam-I-am-not.twcny.rr.com)
Date: 02/07/04
- Next message: Paul Thompson: "Re: Java, Linux and FIFOs"
- Previous message: Raymond DeCampo: "Re: Retrieving Sounds from a Jar file"
- In reply to: BlackHawke: "Execute Java in a new window"
- Next in thread: BlackHawke: "Re: Execute Java in a new window"
- Reply: BlackHawke: "Re: Execute Java in a new window"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 07 Feb 2004 20:04:08 GMT
BlackHawke wrote:
> Our program, game program Andromeda Online (www.andromedaonline.net) uses
> two programs- one to play the game, another to patch the game as updates
> come out. Players actually launch the updater which checks for fresh
> updates, then installs them, then launches the game client.
>
> We have begun our beta test, and would like to have the client open with a
> console window so that players can see exceptions that are thrown. How to do
> this seems to be a question no-one can answer.
>
> A common misconception (as I understand it) is to use "javaw", but javaw
> actually runs a program with no console. It's 'java' which will open a
> command window to run in.
>
> So how do we get our update program to launch our client program in a
> console window? This is the code we have now:
>
> public static void main(String args[]) {
> UpdateFrame uf = new UpdateFrame();
>
> try {Process p =
> Runtime.getRuntime().exec("java -Xmx64M -Xms64M -jar AndromedaClient.jar");}
> catch(Exception exc) {exc.printStackTrace(System.out);}
>
> uf.removeNotify();
> uf.dispose();
> }
>
> This successfully launches the client, but the client does not run in
> console mode.
>
> Any help would be greatly appreciated.
>
> Nick Soutter
>
Nick,
I'm going to assume a windows-specific solution is desired. That seems
reasonable, since you mentioned javaw.
I see a lot of stuff being thrown around in this thread, for example,
trying to redirect standard output and error from Runtime.exec(). The
reason that does not work is that in is actually the shell (cmd.exe or
command.com) that does such things.
You have a couple of options. You can replace the updater with a BAT
file that launches the updater, waits for it to finish and then launches
the client.
Or you could change how the updater invokes the app. Try using
something like:
Runtime.exec("cmd /c java ...");
You may need to put quotes around everything after the /c. If you are
running on multiple Windows versions, use the value of the COMSPEC
environment variable instead of hard coding "cmd". Also, you might have
success by wrapping the java command inside a BAT file file. You will
also want to look at the "start" command. (Start->Help and search for
"start".)
BTW, this is an interesting business model you have, solving all your
technical problems via the Usenet. Is it working out the way you planned?
Ray
- Next message: Paul Thompson: "Re: Java, Linux and FIFOs"
- Previous message: Raymond DeCampo: "Re: Retrieving Sounds from a Jar file"
- In reply to: BlackHawke: "Execute Java in a new window"
- Next in thread: BlackHawke: "Re: Execute Java in a new window"
- Reply: BlackHawke: "Re: Execute Java in a new window"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|