is possible capture InputStream Process to javaws application from another?

N

Nicola Turri

Hello i have simple problem when launch java web start application to
another java program.


I do not succeed to capture the system.out of the application javaws.

what is problem?

this is my simple example.


import java.io.*;

public class Demo {
static void Demo()throws IOException {

// start the ls command running

Runtime runtime = Runtime.getRuntime();
Process proc = runtime.exec("javaws
http://localhost:7080/myapp/myapp.jnlp" );

// put a BufferedReader on the ls output

InputStream inputstream =
proc.getInputStream();

InputStreamReader inputstreamreader =
new InputStreamReader(inputstream);
BufferedReader bufferedreader =
new BufferedReader(inputstreamreader);


// read the ls output

String line;
while ((line = bufferedreader.readLine())
!= null) {
System.out.println(line);
}

// check for ls failure

try {
if (proc.waitFor() != 0) {
System.err.println("exit value = " +
proc.exitValue());
}
}
catch (InterruptedException e) {
System.err.println(e);
}
}



public static void main(String[] args)
{

try
{

Demo();
}
catch(Exception ex)
{
ex.printStackTrace();

}

}
}
 
J

Joshua Cranmer

Nicola said:
Hello i have simple problem when launch java web start application to
another java program.


I do not succeed to capture the system.out of the application javaws.

what is problem?

The javaws tool, by default, exits the application before the
application finishes, so there is no output to capture. If you ran the
command as javaws -wait it should work.
 
N

Nicola Turri

I have tried with cmd /c javaws -wait my.jnlp

but it does not work unfortunately :)
 
J

Joshua Cranmer

Nicola said:
I have tried with cmd /c javaws -wait my.jnlp

but it does not work unfortunately :)
The answer is probably yes, but are you sure it actually produces output
on the output stream and not the error stream?
 
N

Nicola Turri

Hello, they are sure because the escape of the System.out.println , i see it
in java the java console .

perhaps it exists is a bugs with javaws.exe ?

Thanks
 
A

Andrew Thompson

Hello i have simple problem when launch java web start application to
another java program.

What are you actually attemtping to achieve here?
Do you control the code for both apps., and will
they be coming of the same domain?

(You might look to using the persistence service
fo the JNLP API - if both the above are 'yes', or
sockets, to communicate between the two apps.)

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top