File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Problem with running a program from Java file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Problem with running a program from Java file" Watch "Problem with running a program from Java file" New topic
Author

Problem with running a program from Java file

Oz Kron
Ranch Hand

Joined: Feb 27, 2007
Posts: 41
I am trying to run a program, the program is EXE file written in C#, it should get input from a client in Java, and write to it (simple TCP/IP)
But
When it just doesn't work!
the program get stuck and don't get any thing from the server
But
When I run the server alone (EXE from the command), and connect to it with a client, every thing works fine!
So, what is the problem with "exec" and why isn't it like running a program from the command ?
Thank you
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35440
    
    9
Runtime.exec has a few pitfalls that you need to avoid. In this case it sounds like you may not be handling the input, error and output streams of the child process. You can read all about how to do that in this article.


Android appsImageJ pluginsJava web charts
Oz Kron
Ranch Hand

Joined: Feb 27, 2007
Posts: 41
Amm, but what is the problem?
I have done some of the things in the topic you have gave me, but than I can print like only one line, and when sending anther line to the server, it get stuck again like in the first time

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35440
    
    9
In that case it would help to see the code you're now using.
Oz Kron
Ranch Hand

Joined: Feb 27, 2007
Posts: 41

this is the code
Can some one help me out here?
Thank you
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35440
    
    9
So what happens exactly if you execute this code? Also, you don't seem to be handling the error stream.
[ August 13, 2007: Message edited by: Ulf Dittmer ]
Oz Kron
Ranch Hand

Joined: Feb 27, 2007
Posts: 41
What happen is for now that if the client send to the server one line, it kind of works, but if there are more lines, it get stuck
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Problem with running a program from Java file
 
Similar Threads
new command window
Problem running exe file in program files thru java
Runtime.exec() hell. Any opinions? explanations?
runtime.exec problems
can't run commands from application