1

My JAR runs in a DOS shell like this

set MY_VAR=MY_VALUE
my_jar.jar MyClass

and in MyClass I code

String myValue = System.getenv("MY_VAR");
System.out.println("myValue = " + myValue); 

This works fine.

But now I must change in my DOS shell the value of MY_VAR from MY_VALUE to MY%VALUE.

set MY_VAR=MY%VALUE
my_jar.jar MyClass

I can't use this value because the '%' character has disappeared. I dump also myValue in my code to stdout:

myValue = MYVALUE

What is the cause for the disappearance of the '%' character and how can I set a value with '%' characters in the shell and use it in the Java code?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197

0 Answers0