cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How to execute multiple commands one by one on command prompt using JAVA.

manpatil
Newbie

How to execute multiple commands one by one on command prompt using JAVA.

Hi,

i have used,

Process p = Runtime.getRuntime().exec("cmd /c \"start sqlplus system/manager && CREATE OR REPLACE DIRECTORY export_dir AS 'E:\';\"");

application connected to oracle database successfully using command sqlplus system/manager. but second command CREATE OR REPLACE DIRECTORY export_dir AS 'E:\';

does not work as shown in Image attached. Plz let me know how to execute multiple commands on cmd.exe one by one . Please check syntax to run multiple commands in Process p = Runtime.getRuntime().exec("cmd /c \"start sqlplus system/manager && CREATE OR REPLACE DIRECTORY export_dir AS 'E:\';\"");

Thanks

Manoj

3 REPLIES 3

Re: How to execute multiple commands one by one on command prompt using JAVA.

image.jpg

Re: How to execute multiple commands one by one on command prompt using JAVA.

Hi Manoj,

why do you try in java to start sqlplus from the command windows? Wouldn't it be easier to call sqlplus directly from java?

I suppose you'll have to group your 2 main commands, so the start apply to them:

Process p = Runtime.getRuntime().exec("cmd /c \"start (sqlplus system/manager && CREATE OR REPLACE DIRECTORY export_dir AS 'E:\';) \"");

Loïc

Re: How to execute multiple commands one by one on command prompt using JAVA.

Hello,

this is a new feature in java 9 and is not released till now.

Ciao

Leo

Announcements