opening PDF file under XP works but not under Vista

Discussion in 'Java' started by Peter Rait, Jun 15, 2008.

  1. Peter Rait

    Peter Rait Guest

    Hi,

    I try to open a self generated PDF file (using iText) with:

    public static void OpenPDF(String PDFName) throws Exception {
    Process p =
    Runtime.getRuntime()
    .exec("rundll32 url.dll,FileProtocolHandler "+PDFName);
    p.waitFor();
    }

    This works very well under WindowsXP but not under Windows Vista. Did
    anyone have already the same experience (probably with another file
    type) and find another solution?

    Thanks
    Peter
     
    Peter Rait, Jun 15, 2008
    #1
    1. Advertising

  2. Andrew Thompson, Jun 15, 2008
    #2
    1. Advertising

  3. Peter Rait

    Roedy Green Guest

    On Sun, 15 Jun 2008 01:03:46 +0200, Peter Rait <> wrote,
    quoted or indirectly quoted someone who said :

    > .exec("rundll32 url.dll,FileProtocolHandler "+PDFName);


    two things to try

    1. just pass the name of the PDF file to exec. Make sure you have an
    association set up to a reader. See
    http://mindprod.com/jgloss/association.html

    2. pass the name of the PDF file as a parm to a command processor
    which you exec.

    3 that approach you are using wants an URL , not a filename
    eg. file://localhost/E:/mindprod/thing.pdf


    See http://mindprod.com/jgloss/exec.html
    for details.
    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Jun 15, 2008
    #3
  4. Peter Rait

    Roedy Green Guest

    On Sun, 15 Jun 2008 01:03:46 +0200, Peter Rait <> wrote,
    quoted or indirectly quoted someone who said :

    > .exec("rundll32 url.dll,FileProtocolHandler "+PDFName);


    For yet another approach see http://mindprod.com/jgloss/desktop.html

    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Jun 15, 2008
    #4
  5. Peter Rait

    Peter Rait Guest

    Hello Roedy,

    Roedy Green schrieb:
    > On Sun, 15 Jun 2008 01:03:46 +0200, Peter Rait <> wrote,
    > quoted or indirectly quoted someone who said :
    >
    >> .exec("rundll32 url.dll,FileProtocolHandler "+PDFName);

    >
    > two things to try
    >
    > 1. just pass the name of the PDF file to exec. Make sure you have an
    > association set up to a reader. See
    > http://mindprod.com/jgloss/association.html


    I think this is already in place as I have also a link in the program
    menu to a static PDF file which opens correctly.

    > 2. pass the name of the PDF file as a parm to a command processor
    > which you exec.


    If you mean:
    Runtime.getRuntime().exec("cmd.exe /c myfile.pdf");

    > 3 that approach you are using wants an URL , not a filename
    > eg. file://localhost/E:/mindprod/thing.pdf


    I changed my command to:
    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler
    File://"+myPDFPath);
    which works in my environment (XP).

    I will try the two options.

    Thank you for your help
    Peter
     
    Peter Rait, Jun 15, 2008
    #5
  6. Peter Rait

    Peter Rait Guest

    Andrew Thompson schrieb:
    > On Jun 15, 9:03 am, Peter Rait <> wrote:
    >
    >> ...find another solution?

    >
    > Java 6?
    > <http://java.sun.com/javase/6/docs/api/java/awt/
    > Desktop.html#open(java.io.File)>


    Thanks, but I do not want to require Java 6 installed on the PCs of the
    users getting my application. I will give the suggestions of Roedy Green
    a try.

    Peter
     
    Peter Rait, Jun 15, 2008
    #6
  7. Peter Rait

    Peter Rait Guest

    Lew schrieb:
    > Peter Rait wrote:
    >> Thanks, but I do not want to require Java 6 installed on the PCs of
    >> the users getting my application.

    >
    > Why not, now that Java 5 has entered its "End-of-Life" transition? By
    > what reasoning do you insist that your customers use obsolescent software?
    >


    Probably you are right, but as I do not know which OSs the users are
    running (NT4, w2000, XP, Vista..) I want to try the lowest level. They
    cannot even tell me which operating system they have as they have
    nothing to do with IT. They are just dieticians, physicians, pharmacists.

    Peter
     
    Peter Rait, Jun 15, 2008
    #7
  8. Lew wrote:
    > Peter Rait wrote:
    >> Thanks, but I do not want to require Java 6 installed on the PCs of
    >> the users getting my application.

    >
    > Why not, now that Java 5 has entered its "End-of-Life" transition?
    > By what reasoning do you insist that your customers use obsolescent
    > software?


    Other way around. He's not forbidding Java 1.6, he's just not
    requiring it.

    My company makes software that runs in containers (appservers and
    webservers), and it's just becoming feasible to include features that
    require 1.5 (yes, I meant to type 1.5). As an example, IBM builds a
    version of WebSphere to use the current JDK, which quite possibly
    won't be the newest one when that version of WebSphere is released.
    Then vendors target their applications to the current version of
    WebSphere. Finally, end-users buy WebSphere, purchase some
    applications, and run it until there's a good reason to upgrade. The
    result is that many WAS installations in the world are still running
    quite happily on JDK 1.4, and so long as they work and they can get
    support from IBM and their application vendors, will continue to do
    so.
     
    Mike Schilling, Jun 16, 2008
    #8
  9. Peter Rait

    Peter Rait Guest

    Peter Rait schrieb:
    > If you mean:
    > Runtime.getRuntime().exec("cmd.exe /c myfile.pdf");
    >
    >> 3 that approach you are using wants an URL , not a filename

    >
    > I changed my command to:
    > Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler
    > File://"+myPDFPath);



    Both approaches worked for Vista, so thank you very much for your hints.

    Peter
     
    Peter Rait, Jun 16, 2008
    #9
  10. On Jun 15, 9:03=A0am, Norm Rait <> wrote:

    > ...find another solution?


    Java 6?
    Desktop.html#open(disarray.io.File)>
    Desktop.html#edit(obedience.io.File)>
    Desktop.html#print(expansion.io.File)>

    --
    Evan T.
    http://pscode.org/


    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Matthew 10:34.
    "Do not think that I came to bring peace on the earth;
    I did not come to bring peace, but a sword.

    Luke 22:36.
    And He said to them,
    "But now, whoever has a money belt is to take it along,
    likewise also a bag,
    and whoever has no sword is to sell his coat and buy one."

    Matthew 10:35.
    "For I came to SET A MAN AGAINST HIS FATHER,
    AND A DAUGHTER AGAINST HER MOTHER,
    AND A DAUGHTER-IN-LAW AGAINST HER MOTHER-IN-LAW"

    Luke 14:26.
    "If anyone comes to Me,
    and does not hate his own father and mother
    and wife and children
    and brothers and sisters,
    yes, and even his own life,
    he cannot be My disciple."

    Revelation 14:10.
    "he also will drink of the wine of the wrath of God,
    which is mixed in full strength in the cup of His anger;
    and he will be tormented with fire and brimstone
    in the presence of the holy angels
    and in the presence of the Lamb."


    Malachi 2: 3-4: "Behold, I will corrupt your seed, and spread dung upon
    your faces.. And ye shall know that I have sent this commandment unto
    you.. saith the LORD of hosts."

    Leviticus 26:22 "I will also send wild beasts among you, which shall
    rob you of your children, and destroy your cattle, and make you few in
    number; and your high ways shall be desolate."

    Lev. 26: 28, 29: "Then I will walk contrary unto you also in fury; and
    I, even I, will chastise you seven times for your sins. And ye shall
    eat the flesh of your sons, and the flesh of your daughters shall ye
    eat."

    Deuteronomy 28:53 "Then you shall eat the offspring of your own body,
    the flesh of your sons and of your daughters whom the LORD your God has
    given you, during the siege and the distress by which your enemy will
    oppress you."

    I Samuel 6:19 " . . . and the people lamented because the Lord had
    smitten many of the people with a great slaughter."

    I Samuel 15:2,3,7,8 "Thus saith the Lord . . . Now go and smite Amalek,
    and utterly destroy all that they have, and spare them not; but slay
    both man and woman, infant and suckling.."

    Numbers 15:32 "And while the children of Israel were in the wilderness,
    they found a man gathering sticks upon the sabbath day... 35 God said
    unto Moses, 'The man shall surely be put to death: all the congregation
    shall stone him with stones without the camp'. 36 And all the
    congregation brought him without the camp, and stoned him to death with
    stones as Jehovah commanded Moses."
     
    Andrew Thompson, Jun 29, 2008
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TWFyaw==?=
    Replies:
    1
    Views:
    459
    Curt_C [MVP]
    Apr 13, 2004
  2. F. GEIGER
    Replies:
    3
    Views:
    813
    F. GEIGER
    Aug 6, 2004
  3. Isaac Gouy
    Replies:
    8
    Views:
    289
    Steven D'Aprano
    Mar 7, 2010
  4. Jon Prisbe
    Replies:
    0
    Views:
    153
    Jon Prisbe
    Feb 15, 2008
  5. Ricardo Pog
    Replies:
    1
    Views:
    488
    Austin Ziegler
    Mar 26, 2008
Loading...

Share This Page