• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Running java jar with ram of 2GB

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To specify the memory settings you can use -Xmx and -Xms. -Xms specifies the minimum heapsize and -Xmx specifies the maximum size.
 
Jacob Sonia
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That way you're giving the parameters as application parameters and not as jvm parameters. The correct syntax is:
java -jar -Xmx2048m foo.jar
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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!
 
He got surgery to replace his foot with a pig. He said it was because of this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic