JavaSE如何启动桌面应用程序??

weifeng378 2018-06-24 01:25:30
JDK 9 开发环境 IDEA ,,系统windows10 。。

我在网上找的代码,运行出错
代码:Process p = java.lang.Runtime.getRuntime().exec( "D:\\test.txt");


java.io.IOException: Cannot run program "D:\test.txt": CreateProcess error=2, 系统找不到指定的文件。
...全文
269 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
stacksoverflow 2018-06-24
  • 打赏
  • 举报
回复
Process p = java.lang.Runtime.getRuntime().exec( "notepad.exe D:/test.txt");
天行归来 2018-06-24
  • 打赏
  • 举报
回复
Process p = java.lang.Runtime.getRuntime().exec("notepad.exe D:\\test.txt");
stacksoverflow 2018-06-24
  • 打赏
  • 举报
回复
参考
https://stackoverflow.com/questions/4157303/how-to-execute-cmd-commands-via-java
stacksoverflow 2018-06-24
  • 打赏
  • 举报
回复
Runtime r = Runtime.getRuntime();
Process process = r.exec("cmd /c c:/xxx/xxx.exe");
weifeng378 2018-06-24
  • 打赏
  • 举报
回复
如果是.exe 文件呢
zhuailhw123 2018-06-24
  • 打赏
  • 举报
回复
notepad.exe D:/test.txt

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧