Forum Stats

  • 3,759,035 Users
  • 2,251,494 Discussions
  • 7,870,475 Comments

Discussions

Using Runtime exec() to open java on other directory

843798
843798 Member Posts: 24,864
HI, I have a little problem and i hope everyone can help me out abit. You see when u use Runtime.exec(), how to you use it so that when the file you want to open is different from your program directory.
For example,
my program is in c:\windows\desktop
but the file i want to open eg. Somthing.class is in c:\my documents\
How do I open it using java and i wish to open the file using the java command. Thank a million

Comments

  • 843798
    843798 Member Posts: 24,864
    Hi,

    You can try something like

    Runtime.getRuntime().exec("cmd /c start /d\"C:\\my documents\" java.exe Somthing");

    Hope this helps,

    Kurt.
  • 843798
    843798 Member Posts: 24,864
    Runtime.getRuntime().exec("cmd /c start /d\"C:\\my documents\" java.exe Somthing");

    Can someone explain the /c start /d\"C:\Mydocuments\" java.exe Somthing.
    And I try to use ping in RunTime.exec,how do I construct the string?And how do i get the result of the ping?

    Thanks
This discussion has been closed.