wood burning stoves 2.0*
The moose likes Servlets and the fly likes Premature EOF from runtime.exec() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Premature EOF from runtime.exec()" Watch "Premature EOF from runtime.exec()" New topic
Author

Premature EOF from runtime.exec()

mathew Jackson
Greenhorn

Joined: Jun 15, 2001
Posts: 12
First, if this is the wrong forum, my appologies.
I have a servlet that executes a C++ program on Solaris. The problem I'm having comes in streaming the output from the servlet to the client app. The client is also a Java client.
The code looks like this (but a bit more complex)
OutputStream = (OutputStream)response.getOutputStream;

Runtime rt = Runtime.getRuntime();
Process pro = rt.exec(cmd);
InputStream is = pro.getInputStream();
byte[] buffer = new byte[266];
while(true){
int bytes = in.read(buffer);
if(bytes == -1) break;
out.write(buffer,0,bytes);
}// end while
Regardless of the size of output (and it is usally quite large) I get one of two errors. either an OutOfMemoryError from the servlet or Unexpected EOF Exception from the client.
Does anybody have any ideas? Would I have the same trouble if I used JNI?
thanks in advance
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Premature EOF from runtime.exec()
 
Similar Threads
Newbie File Questions
Sending a file over socket
Reading & Writing bytes to socket
Copying File
how can i copy a file from one location to another location then delete............