Article View: borland.public.jbuilder.java.language
Article #15228Re: Running External Programs
From: Steve Horsley
Date: Wed, 07 Jul 1999 00:00
Date: Wed, 07 Jul 1999 00:00
60 lines
2420 bytes
2420 bytes
Here is a class that launches a jar file I had lying around on my PC:
class Executor {
public static void main(String[] args) {
Runtime r = Runtime.getRuntime();
try {
r.exec("javaw -jar e:\\java\\projects\\McTest.jar");
System.out.println("done it!");
}
catch (java.io.IOException ioe) {
System.out.println("IO Exception:" + ioe);
}
}
}
Steve.
//----------------------------------
Hakan UNLU wrote:
>
> You cannot launch a jar file.
> If you need to run this jar file
> 1. define it in your classpath.
> 2. call it main method of the desired entry class.
>
> If you want to run two applications simultaneously you can initiate another
> thread.
>
> Runtime.Exec is only for executable files like .EXE files in Windows.
>
> Hope this helps.
>
> --
> Hakan UNLU
> Hitit Computer Services
> -------------------------------------------------------------
> Visit my virtual bookstore at
> http://surf.to/hakan-books
> ------------------------------------------------------------
> Matt DeBoer <mjd1@midwestlabs.com> wrote in message
> news:378224C3.D8289CE4@midwestlabs.com...
> > Im trying to launch another .jar file from within a java program.
> > here is the statement i have used so far
> >
> > Runtime exec("C:/Windows/Desktop/TEST.jar")
> >
> > and these errors returned
> >
> > Error: non-static method exec(java.lang.string) cannot be referenced
> > from a static context.
> > Error: unreported exception: java.io.IOException; must be caught or
> > declared to be thrown.
> >
> >
> > If some one could tell me all the steps to getting a statement like this
> > to work (such as imports, declarations, anything) I would really
> > appreciate it.
> >
> > Matt
> >
Technical Details
Message-ID:
<37832241.8B0E92AC@cwcom.co.uk>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<378224C3.D8289CE4@midwestlabs.com> <7lurds$e249@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,d207c7dd6be77e9d X-Google-Attributes: gidf74b3,public From: Steve Horsley <steve.horsley@cwcom.co.uk> Subject: Re: Running External Programs Date: 1999/07/07 Message-ID: <37832241.8B0E92AC@cwcom.co.uk> X-Deja-AN: 498087664 Content-Transfer-Encoding: 7bit References: <378224C3.D8289CE4@midwestlabs.com> <7lurds$e249@forums.borland.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Cable & Wireless Communications Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language