I want to get a date from a key dynamically which will be used by java program to perform some tasks.
I have to get values from property file to java. cannot do vice versa
So basically the value for this key, job.date=2022-03-23 i can get through date -d tomorrow " %Y-%m-%d". But this works fine when job.date is accessed from shell script and gives a parsing error when accessed from java class.
so looking for java understandable snippet, or a way to override it while executing the java class with jar
CodePudding user response:
You should use (if this is the property and value you want)
java -Djob.date=$(date -d tomorrow "%Y-%m-%d") ...
CodePudding user response:
java -Djob.date=$(date -d tomorrow "%Y-%m-%d") ...
The above gave me exception, error loading main class.
It worked with following snippet:
sed -i "s/(testauto.as.of.date=).*$/\1${tomorrow}/" abc.properties
Added this line in shell script that was calling the java class.