Redian新闻
>
紧急求教,JAVA程序如何启动浏览器
avatar
紧急求教,JAVA程序如何启动浏览器# Java - 爪哇娇娃
p*p
1
IE或者FF,而且打开一个指定地链接
avatar
g*g
2
Runtime.getRuntime.exec()
firefox http://www.google.com.

【在 p***p 的大作中提到】
: IE或者FF,而且打开一个指定地链接
avatar
p*p
3

Runtime.getRuntime().exec(
"C:\.......\iexploer.exe");
对不对,请问如何指定路径呢

【在 g*****g 的大作中提到】
: Runtime.getRuntime.exec()
: firefox http://www.google.com.

avatar
g*g
4
Just put the absolute path in it, you need to use "\\" to represent "\"
in a string. In a more robust approach you may want to read registry.
Either way, you lose the platform-independcy.

【在 p***p 的大作中提到】
:
: Runtime.getRuntime().exec(
: "C:\.......\iexploer.exe");
: 对不对,请问如何指定路径呢

avatar
s*d
5
建议只写iexplorer.exe,因为通常情况下ie是放在系统路径里的.

【在 g*****g 的大作中提到】
: Just put the absolute path in it, you need to use "\\" to represent "\"
: in a string. In a more robust approach you may want to read registry.
: Either way, you lose the platform-independcy.

avatar
s*e
6
建议你看看BrowserLaunch的源代码.用google搜一搜就可以搜到了
基本上在几个os上都可以调用缺省的browser
在windows下当然是ie或者firefox(反正是你设定的缺省的browser)
在linux下好像要指定名字,比如说mozilla.
在mac os下我没试过

【在 s*******d 的大作中提到】
: 建议只写iexplorer.exe,因为通常情况下ie是放在系统路径里的.
avatar
p*p
7

是在Eclipse里面用运行的,用ANT编译。请问是不是要选择run-windows?
try {
Runtime.getRuntime().exec("iexplorer.exe "+httpURI);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
错误信息如下
[java] java.io.IOException: CreateProcess: iexplorer.exe
http://localhost:8080/CallCenter/CustomerSipSelect;ApplicationSessionID=111160
931956213782591?employeeID=5&kundensip=sip:p***[email protected] error=2
[java] at java.lang.Win32Process.create(Native Method)
[java] at

【在 s*******d 的大作中提到】
: 建议只写iexplorer.exe,因为通常情况下ie是放在系统路径里的.
avatar
m*t
8

It's "iexplore.exe" without the 'r'. And it's not by default on
the system path. People(the normal, innocent, ignorant, and
ever-demanding End Users, that is) don't start IE by typing it on
the command line, so it doesn't need to be on the path.

【在 p***p 的大作中提到】
:
: 是在Eclipse里面用运行的,用ANT编译。请问是不是要选择run-windows?
: try {
: Runtime.getRuntime().exec("iexplorer.exe "+httpURI);
: } catch (IOException e) {
: // TODO Auto-generated catch block
: e.printStackTrace();
: }
: 错误信息如下
: [java] java.io.IOException: CreateProcess: iexplorer.exe

avatar
g*g
9
yep, it's better to use the default path, and throw an error
ask user to specify if you can' find it.
Or read registry.

【在 m******t 的大作中提到】
:
: It's "iexplore.exe" without the 'r'. And it's not by default on
: the system path. People(the normal, innocent, ignorant, and
: ever-demanding End Users, that is) don't start IE by typing it on
: the command line, so it doesn't need to be on the path.

avatar
w*f
10
还是用现成的吧, 考虑更周全些。
http://ostermiller.org/utils/Browser.java.html

【在 m******t 的大作中提到】
:
: It's "iexplore.exe" without the 'r'. And it's not by default on
: the system path. People(the normal, innocent, ignorant, and
: ever-demanding End Users, that is) don't start IE by typing it on
: the command line, so it doesn't need to be on the path.

avatar
p*p
11
多谢了,DEMO时候出了小丑。本来用IE工作,弹出的
窗口却是FF的,当时就笑场了

Runtime.getRuntime().exec("iexplorer.exe "+httpURI);

【在 w***f 的大作中提到】
: 还是用现成的吧, 考虑更周全些。
: http://ostermiller.org/utils/Browser.java.html

avatar
e*e
12
hehe

【在 p***p 的大作中提到】
: 多谢了,DEMO时候出了小丑。本来用IE工作,弹出的
: 窗口却是FF的,当时就笑场了
:
: Runtime.getRuntime().exec("iexplorer.exe "+httpURI);

avatar
m*t
13

Your application _is_ supposed to use whatever the user sets
her default browser to. You should feel good about it.

【在 p***p 的大作中提到】
: 多谢了,DEMO时候出了小丑。本来用IE工作,弹出的
: 窗口却是FF的,当时就笑场了
:
: Runtime.getRuntime().exec("iexplorer.exe "+httpURI);

avatar
p*p
14
请问能不能启动一个浏览器之后能获得一个浏览器的对象,然后
可以操纵这个浏览器访问指定的连接?!

Runtime.getRuntime().exec("iexplorer.exe "+httpURI);

【在 g*****g 的大作中提到】
: yep, it's better to use the default path, and throw an error
: ask user to specify if you can' find it.
: Or read registry.

avatar
R*r
15
Most browser would accept command line parameter, you can
call from there.

【在 p***p 的大作中提到】
: 请问能不能启动一个浏览器之后能获得一个浏览器的对象,然后
: 可以操纵这个浏览器访问指定的连接?!
:
: Runtime.getRuntime().exec("iexplorer.exe "+httpURI);

avatar
r*e
16
去sourceforge找一个browserlauncher.

【在 p***p 的大作中提到】
: IE或者FF,而且打开一个指定地链接
avatar
b*o
17
String[] command ={"cmd.exe","/c","C:\\Program Files\\Internet Explorer\\IEXPL
ORE.EXE","","" };
Process proc = Runtime.getRuntime().exec(command);
proc.waitFor();

【在 r*****e 的大作中提到】
: 去sourceforge找一个browserlauncher.
avatar
p*p
18
It works fine for me, I use following code to open a default Browser.
For windows:
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
It open a new Browser Process for every URL, have to shut down one by one. Now
After opening a browser, the following urls will be launched in the same
browser.
So first:
public static Process launchURL(Process p, String url)
if (p==null) {
p = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " +
url);
} else {
?

【在 b*****o 的大作中提到】
: String[] command ={"cmd.exe","/c","C:\\Program Files\\Internet Explorer\\IEXPL
: ORE.EXE","","" };
: Process proc = Runtime.getRuntime().exec(command);
: proc.waitFor();

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。