Java opening the 'system default' web browser?

M

MS

Hi,

I've written a DVD database app in Java and, for any DVD, I'd like the
user to be able to click on a button to load the system default web
browser with the appropriate IMDb web page. Is it possible to tell Java to
open the sys default web browser with a specific page? If not can I get
Java to open a specific web browser?

Thanks,

MS
 
K

kaeli

Hi,

I've written a DVD database app in Java and, for any DVD, I'd like the
user to be able to click on a button to load the system default web
browser with the appropriate IMDb web page. Is it possible to tell Java to
open the sys default web browser with a specific page? If not can I get
Java to open a specific web browser?

The system command to open a browser tends to support a parameter including
the page to open.

i.e. Win2K, I can do Start -> Run ->
"C:\Program Files\Internet Explorer\IEXPLORE.EXE" http://www.google.com
and MSIE opens with Google.com as the page.

I don't know if that helps you any, though. :)


--
 
D

Dave

MS said:
Hi,

I've written a DVD database app in Java and, for any DVD, I'd like the
user to be able to click on a button to load the system default web
browser with the appropriate IMDb web page. Is it possible to tell
Java to open the sys default web browser with a specific page? If not
can I get Java to open a specific web browser?

Thanks,

MS

Here's something I did one time for running adobe, but it really works
for anything under windows, based on the extension of the file name
that is passed in.


public class defaultViewer {
public static void startdefaultViewer(String path){
try {
Process p =
Runtime.getRuntime().exec("RunDLL32.EXE shell32.dll,ShellExec_RunDLL "
+ path);
}
catch( IOException e ){
}
}
}


if you were to pass it a .htm or .html file, it will start the default
program that is associated with that filetype in windows.

Sorry if the code above wraps...

Dave
 
J

Jacob

MS said:
I've written a DVD database app in Java and, for any DVD, I'd like the
user to be able to click on a button to load the system default web
browser with the appropriate IMDb web page. Is it possible to tell Java
to open the sys default web browser with a specific page? If not can I
get Java to open a specific web browser?

Check the "browser" module of http://geosoft.no/software/
 
O

oskarsigvardsson

All these methods are really nice and good, but what I'd do is cheat a
little and use the (little known I've noticed) "start" command thats
been in windows for a while. If you type "start http://www.google.com"
into the command-promt it will open google in the default browser.
I.e.:

Runtime.getRuntime().exec("start http://www.google.com");

(the start command works basically like putting in things in start ->
run). This does however only work in windows. And really, it is
cheating.

Oskar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top