可以,java功能可是相當強大的。

創新互聯建站-專業網站定制、快速模板網站建設、高性價比達拉特網站開發、企業建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式達拉特網站制作公司更省心,省錢,快速模板網站建設找我們,業務覆蓋達拉特地區。費用合理售后完善,十余年實體公司更值得信賴。
這個是調用應用程序的代碼:
Runtime
ec;
ec=Runtime.getRuntime();
ec.exec("這里是應用程序的路徑或者命令");
比如:ec.exec("c:\\123.exe");
運行exe 文件
Java JDK里已經提供了調用的方法,不在累贅,代碼如下。
try {
String command = "notepad";
Process child = Runtime.getRuntime().exec(command);
} catch (IOException e) {
}
這個也可以 Runtime.getRuntime().exec(wkspacePth + "/ReaderDevice.exe");
運行以下代碼試試看。
public static void main(String[] args) {
Frame frame = new Frame("打開文件窗口");
frame.setLayout(new FlowLayout(FlowLayout.CENTER));
frame.setBounds(100, 200, 400, 300);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
final TextField txtField = new TextField(50);
Button button = new Button("打開指定文件");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String path = txtField.getText();
System.out.println(path);
if (path.length() == 0) {
return;
}
try {
Runtime.getRuntime().exec("explorer.exe /n, " + path);
} catch (IOException ex) {
ex.printStackTrace();
}
}
});
frame.add(txtField);
frame.add(button);
frame.setVisible(true);
}
文章標題:java打開應用的代碼 java打開方式怎么設置
文章出自:http://www.yijiale78.com/article20/dohidco.html
成都網站建設公司_創新互聯,為您提供微信公眾號、建站公司、定制網站、云服務器、網站制作、標簽優化
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯