aspose file tools*
The moose likes Java in General and the fly likes Running java jar with ram of 2GB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Running java jar with ram of 2GB" Watch "Running java jar with ram of 2GB" New topic
Author

Running java jar with ram of 2GB

Jacob Sonia
Ranch Hand

Joined: Jun 28, 2009
Posts: 174
Hi, i want to run a jar from the command line and i want to specify that it needs 2 GB of memory
i think -Dkey=value would help me, but i don't know what should be the key in this case
i believe value would be -Xmx2048m

Please help
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

To specify the memory settings you can use -Xmx and -Xms. -Xms specifies the minimum heapsize and -Xmx specifies the maximum size.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Jacob Sonia
Ranch Hand

Joined: Jun 28, 2009
Posts: 174
But how do i set it
i mean is it just java jar foo.jar -Xmx2048m

for me it didn't work this way
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

That way you're giving the parameters as application parameters and not as jvm parameters. The correct syntax is:
java -jar -Xmx2048m foo.jar
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19785
    
  20

A 32-bit JVM cannot use more than 1.5GB of memory, at least on Windows. If you need more you will need to switch to a 64-bit JVM on a 64-bit Windows machine. This is not a limitation of the JVM but of Windows. I'm not sure if Linux has the same limitation.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
Rob Prime wrote:. . . I'm not sure if Linux has the same limitation.
It hasn't on my laptop; Fedora will happily use -Xmx2048M, but not -Xmx3072M. Maybe if I had paid a bit more and got more than 2GB RAM it would accept 3072!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Running java jar with ram of 2GB