How to pass an environment variable as a part of a command

ram kumar :

I am trying to run a jar which needs to be passed args value. How to pass an environment variable as args for the java in windows

Example:

Set OUT = hi

java -jar something.jar OUT

How to send this OUT an ideas??

Elliott Frisch :

Option 1: What you asked for, use %VARIABLE% to access the variable (quote it to allow spaces)

java -jar something.jar "%OPT%"

Option 2: Read the environment variable with Java. And skip using the command line option

String outValue = System.getenv().get("OUT");

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=28896&siteId=1