如何在程序中启动别的应用程序? 比如说通过双击打开word~ 在java中如何做到呢~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Runtime.getRuntime().exec(String cmd)能做到等价于你在开始->运行里输入的命令。比如Runtime.getRuntime().exec("cmd.exe /c start http://www.csdn.net");将打开IE,然后连到csdn至于你说的用打开word,可以具体研究在命令行里怎么完成这种功能的,比如"可执行文件路径"+ "参数" import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.IOException;import javax.swing.*;public class OpenIE extends JFrame { public OpenIE() { JButton button = new JButton("Open"); button.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub try { /* String[] strs = {"C:\\Program Files\\Internet Explorer\\iexplore.exe", "http://dzh.mop.com/topic/readSub_5661107_0_0.html"};*/ String[] strs = {"C:\\Program Files\\Microsoft Office\\Office10\\WINWORD.exe", "D:\\Develop Documents\\XML实用大全.doc"}; Runtime.getRuntime().exec(strs); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); this.getContentPane().add(button); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setBounds(200, 200, 200, 200); } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub new OpenIE().setVisible(true); }} 如何用java实现excel转换成csv 多个JFrame 放一起的问题 新人,提问 Jc编译运行都没错,JB编译没错,但是运行时全部都是NullPointerException 想提高图片的显示速度..请大家帮帮忙! 关于APPLET的 一个小问题 请高手帮忙! 怎么看一个ArrayList对象的容量? java 中中文编码问题 是不是 与本地系统有关? (路人甲)List->Arrays mysql与sqlyog安装问题 怎么样运行以下程序 ,我在eclipse直接运行是可以的。怎么在dos下运行 求救:java连接数据库的问题
比如
Runtime.getRuntime().exec("cmd.exe /c start http://www.csdn.net");
将打开IE,然后连到csdn至于你说的用打开word,可以具体研究在命令行里怎么完成这种功能的,比如"可执行文件路径"+ "参数"
import java.awt.event.ActionListener;
import java.io.IOException;import javax.swing.*;public class OpenIE extends JFrame { public OpenIE() {
JButton button = new JButton("Open");
button.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
try {
/* String[] strs = {"C:\\Program Files\\Internet Explorer\\iexplore.exe",
"http://dzh.mop.com/topic/readSub_5661107_0_0.html"};*/
String[] strs = {"C:\\Program Files\\Microsoft Office\\Office10\\WINWORD.exe", "D:\\Develop Documents\\XML实用大全.doc"};
Runtime.getRuntime().exec(strs);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
this.getContentPane().add(button);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setBounds(200, 200, 200, 200);
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new OpenIE().setVisible(true);
}}