首先需要創建一個進程,然后用該進程去打開本地應用程序,當然也可以調用cmd命令。
1 package com.test; 2 3 public class callExe { 4 5 /** 6 * @param args 7 */ 8 public static void main(String[] args) { 9 Runtime rt = Runtime.getRuntime(); 10 Process p = null; 11 String fileLac = ""; 12 try { 13 fileLac = "D:\\Program Files (x86)\\Notepad++\\notepad++.exe";//要調用的程序路徑 14 p = rt.exec(fileLac); 15 } catch (Exception e) { 16 System.out.println("open failure"); 17 } 18 } 19 20 }