可以,java功能可是相當(dāng)強(qiáng)大的。
創(chuàng)新互聯(lián)建站-專(zhuān)業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性?xún)r(jià)比達(dá)拉特網(wǎng)站開(kāi)發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫(kù),直接使用。一站式達(dá)拉特網(wǎng)站制作公司更省心,省錢(qián),快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋達(dá)拉特地區(qū)。費(fèi)用合理售后完善,十余年實(shí)體公司更值得信賴(lài)。
這個(gè)是調(diào)用應(yīng)用程序的代碼:
Runtime
ec;
ec=Runtime.getRuntime();
ec.exec("這里是應(yīng)用程序的路徑或者命令");
比如:ec.exec("c:\\123.exe");
運(yùn)行exe 文件
Java JDK里已經(jīng)提供了調(diào)用的方法,不在累贅,代碼如下。
try {
String command = "notepad";
Process child = Runtime.getRuntime().exec(command);
} catch (IOException e) {
}
這個(gè)也可以 Runtime.getRuntime().exec(wkspacePth + "/ReaderDevice.exe");
運(yùn)行以下代碼試試看。
public static void main(String[] args) {
Frame frame = new Frame("打開(kāi)文件窗口");
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("打開(kāi)指定文件");
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);
}
文章標(biāo)題:java打開(kāi)應(yīng)用的代碼 java打開(kāi)方式怎么設(shè)置
文章出自:http://www.chinadenli.net/article20/dohidco.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號(hào)、建站公司、定制網(wǎng)站、云服務(wù)器、網(wǎng)站制作、標(biāo)簽優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)