Forums Register Login

Launching firefox and IE from a Java App

+Pie Number of slices to send: Send
I have a Java app downloaded using Java Web Start that creates html by transforming xml using xsl.

I need to open the html in either Firefox or IE.

1. Firstly is there any way to tell the app which Browser launched the Java Web Start .jnlp file?

2. How can you launch Firefox or IE from a Java app? Is there any API available?

3. Preferably I do not want to save the html file to disk. Can it be passed directly from the Java app to the Browser?

Thanks ins advance.
+Pie Number of slices to send: Send
 


1. Firstly is there any way to tell the app which Browser launched the Java Web Start .jnlp file?


Don't think so. You don't need a broswer to launch a Java Web Start app, so I don't think there is any out-the-box method of doing this. Even if there were, I'm not sure how it would help solve your issue.


2. How can you launch Firefox or IE from a Java app? Is there any API available?


Runtime.exec(). Presuming you know where the user has installed their browser. And which browser it is.



3. Preferably I do not want to save the html file to disk. Can it be passed directly from the Java app to the Browser?


You can't use a browser to open a file that doesn't exist. Lots of Swing components render HTML though - could you not just use a one of them in your app?
[ January 25, 2007: Message edited by: Paul Sturrock ]
+Pie Number of slices to send: Send
One note with runtime exec ... on Windows you can "execute" an HTML file and launch the default browser. Open a command window and type the name of an existing HTML file like a command to see it work. There are many examples using RUNDLL32 to launch a file like this:

Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
+Pie Number of slices to send: Send
If you're using JDK 6, you can launch a browser fairly easily with java.awt.Desktop:

[ January 25, 2007: Message edited by: Jim Yingst ]
+Pie Number of slices to send: Send
In fact, the BasicService class that comes with Webstart has a showDocument method that does exactly what you want: http://java.sun.com/products/javawebstart/docs/javadoc/javax/jnlp/BasicService.html
Come have lunch with me Arthur. Adventure will follow. This tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 6376 times.
Similar Threads
is applet still important in java ?
how can i open save file dialog box in firefox?
download files from UNC using jsp
Applet ClassLoader Problem
HttpServletRequest getRemoteAddr() has strange results
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 01:54:30.