• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Premature EOF from runtime.exec()

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic