No, it works. You can execute java.exe from within java.exe.
I just tried it with the following program:
import java.io.*;
public class TestProcess {
public static void main(String[] args) throws IOException {
String s = null;
String[] cmdArray = null;
if(args.length < 1) {
System.out.println(
"You must give atleast one argument as the command to execute");
System.exit(0);
} else if(args.length > 0) {
cmdArray = args;
}
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(cmdArray);
BufferedReader br = new BufferedReader(
new InputStreamReader(
p.getInputStream()));
if(br != null) {
while( (s = br.readLine()) != null) {
System.out.println(s);
}
}
}
}
And to test it, give arguments on the command line, like:
java TestProcess java HelloWorld
It worked for me, so you can definitely invoke java.exe from within java.exe
Shireesh Thanneru
On Thu, 2 Nov 2000, Daryani Santosh wrote:
>I too played around with this for a while , trying to invoke java.exe from
>within java.exe and it does'nt seem to work. I was able to call all other
>applications using runtime exec but not java itself , I don't think its
>possible , not any way that I know of. I'd like to know if it there is a way of
>doing it .
>
>Santosh
>
>
>
>
>
>
>
>Santiago Benito Rebollo <[EMAIL PROTECTED]> on 11/02/2000 10:25:19 AM
>
>Please respond to A mailing list about Java Server Pages specification and
> reference <[EMAIL PROTECTED]>
>
>To: [EMAIL PROTECTED]
>cc: (bcc: Santosh Daryani/IT/Aon Consulting)
>
>Subject: Re: Execute aplication in other process
>
>
>
>Thanks. It works fine, buts I have a problem when I try to run java class
>files.
>
>For example,
>
>this works:
>c:/jdk1.2.2/bin/java Mensajeria
>
>but this doesn't work
>
>c:/jdk1.2.2/bin/java -cp c:/Temporal/ProcesosBatch;%CLASSPATH% Mensajeria
>(in dos window, it always work)
>
>
>Do you know how i can do it?
>
>Thanks for all.
>
>
>>
>> Hi,
>>
>> First get the Runtime object then use its exec method to run your .exe
>> application.
>>
>> Runtime r = Runtime.getRuntime();
>> r.exec("notepad");
>>
>> Note : notepad.exe should be in the system Path.
>>
>> Hope this helps you.
>>
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets