在窗口中运行的程序java,在新窗口中执行Java

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

解决方案

> Our program, game program Andromeda Online (www.andromedaonline.net) usestwo 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.

Why is using "javaw" a "misconception"?

It''s better for the end-users... having a command window hanging around

might make them worried/uncomfortable, and they might close that command

window, terminating the Java app at the same time.

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.

I don''t understand... what do you mean by "client does not run in console

mode"?

If your client app can be launched by "javaw", it can be launched by "java".

You can modify the command line to launch the client program to redirect the

standard error and standard output streams, e.g.

javaw {classname} > Log.txt 2>&1

That would redirect stderr to stdout, then stdout to Log.txt.

HTH,

KC

"BlackHawke" wrote in message news:...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.

[snipped..]

This doesn''t answer your question directly, as put, but it does provide

a solution: have you considered just opening an AWT window with a TextArea

set to fixed width font, then appending your stuff onto the end of the

TextArea. It is possible to redirect System.err - so write a simple

''TextAreaPrintStream'' class with the same interface, which ''outputs'' to

a given TextArea.

This solution:

(a) is easier to use (it''s awkward cutting/pasting from a MS-DOS window).

(b) supports better platform neutrality (platforms without shells?)

(c) does not require an exec() call to fork off a new java executable,

with all the associated issues that brings.

-FISH- ><>

"FISH" wrote in message

news:db*************************@posting.google.co m..."BlackHawke" wrote in message

news:...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.

[snipped..]

This doesn''t answer your question directly, as put, but it does provide

a solution: have you considered just opening an AWT window with a TextArea

set to fixed width font, then appending your stuff onto the end of the

TextArea. It is possible to redirect System.err - so write a simple

''TextAreaPrintStream'' class with the same interface, which ''outputs'' to

a given TextArea.

This solution:

(a) is easier to use (it''s awkward cutting/pasting from a MS-DOS window).

(b) supports better platform neutrality (platforms without shells?)

(c) does not require an exec() call to fork off a new java executable,

with all the associated issues that brings.

-FISH- ><>

what about java console?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值