Heap space problem outside Netbeans IDE

EDIT: I ended up doing a combo of both suggested answers and thus answered my own question, it is accepted below, hopefully this helps others in the future!

I am running Java 1.8.0_40 32 bit on Windows 7.

I created a program in Netbeans 8.0 and adjusted the VM parameters for -Xms512m -Xmx2048m.

The program works quite well inside the Netbeans IDE, however, when I try to run the program outside of Netbeans, I encounter an out of memory error.

EDIT: I am running the program through the .jar file that Netbeans creates for the project when it compiles.

I went to the Java Control Panel and applied the same "-Xms512m -Xmx2048m" information to the runtime parameters. I am still facing out of memory error.

Any suggestions? Where can I go from here? Did I miss a step in making sure there is enough memory in a runtime outside of Netbeans?


source to share

3 answers

I made a combination of the two answers. In the end, it turned out that I needed to use the fully qualified name enclosed in quotes to execute this command, and since others will be using this program, I was able to create a .bat file for this. The final .bat file looked like this:

java -Xms512m -Xmx2048m -jar "T:\Netbeans Projects\DataLoader\dist\DataLoader.jar"


Thanks to both Jorge_B and Sanj for your help! Hope this helps others in the future!



The VM options you use in netbeans can also be used from the command line ie

java -Xms512m -Xmx2048m  -jar yourprg.jar


Available JVM Options .



Since you are creating an independent JAR file, it looks like there is no clean way to include such options in your JAR (some people have asked this here and here with no definitive answer). When in your case, my solution usually outlines a small shell script with the correct -Xms and -Xmx arguments along with my JAR file.



All Articles