[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.java.programmer

Why do I get no IO exception ?

Why do I get no IO exception ?

Johannes Beekhuizen

5/14/2016 7:24:00 PM

Hallo,

In an application I have the following block of code:

=== import ===
if ( ok.equals(cmd) ) { // Process the selection
String selection =
firmsTable.get((byte)choiceList.getSelectedIndex());
try {
ProcessBuilder pk =
new ProcessBuilder("java", "Greetings");
Map<String, String> env = pk.environment();
env.put("LANG", myLocale.toString());
env.put("FIRMACODE", selection.substring(2, 5));
env.put("FIRMANAAM", selection.substring(5 ))
Process ppk = pk.start();
} catch (IOException ioex) { System.err.println(ioex); }
Runtime runtime = Runtime.getRuntime();
runtime.exit(0);
}
=== tropmi ===

When "Greetings" does not exist, I would expect an IO exception. But I get
nothing. Why?

Groetjes,

Hans.


Roedy Green

1/6/2006 5:03:00 PM

On Fri, 06 Jan 2006 16:52:47, "Johannes Beekhuizen"
<jbeekhui@duinheks.xs4all.nl> wrote, quoted or indirectly quoted
someone who said :

>
>When "Greetings" does not exist, I would expect an IO exception. But I get
>nothing. Why?

You might possibly expect something if java.exe did not exist (use
explicit extensions in Windows), but once that program fires up, it is
a separate process, Any troubles it has, e.g. finding the Greetings
class, all you are going to find out is by the return code.

I hope you are just experimenting. If all you want to do in run
Greetings, just invoke method Greetings.main( new String [0] );
--
Canadian Mind Products, Roedy Green.
http://mi... Java custom programming, consulting and coaching.

opalpa@gmail.com

1/6/2006 7:09:00 PM

What Roedy is saying (assuming that Greetings and all other
applications are java too) you can invoke them within the JVM you are
in. Instead of executing in the operating system you can invoke the
main method on the classes you are interested in. (But you may want to
instantiate a Greetings object and then call some method). Because
you're not doing that I get a feeling that some of the stuff you invoke
is not Java classes but some other language executables.

opalpa@gmail.com

1/6/2006 7:09:00 PM

What Roedy is saying (assuming that Greetings and all other
applications are java too) you can invoke them within the JVM you are
in. Instead of executing in the operating system you can invoke the
main method on the classes you are interested in. (But you may want to
instantiate a Greetings object and then call some method). Because
you're not doing that I get a feeling that some of the stuff you invoke
is not Java classes but some other language executables.

http://www.geocities.com/...

Roedy Green

1/6/2006 11:23:00 PM

On Fri, 06 Jan 2006 19:37:34, "Johannes Beekhuizen"
<jbeekhui@duinheks.xs4all.nl> wrote, quoted or indirectly quoted
someone who said :

>The idea is that this application will be able to start other applications
>depending on the choice of the user. The "Greetings" is just used as an
>example to get the mechanism correct. If you think there's a beter way to do
>that, I won't mind if you tell me :)

If you are starting Java apps, you can use Class.forName. If you are
starting apps written in something else, you would need to use exec.

ClassForName will be much quicker since the program will run in the
same JVM.

See http://mi.../jgloss...
http://mi.../jgloss/classfo...
--
Canadian Mind Products, Roedy Green.
http://mi... Java custom programming, consulting and coaching.

Roedy Green

1/9/2006 9:01:00 PM

On Mon, 09 Jan 2006 21:24:05, "Johannes Beekhuizen"
<jbeekhui@duinheks.xs4all.nl> wrote, quoted or indirectly quoted
someone who said :

>OK, thank you. I'll study this and see if I can get it to work.
>I hava a question already: I prefer to pass parameters to the spawned
>applications by environment variables rather than parameters. I have not seen
>a way [yet] to do this with this construction. Is it possible at all?

See http://mi.../jgloss... to pass environment variables
to a spawned program.

--
Canadian Mind Products, Roedy Green.
http://mi... Java custom programming, consulting and coaching.

Thomas Weidenfeller

1/10/2006 8:08:00 AM

Johannes Beekhuizen wrote:
> I hava a question already: I prefer to pass parameters to the spawned
> applications by environment variables

Which is a bad idea in general, but that is an entirely different story.

> rather than parameters. I have not seen
> a way [yet] to do this with this construction.

Then you haven't Read The Fine Manual:

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime...(java.lang.String[],%20java.lang.String[])

/Thomas
--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/ja...
http://www.uni-giessen.de/faq/archiv/computer-lang.jav...

Big Daddy

9/6/2010 4:34:00 PM

On Sep 5, 11:18 pm, Taylor-VA <taylorv...@gmail.com> wrote:
> Location of game?

Games are in Chambersburg, PA - 60 miles south of Harrisburg PA just
off I-81 (and 60 miles west of York, PA, home of the upcoming York
Game Show in early October).

My friend and I are hoping to move his shooter game and my Bally slot,
want to sell both.

E-mail me if interested in talking more at
insertquarterhere(at)yahoo(dot)com

Thanks!
BD

Johannes Beekhuizen

5/14/2016 7:24:00 PM

Hallo Roedy,

Op 06 Jan 06 schreef Roedy Green aan All:

>> When "Greetings" does not exist, I would expect an IO exception. But I
>> get nothing. Why?
RG> You might possibly expect something if java.exe did not exist (use
RG> explicit extensions in Windows), but once that program fires up, it is
RG> a separate process, Any troubles it has, e.g. finding the Greetings
RG> class, all you are going to find out is by the return code.

OK, so I'll have to find out about retrieving the return code...

RG> I hope you are just experimenting. If all you want to do in run
RG> Greetings, just invoke method Greetings.main( new String [0] );

The idea is that this application will be able to start other applications
depending on the choice of the user. The "Greetings" is just used as an
example to get the mechanism correct. If you think there's a beter way to do
that, I won't mind if you tell me :)

Thanks for your help.

Groetjes,

Hans.


Johannes Beekhuizen

5/14/2016 7:27:00 PM

Hallo,

Op 06 Jan 06 schreef opalpa@gmail.com aan All:

o> Instead of executing in the operating system you can invoke the main
o> method on the classes you are interested in. (But you may want to
o> instantiate a Greetings object and then call some method). Because
o> you're not doing that I get a feeling that some of the stuff you
o> invoke is not Java classes but some other language executables.

Wrong :) I am somebody who was a reasonably handy programmer in Fortran,
Pascal en Cobol under MS-Dos and on main frames who suddenly has to work with
Java under Linux. That requires a rather different way of thinking...

Groetjes,

Hans.


Johannes Beekhuizen

5/14/2016 7:27:00 PM

Hallo Roedy,

Op 06 Jan 06 schreef Roedy Green aan All:

>> The idea is that this application will be able to start other
>> applications depending on the choice of the user.
RG> If you are starting Java apps, you can use Class.forName. If you are
RG> starting apps written in something else, you would need to use exec.

OK, thank you. I'll study this and see if I can get it to work.
I hava a question already: I prefer to pass parameters to the spawned
applications by environment variables rather than parameters. I have not seen
a way [yet] to do this with this construction. Is it possible at all?

Groetjes,

Hans.



Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Why do I get no IO exception ?

Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te

Il servizio è completamente GRATUITO!