0

I'd like to retrieve some arguments passed from the command line. The problem is that it is not work as expected:

java -jar target/gs-rest-service-0.1.0.jar -Dhello=hello

System.out.println(System.getProperties()); // return a propertie obj with Dhello parameter inside.

So now, when i try to get the value:

  System.getProperties().getProperty("hello")); // return null
    System.getProperties().getProperty("-Dhello")); // return null 
    System.getProperty("hello"); // return null 
    System.getProperty("-Dhello")); // return null

I'm fighting with that since 2 hours. This is begin to be irritating.

Note: This is not working because Java cl is not clever to pass the parameter as a property. So instead of giving me a key/value hello=hello, it give me the full command without separation: target/gs-rest-service-0.1.0.jar -Dhello=hello (which I get from "sun.java.command" key). So i can't retrieve my parameter.

Mr Bonjour
  • 3,330
  • 2
  • 23
  • 46

0 Answers0