This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes How to increase Jar heap space in Linux Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "How to increase Jar heap space in Linux" Watch "How to increase Jar heap space in Linux" New topic
Author

How to increase Jar heap space in Linux

Hesham Gneady
Ranch Hand

Joined: Feb 26, 2007
Posts: 66
Hi everyone ,

After creating my executable jar program, i used Launch4J to convert it to exe file + to increase the reserved Heap space for the program in windows O.S.

Now in Linux and other operating systems i use only the executable jar file and i can't find a way to increase the reserved Heap space for my program, so i'll get "Out of memory" error.

Is their a way to overcome this like the solution mentioned for windows O.S ?

Thanks ,
Hesham


Hesham
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32654
    
    4
Have a look through the java tool documentation, particularly the -Xmx and -Xms options, which allow you to alter the possible heap memory use. That might help. It should work the same on any operating system.
Moojid Hamid
Ranch Hand

Joined: Mar 07, 2009
Posts: 120
You can either write a shell scrip to launch the JVM with increased heap size or use webstart.

EDIT:

Apparently launch4j that you used for WinOS also works on Linux and Solaris also. Check out http://launch4j.sourceforge.net
Hesham Gneady
Ranch Hand

Joined: Feb 26, 2007
Posts: 66
Apparently launch4j that you used for WinOS also works on Linux and Solaris also.


As i understood ... "launch4j" has a Linux,mac & Solaris versions but it is going to create an (*.exe) file too in these operating systems.
I think there'll be no other way than to create a script file for every O.S.
Hesham Gneady
Ranch Hand

Joined: Feb 26, 2007
Posts: 66
particularly the -Xmx and -Xms options, which allow you to alter the possible heap memory use


I think that's what Launch4J does in windows O.S. I didn't read about it but i think they create a batch file inside the (exe) sending the memory parameters you mentioned through it to the JVM. But how to do that for other operating systems except in a script file for each O.S ?

I thought of creating a small jar file defining those parameters in it + call my program jar file .... But that would be very bad
What do you think ?
Moojid Hamid
Ranch Hand

Joined: Mar 07, 2009
Posts: 120
Starting two JVMs could significantly increase startup time and memory requirements. I think shell script is not such a bad idea especially taking into consideration how common scripts are in Linux world. There is another launcher called Jnix that is compatible to Launch4j but I have no experience of using it, it might be worth a try.
Hesham Gneady
Ranch Hand

Joined: Feb 26, 2007
Posts: 66
Thanks a lot Moojid for your help.
It's my first time to hear about Jnix ... I tried it and created the script so easily.
I am just waiting to install Linux O.S to try it out, but i'm sure it'll work fine.

So thanks again for the help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to increase Jar heap space in Linux
 
Similar Threads
running java program as service
Executable Jar File
why jre after exe produced
How to run a commandline command from a java program
Looking for wrapper/installer for all platforms