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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

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

manpatil
1-Visitor

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

lmouchard
12-Amethyst
(To:manpatil)

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

Announcements

Top Tags