Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Initializing network configuration when invoking cmd prompt from RunTime.exec()

Bangar Raju
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am building a swing application where in when we click a button I need to run a process from command prompt which needs network configuration information. I display the response from the process in a JTextArea. Currently the process is failing unable to resolve localhost. I tried to debug the problem and found out that network configuration is not initialized for the new command prompt which is invoked from Runtime.exec(). can some body tell how to initialize network configuration in this scenario.

Here is the code...... ResolveLocalHost is the java code where in I used InetAddress.getLocalHost() and I am printing the error in catch block.

String[] taskCommands = {"cmd.exe", "D:\\bea\\1003\\jdk160_05\\bin\\java", "ResolveLocalHost"};
Runtime rt = Runtime.getRuntime();
process = rt.exec(taskCommands, ProcessConstants.env, dir);

Bangar Raju.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic