2

I need to run command using Runtime.exec() :

java -cp .:/s/v-lib/* tDesigner -inRs /scg.rsp -out /g.plan;

here i need to add all the jars present in /s/v-lib directory to my class path. Do i need to add them individually?

tDesigner is my class.
-inRs /scg.rsp -out /g.plan are the arguments to the class.

what will be the correct way to construct command string?
is this correct:

String[] command = {"java", "-cp", ".:/s/v-lib/*", "tDesigner" ,"-inRs", "/scg.rsp" ,"-out", "g.plan"};
Tim Bender
20.5k2 gold badges52 silver badges59 bronze badges
asked Oct 16, 2012 at 6:34
1
  • Usually it's best to stick to a single question per ... well, question. I see two here: One about classpaths, the other about Runtime.exec. Commented Oct 16, 2012 at 6:40

1 Answer 1

1

The invocation of exec() looks correct.

Regarding the classpath, since java 1.5 you may specify a directory (rather than jars) in the classpath, in which case all jars found there are added to the classpath.

Joey
357k88 gold badges705 silver badges700 bronze badges
answered Oct 16, 2012 at 6:40
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.