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