The Artima Developer Community
Sponsored Link

Java Answers Forum
Runtime.getRuntime().exec()

0 replies on 1 page.

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 0 replies on 1 page
Ying Liu

Posts: 2
Nickname: yl
Registered: Jun, 2002

Runtime.getRuntime().exec() Posted: Jul 1, 2002 5:51 AM
Reply to this message Reply
Advertisement
Hi,

I have a question abotu runtime.exec().

I wrote a .BAT file (1.bat), whihc is to list all the file in C:\ (dir c:\). I can run it using DOS.

Then I try to run it using Runtime.getRuntime().exec(1.bat) in Windows 2000. But it does work. Can anyone tell me what is wrong?

it does not show anything. The exitVal = 1.

public void test()
{

String[] cmdLine = {"cmd.exe", "/c", "1.bat"};

String line = "";

try

{

java.lang.Process djProc = Runtime.getRuntime().exec(cmdLine);

System.out.println("1");

djProc.waitFor();

System.out.println("HERE");

BufferedReader input = new BufferedReader(new InputStreamReader(djProc.getInputStream()));

System.out.println("LINE = " +line);

while ((line = input.readLine()) != null) {

System.out.println(line);

}

System.out.println("in Here");

System.out.println("exitval = " + djProc.exitValue());

}

catch (Exception e)

{

System.out.println(e.toString());

}
}

Topic: Tomcat Installation Previous Topic   Next Topic Topic: problem in apahce java.exe

Sponsored Links



Google
  Web Artima.com   

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