🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #7985

Re: Getting Def

#7985
From: Valentino Kyriakides
Date: Mon, 07 May 2001 16:26
83 lines
3827 bytes
You can use a try/catch block similar to the following shown code fragments:

...
try
  {
      if (windows)
      {
          // cmd = prog args or rundll etc.
           cmd = WIN_PATH + " " + WIN_FLAG + " " + args;
           Process p = Runtime.getRuntime().exec(cmd);
       }
       else
       {

           // UNIX cmd = prog args
           cmd = UNIX_PATH + " " + UNIX_FLAG;
           Process p = Runtime.getRuntime().exec(cmd);

             try
              {
                 // wait for exit code -- if it's 0, command worked,
                 // otherwise we need to start the related prog up.
                  int exitCode = p.waitFor();

                  if (exitCode != 0)
                  {
                     // Command failed, start up the prog

                     // cmd = 'prog options'
                     cmd = UNIX_PATH + " " + args;
                      p = Runtime.getRuntime().exec(cmd);
                   }
               }
               catch(InterruptedException x)
                {
                    System.err.println("yourappname: Error bringing up
prog='" + cmd + "'");
                    System.err.println("yourprog: Caught: " + x);
                }
           }



Valentino


"Erwin Olaerts" <erwin.olaerts@idp.be> schrieb im Newsbeitrag
news:3af64909_1@dnews...
> Thanks a lot for pointing me out the problems of using CMD. I changed it
to
> what you proposed. But I still have one question.
> Is there a way to find out if no program is linked with a certain type of
> files. What I mean is, let's say there is no PDF reader, at this moment I
> get a windows message. But I want to catch this in my program, so I can
show
> my report on another way.
> How can I do this ???
>
> "John McGrath [TeamB]" <ng-b@JPMcGrath.net> schreef in bericht
> news:MPG.155d7bb8708a9f3e98a19f@forums.borland.com...
> > On Sat, 5 May 2001 02:56:10 -0400, John McGrath  [TeamB] wrote:
> >
> > >  Runtime.getRuntime().exec("cmd /c Start filename.pdf");
> > >
> > >  Runtime.getRuntime().exec( new String[] { "rundll32",
> > >     "url.dll,FileProtocolHandler", fileName } );
> >
> > One more problem with using CMD:  If your file name has spaces in it,
> > this is going to really muck things up.  There may be some way to set
> > up the command line properly, but at least my first few attempts at
> > doing this from the command line failed.  Spaces are not an issue with
> > the rundll32 method.
> >
> > --
> > Regards,
> >
> > John McGrath [TeamB]
> >
> > ---------------------------------------------------
> > Before sending me e-mail, please read:
> >     http://www.JPMcGrath.net/newsgroups/e-mail.html
>
>
Technical Details
Message-ID: <3af6cd62_2@dnews>
Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-02!supernews.com!bignews.mediaways.net!news0.de.colt.net!news-fra1.dfn.de!news-lei1.dfn.de!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews
References: <3af165f4_2@dnews> <MPG.155bfe5339e0223c98a18f@forums.borland.com> <3af29d21_2@dnews> <MPG.155d66295a54734398a19a@forums.borland.com> <MPG.155d7bb8708a9f3e98a19f@forums.borland.com> <3af64909_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,23c4ef4f8da51747
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-05-07 09:49:36 PST
From: "Valentino Kyriakides" <vkyr@nospamlavielle.com>
Newsgroups: borland.public.jbuilder.java.language
References: <3af165f4_2@dnews> <MPG.155bfe5339e0223c98a18f@forums.borland.com> <3af29d21_2@dnews> <MPG.155d66295a54734398a19a@forums.borland.com> <MPG.155d7bb8708a9f3e98a19f@forums.borland.com> <3af64909_1@dnews>
Subject: Re: Getting Def
Date: Mon, 7 May 2001 18:26:20 +0200
Lines: 85
Organization: ISION
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
NNTP-Posting-Host: 194.64.62.36
Message-ID: <3af6cd62_2@dnews>
X-Trace: dnews 989252962 194.64.62.36 (7 May 2001 09:29:22 -0700)
Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-02!supernews.com!bignews.mediaways.net!news0.de.colt.net!news-fra1.dfn.de!news-lei1.dfn.de!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews