2012-06-05 5 views
0

Oracle 가상 시스템이 Solaris 시스템에 설치되었습니다. (Windows에만 설치할 수있는 waptpro 도구가 필요합니다). 따라서 우리는이 도구를 Oracle 가상 시스템에 설치했습니다.Oracle VM에서 명령을 실행하는 방법

이제 solaris 컴퓨터에 Java 코드가 있습니다. solaris 시스템에서 waptpro 도구를 실행해야합니다. 솔라리스에서 오라클 가상 머신 명령을 실행할 수있는 명령이 있다면 javacode에 통합 할 수 있습니다.

solaris에서 oracle 가상 시스템 명령을 실행하는 방법을 알고 있다면 알려주십시오.

답변

0

이것은 가장 단순한 경우에는 간단하지만 모든 경우에 적합하도록 꽤 많은 양의 팔꿈치 기름이 필요합니다.

자바 1.5 http://www.rgagnon.com/javadetails/java-0014.html에서

이상 (필요에 따라 명령을 적응) : 나는 "WINDIR"와 "온도가"여기에 사용 된 환경 변수라고 가정하고

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 is = 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!"); 
    } 
} 
+0

. 이러한 변수를 생성하는 방법과 oracle VM에서 스크립트를 실행하기위한 값을 알려주시겠습니까? system.getenv ("windir") 및 system.getenv ("temp") 값은 null을 반환합니다. – Praveen

관련 문제