GloriousRain
asked on
Launch Web Browser in an application?
Dear all,
How can i launch Web Browser in an Java application(not applet)?
How can i launch Web Browser in an Java application(not applet)?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
May be you no need to import those packages..
You try to test the program by remove them one by one.
Ok. Good Luck
You try to test the program by remove them one by one.
Ok. Good Luck
ASKER
yongsing,
i couldn't open your link.
yongyih,
i don't want hardcode in my app. Is the address of IE always in the path you address? If not, how can i get the path in runtime?
i couldn't open your link.
yongyih,
i don't want hardcode in my app. Is the address of IE always in the path you address? If not, how can i get the path in runtime?
ASKER
yongyih,
one more thing: how about if i use Netscape?
one more thing: how about if i use Netscape?
This link works fine for me here. Why don't you try again?
To run Netscape:
Runtime.getRuntime().exec(
"C:\Program Files\Netscape\Communicato r\Program\ netscape.e xe http://www.yahoo.com");
This will open Netscape with the URL to Yahoo!
To run Netscape:
Runtime.getRuntime().exec(
"C:\Program Files\Netscape\Communicato
This will open Netscape with the URL to Yahoo!
The link will teach you how to launch the default browser on Windows platform.
http://www.javaworld.com/javaworld/javatips/jw-javatip66.html
http://www.javaworld.com/javaworld/javatips/jw-javatip66.html
ASKER
Dear all,
it's better if all you guys can give me the way to get the path for IE and Netscape because i don't want hardcode in my app.
it's better if all you guys can give me the way to get the path for IE and Netscape because i don't want hardcode in my app.
GloriousRain, please refer to the URL I've given. I believe it teaches you how to launch the default browser in your system.
ASKER
:) yongsing,
i still can't open. but i tell u the true, that i've found code in own our project shows how to launch Web in Java App, the code indicates it has origin from your link ( that reason y i give u points ). Now it's still not works fine because some difficult about multi OS problem. Thanks anyway!
i still can't open. but i tell u the true, that i've found code in own our project shows how to launch Web in Java App, the code indicates it has origin from your link ( that reason y i give u points ). Now it's still not works fine because some difficult about multi OS problem. Thanks anyway!
Great to hear that you already found your answer ^^
Anyway, if don't want to hardcode it, just pass in the path as parameter..
Like this, you can run any exe file you want. ^^
public class Test{
public void runProgram(String strPath)throws Exception{
Runtime temp=Runtime.getRuntime();
temp.exec(strPath);
}
public static void main(String[] args)throws Exception{
Test a=new Test();
a.runProgram("c:\\progra~1 \\Intern~\ \IExplore. exe");
}
}
Anyway, if don't want to hardcode it, just pass in the path as parameter..
Like this, you can run any exe file you want. ^^
public class Test{
public void runProgram(String strPath)throws Exception{
Runtime temp=Runtime.getRuntime();
temp.exec(strPath);
}
public static void main(String[] args)throws Exception{
Test a=new Test();
a.runProgram("c:\\progra~1
}
}
ASKER
yongyih,
"a.runProgram("c:\\progra~ 1\\Intern~ \\IExplore .exe");"
->This is also hardcode man. I mean you can get the path from Registry or somewhere at runtime not code strings directly in your program at design time.
"a.runProgram("c:\\progra~
->This is also hardcode man. I mean you can get the path from Registry or somewhere at runtime not code strings directly in your program at design time.
import java.io.*;
import java.text.*;
public class Test{
public void runExplorer()throws Exception{
Runtime temp=Runtime.getRuntime();
temp.exec("c:\\progra~1\\I
}
public static void main(String[] args)throws Exception{
Test a=new Test();
a.runExplorer();
}
}
Try this... hope this will help you.