java打開本地應用程序


首先需要創建一個進程,然后用該進程去打開本地應用程序,當然也可以調用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 }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM