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

We are happy to announce the new Windchill Customization board! Learn more.

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

manpatil
1-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

image.jpg

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

Hello,

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

Ciao

Leo

Top Tags