Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I stop Java program arguments being mistaken for VM arguments?

Inside a bat file I have the following:

java -Ddatabase.host=127.0.0.1 -Xms128M -Xmx1024M com.temp.util.manual.serial.Assignment -folder C:\temp\ -destination C:\temp\out.csv

The -folder and -destination params are supposed to be passed to the main method of the Assignment class being called, but instead they are being interpreted as VM Args.

I tried putting quotes around the params to no avail, and searching does not reveal an answer.

I get the following error:

Unrecognized option: -'destination'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Press any key to continue . . .

@echo off
setlocal EnableDelayedExpansion EnableExtensions 
set FILETYPE=%~n0
set CLASSPATH=jar1.jar
set CLASSPATH=%CLASSPATH%;anotherjar.jar
echo %CLASSPATH%
java -DjobName=%FILETYPE% -Ddatabase.host=127.0.0.1 -Ddatabase.name=db1 -Ddatabase.username=user1 -Ddatabase.password=password1 -Xms128M -Xmx1024M com.temp.util.manual.serial.Assignment -folder C:\\temp\\ -destination C:\\temp\\out.csv
call Cleanup.bat
endlocal
like image 529
lucas.bennett Avatar asked Dec 02 '14 15:12

lucas.bennett


1 Answers

I think your issue has more to do with passing in variables. Remove EnableDelayedExpansion EnableExtensions

like image 71
dmacke Avatar answered Nov 01 '22 23:11

dmacke