How do I set the maximal jvm-memory without adding an extra batch-script to my Programm.
Answer is provided below.
How do I set the maximal jvm-memory without adding an extra batch-script to my
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s a good question, but your implmenetation assumes a lot. I presume you have to document the name of your jar for your users to invoke “java -jar xyz.jar” on so can you also include in the documentation that “-Xmx256M” is required?
You may have more luck using a java launcher, such as this one for Windows, where you put the launcher config (path, max memory etc.) in a separate file. For cross platform, there’s LaunchAnywhere, and others, which function similarly. See How can I convert my Java program to an .exe file?
To improve upon your existing scheme:
java.homesystem property to resolve the location of the JDK/JREjava.class.pathto set up the class path, and similarly forjava.library.pathif your application requires native code.But still, this seems to be a lot of effort that at best represents a leaky abstraction, when instead simple and clear documentation would suffice.