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 }

 

posted @ 2013-04-10 21:58  残剑_  阅读(7703)  评论(2编辑  收藏  举报