aspose 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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
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: 41880
    
  63
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.


Ping & DNS - my free Android networking tools app
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: 41880
    
  63
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: 41880
    
  63
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://aspose.com/file-tools
 
subject: Problem with running a program from Java file