Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Launching other applications from Java GUI

Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All -
We are planning to rewrite a GUI application in Java/Swing. In our current GUI (using Visual Basic), users can search for some documents and the search results display a list of PDF documents. If the user does a double click on one of the results, the application launches Adobe Acrobat reader with the corresponding PDF file. We know that Acrobat Reader is available in most platforms. But, how can I launch Acrobat reader from my Java application without sacrificing the platform independent feature of Java? How can I check whether Acrobat reader is installed in the platform in which the GUI is run? All suggestions will be appreciated.
- Hari Gangadharan
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, this will get it started.
try {
Runtime.getRuntime().exec("C:\\Program Files\\Adobe\\Acrobat 4.0\\Reader\\AcroRd32 S:\\wherever\\yourFile.pdf");
catch(IOException e) {
//something clever

However, this is of course very dependant on the location of the installation of AcroRd32.
You can alway hope that the AcroRd32.exe is in the path and try
Runtime.getRuntime().exec("AcroRd32 yourFile.pdf");
You could set up your exception to look for am IOException and do something clever about asking the user to find the reader.
[ November 12, 2002: Message edited by: Cindy Glass ]
Hari Gangadharan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Cindy --
I was thinking in those lines. I think I may have to build intelligence into the application to look for possible locations of Acrobat Reader. I think I may have to popup a JFileChooser and ask the user to locate acrobat reader, if I fail.
Cindy, thanks for these tips, once again.
Did Steve tell you that? Fuh - Steve. Just look at this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic