• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Launching Acrobat Reader

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am using below code to launch Acrobat reader window to open PDF on windows

Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + file);

My application and browser are windows. Now if I move application over to linux platform how can I achieve the same thing? Pardon me, seeking expert advise in advance (I didn't try it yet).My user will always be opening IE from windows.

Thanks
-Nitin
 
Marshal
Posts: 79964
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

You oughtn't to use Runtime.exec() on its own; you get two Streams representing standard error and standard output, both of which must be "emptied" otherwise your Runtime.exec() might throw an exception. Google for "when Runtime.exec() won't" (sic) and you will get an article by Dacosta from 2000 about this very problem. Look in the API at the ProcessBuilder class, which I am not familiar with, but may provide a simpler solution to that problem.

You don't usually use Acrobat on Linux, but evince. I tried this on a Bash shell

[Campbell@dhcppc0 ~]$ which evince
/usr/bin/evince
[Campbell@dhcppc0 ~]$ evince /home/Campbell/oldFolders/Eiffel/ECMA-367.pdf

. . . and a few seconds later ECMA-367 opened. So try and see what happens. Or tryYou will have various Streams to "empty" and various Exceptions to catch, but you should find the details in the API for Process and ProcessBuilder and in Dacosta.
 
Campbell Ritchie
Marshal
Posts: 79964
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, but the Streams you want to get from the Process can be obtained with the getErrorStream() and getInputStream() methods.
 
Saloon Keeper
Posts: 28319
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, since Acrobat Reader isn't supposed to be using any of the standard I/O files, having the process fail on a write to stdout/stderr is OK by me. I've had to fix problems where processes exec'ed and had stream I/O to contend with, but never had issues when they were mute. And setting up to handle streams that shouldn't exist is a lot of trouble.

I do tend to prefer Acrobat Reader over evince or XPDF myself. On my home system, I think it's in /usr/local/Acrobat/bin/acroread, but the machine I'm using right now just has it in /usr/bin/acroread.
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you considered embedding a PDF viewer into your Java code so that it is far more portable? For example Accessing a PDF Document with the Acrobat Viewer JavaBean. This is only one example - there are plenty of other portable solutions as well.

Regards, Andrew
 
Tim Holloway
Saloon Keeper
Posts: 28319
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oooh, I like that idea! I'll have to remember it.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the Acrobat Java Viewer Bean hasn't been updated for ages (at least since PDF 1.4 came along, and maybe before that), and has serious problems displaying PDFs using recent features. So it works for simple stuff, but nothing fancy.
 
Any sufficiently advanced technology will be used as a cat toy. And this tiny ad contains a very small cat:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic