I have a java project which I'm running in the command line. I have created a .bat file to run the project. However my java project must take in 4 arguments before it starts running which works like this in my .bat
file....
@echo off
pushd %~dp0
java -jar dist/prog.jar 5 6 7 3
pause
(5 6 7 3 being the arguments passed to String[] args)
However, I do not want to input the specific arguments to be passed to String[] args
in the .bat
file, I want it to be passed by user input so that I can enter in different values as my arguments in the command line each time I run it. How can I do this?
You can use % replacements to pass in the parameters given to the .cmd
@echo off
pushd %~dp0
REM %* forwards all parameters
java -jar dist/Election_real.jar %*
pause
And then call yourcmd.cmd 5 6 7 8
If you want to ask for these parameters, you'd go
@echo off
pushd %~dp0
set /p nr1=Enter Nr1:
set /p nr2=Enter Nr2:
set /p nr3=Enter Nr3:
set /p nr4=Enter Nr4:
java -jar dist/Election_real.jar %nr1% %nr2% %nr3% %nr4%
pause
Este artigo é coletado da Internet.
Se houver alguma infração, entre em [email protected] Delete.
deixe-me dizer algumas palavras