process - How to run Linux program from Java code -
I am trying to create a disk space with java code using qemu-img, so I have a process and runtime I'm installing the client. When the command to run the program is not executed, though I use the same mechanism for equal performance and it works fine. That's why I am thinking that I miss something or not.
stringbuilder command builder = new string builder ("qemu-img create -f" + + selected storage type + "~ /" + storeName + ".img" + storageSize + "m"); Println (commandBuilder); String command = commandbill.stisting (); System.out.println ("This is right:" + Command); System.out.println ("Creating Image ..."); Runtime runtime = runtime.at timetime (); Process process = null; Try {Process = runtime.exec (command); System.out.println ("Try to Process .. Hold"); } Hold (IOException e1) {e1.printStackTrace (); Println (e1.getMessage ()); } Finally {System.out.println ("Finally Entry"); Process.destroy (); } The output is as follows:
qemu-img create -f raw ~ / testSPACE.img 23.0 m This is true: / qemu -img create - F raw ~ / testSPACE.img 23.0M Creating an image ... by process ... Finally check with the entry But if I go to the directory then the file is not created < / P>
Just to check it, if I copy the output in the terminal then it works like a charm.
tilde ( ~ ) here "~ /" + StoreName + "img" is interpreted by the shell as the meaning of your home directory. I will replace the actual path.
Note that the error code of the process (and its check!) / P> Process.waitFor () > >
Comments
Post a Comment