senex_subconscious
senex_subconscious

Reputation: 241

Heap Space Issue outside Netbeans IDE

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

I'm running 32 bit Java 1.8.0_40 on Windows 7.

I have created a program in Netbeans 8.0 and adjusted the VM Options to be -Xms512m -Xmx2048m.

The program runs quite well inside the Netbeans IDE environment, however upon trying to run the program outside of Netbeans I encounter a heap space out of memory error.

EDIT: I am launching the program via the .jar file that Netbeans creates for the project upon compilation.

I have gone to the Java control panel and applied the same "-Xms512m -Xmx2048m" information to the Runtime Parameters. I am still encountering the heap space out of memory error.

Any suggestions? Where can I go from here? Have I missed a step in making sure there is enough memory in the Runtime Environment outside of Netbeans?

Upvotes: 3

Views: 274

Answers (3)

senex_subconscious
senex_subconscious

Reputation: 241

I did a combination of the two answers. It ended up being that I had to use a fully qualified name enclosed in quotations to execute the command and since others will be using this program I was able to create a .bat file to do so. The final .bat file ended up looking like this:

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

Thank you to both Jorge_B and Sanj for your help! Hopefully this will help other in the future!

Upvotes: 1

Jorge_B
Jorge_B

Reputation: 9872

Since you are building an independent JAR file, it looks like there is not a clean way to include such options inside your JAR (some people have asked about it here and here without a definitive answer). When in your case, my solution is usually to give away a little shell script with the proper -Xms and -Xmx arguments, along with my JAR file.

Upvotes: 2

Sanj
Sanj

Reputation: 850

The VM options you use in netbeans can also be used on the command line i.e

java -Xms512m -Xmx2048m  -jar yourprg.jar

There are more JVM options available.

Upvotes: 4

Related Questions