• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Launching other applications from Java GUI

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I've been selected to go to the moon! All thanks to this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic