Hello,
  I'm not 100% sure of what I'm saying as I'm not a DOS guru!
  The DOS commands that can run from a JVM in separate processes should be a
stand alone application. Meaning .com or .exe "binary" .bat also works.
  I believe this is not the case for dir, and copy as they are only, I'm not
sure, built-in DOS commands that are interepreted from a DOS shell and
cannot run alone as a process or application. The DOS shell is itself the
process.
  For the DOS commands that are applications, see the director
....\windows\command For example edit.com, xcopy.exe will work.

                Runtime rt = Runtime.getRuntime();
                rt.exec("c:\\windows\\command\\Edit.com");

  As a work arround for your needs, I suggest you create a batch file that
contains the DOS commands you need to execute, and run this batch file from
your Java code.
                Runtime rt = Runtime.getRuntime();
                rt.exec("c:\\test.bat");
  test.bat contains the DOS commands.
  This solution worked with me!

Regards,
Ahmed Aboul-Enein

Software Engineer
Lucent Software Center in Egypt,
Wireless Network Group,
Lucent Technologies Inc.,
1 Road 204, Salah Salem Square,
Degla, Maadi 11435, Cairo, Egypt
e-mail: [EMAIL PROTECTED]

Say what you do and do what you say!


-----Original Message-----
From: Padmakar Neelapareddy [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 09, 2001 8:29 AM
To: [EMAIL PROTECTED]
Subject: Running dos native commands from java application...


Dear All,

I need to execute DOS native commnads such as "dir","copy","copy x.txt >
prn".......etc
from inside a java application.

I tried them using following code

Runtime rt = Runtime.getRuntime();
 rt.exec("dir");
 rt.exec("copy x.txt > prn");

But I got following exception

java.io.IOException: CreateProcess: dir error=2
        at java.lang.Win32Process.create(Native Method)
        at java.lang.Win32Process.<init>(Unknown Source)
        at java.lang.Runtime.execInternal(Native Method)

Can any one help me regarding this please ? I want it
urgently...................!

Waiting for your valuable replies........

Rgds
padmakar neelapareddy


The information in this message is confidential and may be legally
privileged. It is intended solely for the addressee. Access to this message
by anyone else is unauthorized. If you are not the intended recipient, any
disclosure, copying, or distribution of the message, or any action or
omission taken by you in reliance on it, is prohibited and may be unlawful.
Please immediately contact the sender if you have received this message in
error.

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
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".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
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

Reply via email to