0
try {
        Process p =Runtime.getRuntime().exec("startNetworkServer.bat",null, new File(System.getProperty("user.dir") + "/bin/"));
        p.waitFor();
    } catch (IOException ex) {
        Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InterruptedException ex) {
        Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
    }

and exception after run this code...

java.io.IOException: 
Cannot run program "startNetworkServer.bat" (in directory "C:\Users\..\Documents\NetBeansProjects\dir\bin"): 
CreateProcess error=2, System cant find directory`

please helpme with problem :)

Am_I_Helpful
  • 18,735
  • 7
  • 49
  • 73
bajky
  • 332
  • 6
  • 17
  • 1
    You have to specify full path to your startNetworkServer.bat file. Where is this batch file? I guess it is not in Netbeans bin directory... – Magic Wand Dec 04 '14 at 12:54
  • Are you sure that file is where the error says it is? If its next to the java file in netbeans than ud need to run a classloader – Arhowk Dec 04 '14 at 12:56
  • ok thanks ... but i try execute bat file from command line and now work this correctly :) – bajky Dec 04 '14 at 13:23
  • Batch files in Windows should be started via the cmd.exe. See: [How do I run a batch file from my Java Application?](http://stackoverflow.com/questions/615948/how-do-i-run-a-batch-file-from-my-java-application) – Ulf Jaehrig Dec 04 '14 at 14:26

0 Answers0