Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Execute DOS command inside java

807580Mar 23 2010 — edited Mar 24 2010
hi,

my application need that some operations (environment variables are stetted, and a database server manager)
are executed before it runs.

If I use a DOS window to realize manually this purpose the application works fine.
I would, however, that the application runs automatically without these operations are manually made.

For realize this purpose I would that some .bat files are made execute from the java code,
and I tried to do it in this way:
        String command = "C:\\path\\commandFile.bat";

        Runtime runtime = Runtime.getRuntime();
        try {
            runtime.exec(command );
            System.out.println("Ok !!! : ");
        } catch (IOException ex) {
        System.out.println("IOexception : " + ex.getMessage());
but I didn't get any result
(i.e. neither a DOS window raised, neither the server started)

I would like have some help about how to do it..

any help is welcome.

thank you, regards

tonyMrsangelo.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 21 2010
Added on Mar 23 2010
14 comments
443 views