java - how run a command on Oracle VM -
we have oracle virtual machine installed in our solaris machine. (we need waptpro tool can installed on windows). so, have tool installed on oracle virtual machine.
now have java code on solaris machine. need execute waptpro tool solaris machine. if there command can run command on oracle virtual machine solaris can integrate in javacode
so, please let me know if know how execute command on oracle virtual machine solaris.
this easy in simplest case require quite bit of elbow grease right cases.
from http://www.rgagnon.com/javadetails/java-0014.html java 1.5 , later (adapt command needed):
import java.io.*; import java.util.*; public class cmdprocessbuilder { public static void main(string args[]) throws interruptedexception,ioexception { list<string> command = new arraylist<string>(); command.add(system.getenv("windir") +"\\system32\\"+"tree.com"); command.add("/a"); processbuilder builder = new processbuilder(command); map<string, string> environ = builder.environment(); builder.directory(new file(system.getenv("temp"))); system.out.println("directory : " + system.getenv("temp") ); final process process = builder.start(); inputstream = process.getinputstream(); inputstreamreader isr = new inputstreamreader(is); bufferedreader br = new bufferedreader(isr); string line; while ((line = br.readline()) != null) { system.out.println(line); } system.out.println("program terminated!"); } }
Comments
Post a Comment