I am completely new to Windows batch programming. I want to achieve a startup script for a Java application. However, it does not start the Java application, but prints
Usage: java [-options] class [args ...]
(to execute the class)
or java [-options] -jar jarfile [args ...]
(to execute jar file)
...
which indicates that my settings are not correctly recognized.
Here is my MCVE for a broken script:
set memory=600000 java -XX:OnOutOfMemoryError="taskkill /PID %p" -Xmx%memory%K -jar MyApp.jar
In a real scenario, memory
calculated to set the optimal maximum heap size for the application.
Leaving one of two parameters, the application starts. So
java -XX:OnOutOfMemoryError="taskkill /PID %p" -jar MyApp.jar
and
set memory=600000 java -Xmx%memory%K -jar MyApp.jar
works, but I need both parameters to work in one call.
source share