java and terminal window commands
Hey there
I am interested in creating a java program which uses a print statement to the terminal window which actually is a command. To be more clear consider the following example. Quote:
Is something like that possible? Thanks for your time |
It is doable by using the Runtime.exec() method, but it is usually not a good idea to run external programs from Java.
Especially when the job can be done in Java, like in this case (you can create a directory in pure Java), which would make your application more portable. |
Hey again
Many thanks for your reply I would like once more again your advice. I have a C program which can be executed like: Quote:
What i want to do is to run the C program then start up Java program which reads the output, determines if it is appropriate and if it's not then it starts up again the C program. All of that should happen until i get the desired output The fact is that i dont need to make any change to C or Java files. In other words they dont need to be compiled again Any ideas? |
How is the java program reporting the input is not appropriate ?
|
You will need to spawn the C application from within the Java program, and make use of the java.util.Scanner class (it's the easiest class in the world for obtaining input).
Pretty much, you'll need to spawn the C app. from within the java.util.Splitter() instance, like so: Code:
java.util.Scanner s = new java.util.Scanner(Runtime.exec("application")); :D |
All times are GMT -5. The time now is 06:42 AM. |