The Artima Developer Community
Sponsored Link

Java Answers Forum
HELP! Runtime.getRuntime().exec("java Test")

2 replies on 1 page. Most recent reply: Mar 25, 2004 1:50 PM by Thomas SMETS

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
silly ivy

Posts: 7
Nickname: akane
Registered: Mar, 2004

HELP! Runtime.getRuntime().exec("java Test") Posted: Mar 24, 2004 8:38 AM
Reply to this message Reply
Advertisement
I have created a java code using threads and this code execute a class file using java.exe.

Process p = Runtime.getRuntime().exec("java -classpath c:\j2sdk1.2\bin\ Test);

The code using BufferedReader can print the output after executing the class file. But I hava a problem... how could I get inputs if the user is supposed to be prompted to input via the MS DOS prompt.. but I am not launching an MSDOS prompt.


Viswanatha Basavalingappa

Posts: 84
Nickname: viswagb
Registered: Nov, 2003

Re: HELP! Runtime.getRuntime().exec("java Test") Posted: Mar 24, 2004 10:58 PM
Reply to this message Reply
Hi,

I think you can use the other method types..as bellow..



1. exec(String[] cmdarray, String[] envp)
Executes the specified command and arguments in a separate process with the specified environment.

2. exec(String[] cmdarray, String[] envp, File dir)
Executes the specified command and arguments in a separate process with the specified environment and working directory.

3. exec(String cmd, String[] envp)
Executes the specified string command in a separate process with the specified environment.

4. exec(String command, String[] envp, File dir)
Executes the specified string command in a separate process with the specified environment and working directory.

Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: HELP! Runtime.getRuntime().exec("java Test") Posted: Mar 25, 2004 1:50 PM
Reply to this message Reply
I think that what you are looking for :)

Process p = Runtime.getRuntime().exec("java -classpath c:\\j2sdk1.2\\bin\\ Test"); // Carefull of the typo's in your code
// You must have double \ like in \\
p.getInputStream();
p.getOutputStream();

Why don't you prompt the user with a TextArea / TextField where they could provide their answer ?
It would be easier that wrapping the in/out put of one console to show it into another ... as you never know where the answer is expected to go ...
But it could be fun ;)

\T,

p.s. :
I don't get your point Viswanatha ?

Flat View: This topic has 2 replies on 1 page
Topic: Easy Way to Develop JAVA Enterprise Applications Previous Topic   Next Topic Topic: Windows Menu Bar

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use