1
java -cp %EPM_JAVA_CLASSPATH% -DEPM_ORACLE_INSTANCE=%1 -DHFM_CLUSTER=%2 -DHFM_APPLICATION=%3 runConsoltesting %4 %5 %6 %7

When i try to access 5th argument it shows:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
at runConsoltesting.main(runConsoltesting.java:42)

It takes only arguments upto class name

2
  • 1
    Try quoting all the % arguments. Commented May 13, 2021 at 10:07
  • You only pass four arguments to the main class: %4 %5 %6 %7 (if nonempty) will be args[0] args[1] args[2] args[3] respectively. The -Dname=value before the classname are arguments and more exactly options to the JVM but not to the main class. Commented May 13, 2021 at 11:19

1 Answer 1

1

Whatever given after main class runConsoltesting are main method arguments which are totally 4 (%4,%5,%6,%7). So you are getting ArrayOutOfBoundException when you try to access fifth element.

%1, %2 and %3 are JVM arguments and NOT java main method arguments. So these can be read in code as below.

System.getProperty(String property), here property is name of your -D argument.

For example, System.getProperty("EPM_ORACLE_INSTANCE") will return the value which is set for place of %1.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.