Skip to content
Advertisement

How to make a parameter override while running a Java jar file?

I have a Java maven project whose Jar file is used as a SDK library in other projects. This SDK is used to call other APIs which are by default in the prod environment. I want to make it run on testing environment by overriding a variable.

JavaScript

This is the Routes class which contains the base URL for prod/testing is used by other classes. I want to have the default _baseUrl as the same one as above. But I want to be able to override it to "https://testing-env.com" while running the Jar. And I don’t want to add a public setter for that. I want to be able to do so by passing some arguments while running the Jar file.

Advertisement

Answer

As @Thomas mentioned in comment:

JavaScript

Set property when executing jar

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement