Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Launching firefox and IE from a Java App

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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 ]
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
They weren't very bright, but they were very, very big. Ad contrast:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic