0

Hi,Someone please shade somelight about this-
how arguments are to be passed from a run.bat file
Thanks
Best Regards
Bethuel

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by thines01
0

Arguments in batch files are passed on the command-line.
Inside the batch, you use %1, %2, %3, etc. to receive each argument.

0

SET CLASSPATH_JARS=../../lib/log4j/log4j-1.2.14.jar

SET BUILD_CLASS_DIR_IMPLEMENTATION=BUILD_LOCAL\implementation\build\classes

SET RUN_CLASSPATH=%BUILD_CLASS_DIR_IMPLEMENTATION%;%CLASSPATH_JARS%
SET CLASS_TO_RUN=chepsoft.micro.javadoc.workerapplication.WorkerApplication

SET ARGUMENTS=Worker implementation by WorkerImpl

ECHO CLASSPATH_JARS=%CLASSPATH_JARS%

ECHO BUILD_CLASS_DIR_IMPLEMENTATION=%BUILD_CLASS_DIR_IMPLEMENTATION%

ECHO RUN_CLASSPATH=%RUN_CLASSPATH%

ECHO CLASS_TO_RUN=%CLASS_TO_RUN%

java -classpath %RUN_CLASSPATH% %CLASS_TO_RUN% %ARGUMENTS%
%1String name = "Bethuel", %2String workerType = "Monthly Employee", %3double salary = 22000d,
if i want to pass the above variables from run.bat file instead of main() method where should insert them in my code of bat file.

0

So, in this example, some values are passed by %1 and %2, etc. and some are SET through environment variables.

If this is called Run.bat, you would (at the command-line) type:

Run Bethuel "Monthly Employee" 22000d

...but inside the batch file, the call the program would be
java -classpath %RUN_CLASSPATH% %CLASS_TO_RUN% %1 %2 %3

The %ARGUMENTS% variable is redundant depending on how you want to use them.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.