Running jars with a dropped file on the fly

I want to drag a file into a .bat file. After I dropped it, I want to run the jar file with the remote file path as input. How can I run jar file with relative path? The dir my.bat file is running - this is my user directory, not the directory where it is located.

goal: cmd /c java -jar myjar.jar -f %1
current: cmd /c java -jar c:\somewhere\myjar.jar -f %1

The fact is that the program (jar + bat) is part of a small automated deployment process, and for each user there may be a different way to launch jar.

+3
source share
1 answer

Maybe this works, it changed the current directory to the batch file path

pushd "%~dp0"
cmd /c java -jar myjar.jar -f "%~1"
+3
source

All Articles