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 ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Launching Acrobat Reader

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I need to launch Acrobat Reader from my GUI. How will I do that? - somehow get the information from the registry?? I need to support both NT and 2000.
Thanks in advance,
Annie
[ April 01, 2003: Message edited by: Annie Siddharth ]
 
Bartender
Posts: 1840
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are several ways to do this, and none of them are truly ideal. The first (and easiest) is to require that Adobe Acrobat Reader be in the system path for the machines on which you are installing. This is the easiest method, but requires some amount of clout with the people setting up the systems on which your program will run.
Short of that, you could create a .properties file and have the path to Acrobat be specified therein. If Acrobat is located in different places on different machines, then each machine needs to have its own .properties file. This can get annoying because you might have to individually configure the .properties file on every machine that this program is deployed on.
Thirdly, you could use the java.io.File class to explore the computer until you found the acrobat reader executable. Not ideal processwise, but this is truly dynamic. You just have to know what drive letters the computer has (and while these can change, you can test them by creating a file for J:\ and asking if the file exists.) Once you've found it once, you could store the location in a .properties file so you wouldn't have to search again. (Or, if someone knows a better way of searching a computer for a file???)
Finally, can we assume that you don't want to open Reader by itself but would rather open a document in reader? You can create a temporary .bat file that contains the name of the file you want to open. Then call Runtime.getRuntime().exec(<BATCH_FILE_NAME> ; If the extension is properly mapped, the OS should automatically launch Reader and display that file. Note that you can't just use the name of the file as the parameter to exec(String) because the VM expects a process to start. (I tried this and it does not work.) It should be able to run batch files, however.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're just trying to view a PDF through a Java application, then you might want to make use of some third party Java-based PDF viewer.
I've not used any of these, but others have suggested considering the following free products to view and/or create PDFs through a Java app:
  • Adobe's Acrobat Reader for Java
  • Etymon's PJ Classic
  • FOP of the Apache XML Project
  • iText
  • PDF Box
  • gnujpdf
  •  
    You didn't tell me he was so big. Unlike this tiny ad:
    Thread Boost feature
    https://coderanch.com/t/674455/Thread-Boost-feature
      Bookmark Topic Watch Topic
    • New Topic