This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 19655
    
  18

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: 38045
    
  22
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
 
Similar Threads
Communication from Java to Javascript
classpath issue jdbc-applet
Ragarding manifest.mf
How can i tell if a resultset is empty?
Ant Build Failing -- Need a way to pick jar file during run time.