1

I am running a jar which reads from properties in code. Now i want to set few variables at environment level and pass them as command line arguments to override properties. How can i do that?

ex:

java -jar test.jar  --server.http.host-url=https://x.com

in the above command, property value server.http.host-url is set as env variable with name "server.http.host.value". how do i pass it as variable so it will resolved from env variables like this

java -jar test.jar  --server.http.host-url=${server.http.host.value}
1
  • You can create a shell or bat script based on your os. Fetch those property values from the script and start the jar. Commented Sep 16, 2020 at 10:15

1 Answer 1

4

Depending on the shell you are using the environment variable names might have different restrictions, but in most cases . is not allowed so name your variable something like SERVER_HTTP_HOST_VALUE for example and use it like this:

java -jar test.jar --server.http.host-url=$SERVER_HTTP_HOST_VALUE
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.