I want to set Java heap size permanently and don't want to run every jar file with options. I use Windows and Java 1.7.
2 Answers
Setup JAVA_OPTS as a system variable with the following content:
JAVA_OPTS="-Xms256m -Xmx512m"
After that in a command prompt run the following commands:
SET JAVA_OPTS="-Xms256m -Xmx512m"
This can be explained as follows:
- allocate at minimum 256MBs of heap
- allocate at maximum 512MBs of heap
These values should be changed according to application requirements.
EDIT:
You can also try adding it through the Environment Properties menu which can be found at:
- From the Desktop, right-click My Computer and click Properties.
- Click Advanced System Settings link in the left column.
- In the System Properties window click the Environment Variables button.
- Click New to add a new variable name and value.
- For variable name enter JAVA_OPTS for variable value enter -Xms256m -Xmx512m
- Click ok and close the System Properties Tab.
- Restart any java applications.
EDIT 2:
JAVA_OPTS is a system variable that stores various settings/configurations for your local Java Virtual Machine. By having JAVA_OPTS set as a system variable all applications running on top of the JVM will take their settings from this parameter.
To setup a system variable you have to complete the steps listed above from 1 to 4.

- 5,529
- 2
- 33
- 57
Try setting a Windows System Environment variable called _JAVA_OPTIONS
with the heap size you want. Java should be able to find it and act accordingly.

- 4,674
- 9
- 44
- 74
-
How to format that variable value please ?.. – Saddam Meshaal Dec 13 '21 at 19:55