473,836 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Execute Java in a new window

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.getRunt ime().exec("jav a -Xmx64M -Xms64M -jar AndromedaClient .jar");}
catch(Exception exc) {exc.printStack Trace(System.ou t);}

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
Jul 17 '05 #1
13 6608
> 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.
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.getRunt ime().exec("jav a -Xmx64M -Xms64M -jar AndromedaClient .jar");} catch(Exception exc) {exc.printStack Trace(System.ou t);}
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
Jul 17 '05 #2
"BlackHawke " <bl********@leg acygames.net> wrote in message news:<tS******* ************@ne wsread2.news.pa s.earthlink.net >...
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
'TextAreaPrintS tream' 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- ><>
Jul 17 '05 #3
nos

"FISH" <jo*****@mersey mail.com> wrote in message
news:db******** *************** **@posting.goog le.com...
"BlackHawke " <bl********@leg acygames.net> wrote in message

news:<tS******* ************@ne wsread2.news.pa s.earthlink.net >...
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
'TextAreaPrintS tream' 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?
Jul 17 '05 #4
> Why is using "javaw" a "misconception" ?

What I meant was I've had several people tell me "Oh, to open in a new
window, use javaw"... Apeares to me to be a comon misconception (even by
some advanced Java users). This is not what javaw does, and I wanted to head
off posts claming that that would work. It won't.

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

Of course. The problem is that because we are launching the program from
another java program, a new console window doesn't open up. When the
original program ends, there are no console windows open....

The following code:

Runtime.getRunt ime().exec("jav a -Xmx64M -Xms64M -jar AndromedaClient .jar");}

does not open the program "AndromedaClien t.jar" in a console window. I don't
know why, but it doesn't. Aparently calling "java" from inside a running
java program (and not from a bat file, for example) does not cause a console
window to open. We need a console window, so I am wondering how to fix this.
javaw {classname} > Log.txt 2>&1


That's a good idea... It'll help, but we still need a console window. :(

Nick
Jul 17 '05 #5
We'd still need to call exec()...

The problem is the update program (which itself sometimes needs to patch)
can not patch itself (because it's running). Therefore we have two separate
programs:

The updater-
Updates the client
Updates the graphics
Updates the sounds
Updates config files

The Client
Updates the updater
Plays the game

In this method we can patch any and all files we need to, but this means one
program MUST launch another.

The problem is even using "java" in the exec() command, a new console window
doesn't open. :(

Nick
----- Original Message -----
From: "FISH" <jo*****@mersey mail.com>
Newsgroups: comp.lang.java, comp.lang.java. help
Sent: Wednesday, February 04, 2004 4:01 AM
Subject: Re: Execute Java in a new window

"BlackHawke " <bl********@leg acygames.net> wrote in message

news:<tS******* ************@ne wsread2.news.pa s.earthlink.net >...
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
'TextAreaPrintS tream' 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- ><>

Jul 17 '05 #6
Thank you for your log advice. Unfortunately it was unsuccessful.

When I used it from a command line (java -Xmx100M -Xms64M -jar
AndromedaClient .jar > Log.txt 2>&1), it worked beautifully.

However when I inserted it into the code:

try {Process p =
Runtime.getRunt ime().exec("jav a -Xmx100M -Xms64M -jar AndromedaClient .jar >
Log.txt 2>&1");}

it failed to work.

My thought is it is tied to the fact that the above code fails to create a
console window. I am not sure, but our issue remains....

We need to launch a java program ("AndromedaClie nt.jar") from inside another
java program ("AndromedaOnli ne.jar"), and get either a console window for
the new program, or a log. Neither appears possible by any method we've
tried.

Nick

"KC Wong" <st************ ********@killki llkill.com> wrote in message
news:bv******** ****@ID-200690.news.uni-berlin.de...
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.
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.getRunt ime().exec("jav a -Xmx64M -Xms64M -jar

AndromedaClient .jar");}
catch(Exception exc) {exc.printStack Trace(System.ou t);}
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

Jul 17 '05 #7
BlackHawke wrote:
Thank you for your log advice. Unfortunately it was unsuccessful.

When I used it from a command line (java -Xmx100M -Xms64M -jar
AndromedaClient .jar > Log.txt 2>&1), it worked beautifully.

However when I inserted it into the code:

try {Process p =
Runtime.getRunt ime().exec("jav a -Xmx100M -Xms64M -jar AndromedaClient .jar >
Log.txt 2>&1");}

it failed to work.

You should try the exec() method that takes a String array - the command
to run and the arguments. I'm not sure that you will be able to do
redirection (>) with an exec().

--
---
MP3 Automagic CD Cover Creator (free Java app)
http://maccc.filenabber.com

Jul 17 '05 #8
Java Webstart can do the updating.
http://java.sun.com/products/javawebstart/

Your client program (whether you use your existing updater or Java webstart)
can catch the exceptions and use printStackTrace or getStackTrace to write
them to a file and to a text window (that you create).

You should be capturing the exceptions in the client program, not in the
updater.

Customers don't like looking at clunky console windows. They will iconize
it and ignore it.

If you capture exceptions, you can control what gets displayed in a dialog
(so they can't be ignored) and also log them to a file (and display it in a
your own code's text window if you want), you can at least look at their
error log when they report a problem (which *won't* be because they are
looking at the exceptions in the console, but *will* be because it doesn't
do what they expect or hangs etc).

"BlackHawke " <bl********@leg acygames.net> wrote in message
news:xB******** **********@news read1.news.pas. earthlink.net.. .
We'd still need to call exec()...

The problem is the update program (which itself sometimes needs to patch)
can not patch itself (because it's running). Therefore we have two separate programs:

The updater-
Updates the client
Updates the graphics
Updates the sounds
Updates config files

The Client
Updates the updater
Plays the game

In this method we can patch any and all files we need to, but this means one program MUST launch another.

The problem is even using "java" in the exec() command, a new console window doesn't open. :(

Nick
----- Original Message -----
From: "FISH" <jo*****@mersey mail.com>
Newsgroups: comp.lang.java, comp.lang.java. help
Sent: Wednesday, February 04, 2004 4:01 AM
Subject: Re: Execute Java in a new window

"BlackHawke " <bl********@leg acygames.net> wrote in message

news:<tS******* ************@ne wsread2.news.pa s.earthlink.net >...
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
'TextAreaPrintS tream' 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- ><>


Jul 17 '05 #9
I think I see what your problem is.

When you launch a program using Runtime.exec(), its standard input,
standard output, and standard error streams are redirected; they are piped
to the launching progarme which can access the via methods getInputStream( )
etc. of class java.lang.Proce ss. Therefore the "launchee" doesn't need a
console; as far as it is concerned, the "launchor" _is_ its console.

To create the effect of a console, e.g. to have System.out write to
somewhere the user can see, you'll need to do one of two things:
1. Instead of launching the program itself, launch a terminal and tell it
to run the program. How you do this is system dependent: e.g. on Unix you
could use xterm -e <program>, on Windows or PalmOS you probably do
something completely different.
2. Launch the program, grab its standard output from the Process object,
read everything which comes down the pipe and display it in a TextArea or
something. You can do the same (in reverse) for standard input if you like.

Make sense?

--
Chris Gray ch***@kiffer.eu net.be
/k/ Embedded Java Solutions

Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
9879
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ********************************** package Celcom.Client;
8
3890
by: tmb | last post by:
1 - Can you build an entire web page or site with Java... sorta like you can with Flash? 2 - Can you do... .. Drag & Drop .. Push Buttons .. Hot Spot .. Hot Object .. Pull Down's (combo boxs) .. data entry fields
18
2907
by: Mickey Segal | last post by:
On comp.lang.java.programmer we are discussing problems created for Java programs by pop-up blockers (in the thread "showDocument blocked by new microsoft pop-up blocker"). Our problem is that Java's showDocument method, which opens new browser windows, is blocked by some pop-up blockers. The showDocument method is blocked even if the user clicked a button in a Java program to call showDocument. As a result, a type of user-initiated...
5
16969
by: Good Man | last post by:
Hi there I am trying to execute a custom-built java program on my linux server via PHP. Basically, a user uploads files via PHP, and then the java program performs some action on these files. I have successfully had other operations performed on these files by using backticks, ie: $doit = `my exec command`;
1
9668
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
1
2321
by: Vinder | last post by:
Hey.... I want to execute java script code like this : javascript:void(d=window.document ); var el=d.getElementsByTagName("img"); var Lenth = d.getElementsByTagName("img").length;while(Lenth--)el.parentNode.removeChild(el);d.close(); i want to remove all images from open anew window openning I used this code to open a new webpage window.location=sURL; // sURL open a new web borwser.... i didn't programmer in Java script ... i...
0
3299
oll3i
by: oll3i | last post by:
package library.common; import java.sql.ResultSet; public interface LibraryInterface { public ResultSet getBookByAuthor(String author); public ResultSet getBookByName(String name);
1
5281
by: byjufromgamut | last post by:
I created a batch file, when executes gives a preview window(using swings & JFrame). I created another java fie in which used a Process object and Runtime.getRuntime().exec(path) , where path specifies the location of above batch file. when indepedantly executes i am able to execute the bath file through this second program. Now the problem is that i want to execute the batch file in my JSP where i have tried a lot to execute the batch file...
5
7084
by: sayeo87 | last post by:
Hi, I am quite new to JSP so please forgive me if I ask really simple things... I am trying to run system commands on the server and display the output on a webpage. This is what I've got: <%@ page import="java.io.*" %> <HTML> <BODY> <% Runtime rt = Runtime.getRuntime(); Process p = rt.exec("/bin/ls");
0
9656
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10567
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10237
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9349
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6972
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5641
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4437
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4000
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3100
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.