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 ]
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.
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
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: