Reputation: 110
I am new to java.I programmed my application in netbeans. Initially it was throwing error:
java.lang.OutOfMemoryError: Java heap space
So, i used -Xmx
option by right clicking the application->properties->Run->VMoption.
Now the program runs perfectly fine in my IDE, but i am trying to make jar file which i will distribute . I have made .jar file by "clean and build project" in netbeans. It creates the .jar file in dist folder but that jar file is not working as it should work. I am not getting any output for this application. Though i tested for other application where -xmx
parameter is not set, and it works perfectly fine.
Can anyone please tell me whats can be the issue? Also, how can i create my .jar file for this application?
Upvotes: 0
Views: 615
Reputation: 3720
You can't.
But there are many workarounds. The application must be started with
java -Xmx512M -jar myJar.jar
So your options are to use a wrapper such as launch4j, or make a shortcut to the jar where you add this -Xmx parameter, or you can actually write a piece of code that is executed when you write java -jar myJar.jar that will read a jar inside your jar and run that with the proper parameters. This last option is semi difficult.
Here's a blogpost about the latter option: http://silentdevelopment.blogspot.dk/2010/03/how-to-set-or-increase-xmx-heap-memory.html
Upvotes: 1