2014-06-11 4 views
-1

nebeans 플랫폼 모듈을 사용하여 Java 데스크탑 도구를 만들었습니다. 이제 버튼을 클릭 할 때 기존 도구를 시작할 수있는 공통 도구를 만듭니다.다른 Java 응용 프로그램에서 Java 데스크탑 도구를 여는 방법

JFrame이 있고 단추 두 개가 들어 있다고 상상해보십시오. 하나는 tool1_btn입니다. 두 번째는 tool2_btn입니다.

이제 tool1_btn 도구를 클릭하면 팝업이 표시됩니다.

내가 ..

을 NOTEPAD.EXE를 나타납니다

try { 
    String line; 

    Process p = Runtime.getRuntime().exec("notepad.exe"); 

    /* java -classpath C:\\projects\\workspace\\testing\\bin test.TestOutput" 
    * Create a buffered reader from the Process input stream. 
    */ 
    BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); 
    /** 
    * Loop through the input stream to print the program output into console. 
    */ 
    while ((line = input.readLine()) != null) { 
     System.out.println(line); 
    } 
    /** 
    * Finally close the reader 
    */ 
    input.close(); 
} catch (Exception e) { 
    e.printStackTrace(); 
} 

처럼 쓰기하지만 우리는 기존 도구를 항아리에 대한 Java 클래스 경로를 제공하는 경우는 것입니다 단지 백 엔드를 실행합니다.

나는 그것을 더블 클릭하고 그것은 나를 hlep possible..Please opend..Is 것처럼 도구를 열려면 ..

내 질문에 저를 알리는 명확하지 않으면 ..

답변

0

내가 할 this like : 파일 exe = 새 파일 (...); Runtime.getRuntime(). exec ("rundll32 url.dll, FileProtocolHandler"+ exe.getAbsolutePath());

+0

그래 그 일 : –

1

ProcessBuilder을 사용하여 시작해야합니다. Process. 그 밖의 모든 것 외에도 프로그램의 시작 컨텍스트 (프로그램을 시작할 디렉토리)를 지정할뿐만 아니라 오류 스트림을 출력 스트림 및 기타 장소로 리디렉션 할 수 있습니다 (프로그램을 시작할 디렉토리)

.

예를 들어
try { 
    String line; 

    ProcessBuilder pb = new ProcessBuilder(
      "java", 
      "-cp", 
      "C:\\projects\\workspace\\testing\\bin", 
      "test.TestOutput" 
    ); 
    pb.redirectError(); 

    Process p = pb.start(); 

    BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); 
    /** 
    * Loop through the input stream to print the program output into console. 
    */ 
    while ((line = input.readLine()) != null) { 
     System.out.println(line); 
    } 
    /** 
    * Finally close the reader 
    */ 
    input.close(); 
} catch (Exception e) { 
    e.printStackTrace(); 
} 

...