Wildcard in Jar name

1.4k Views Asked by At

I am running one jdk command in window batch file as:

javaw -Xms256M -Xmx1024M -Dspring.profiles.active=local -Dport=9001 -jar C:\Users\sampleJAR\myProj-1.0.0.jar

But, every 2 weeks we will have new version coming up and old jar will be replaced by new jar automatically so I was thinking to use wildcard with something like:

javaw -Xms256M -Xmx1024M -Dspring.profiles.active=local -Dport=9001 -jar C:\Users\sampleJAR\myProj-*.jar

I referred lots of articles online which suggested to use *, surround jar name with "" when using *,... None of them worked.

1

There are 1 best solutions below

2
timl On

I believe that the articles you are looking at are in reference to the classpath option wildcard expansion.

The -jar option doesn't do this wildcard expansion and expects a filename without any wildcards.

You could try specifying the classpath with the wildcard and then putting the class name that you want to run at the end of the command. Hopefully like:

javaw -Xms256M -Xmx1024M -Dspring.profiles.active=local -Dport=9001 -cp "C:\Users\sampleJAR\*" com.my.classname