70

Is there a way to specify default JVM arguments when I'm running my code from eclipse, rather than specifying the same ones over and over for each run/debug/etc configuration?

Thomas Johnson
  • 10,776
  • 18
  • 60
  • 98

3 Answers3

138

Go to Window → Preferences → Java → Installed JREs. Select the JRE you're using, click Edit, and there will be a line for Default VM Arguments which will apply to every execution. For instance, I use this on OS X to hide the icon from the dock, increase max memory and turn on assertions:

-Xmx512m -ea -Djava.awt.headless=true
rolve
  • 10,083
  • 4
  • 55
  • 75
Alice Young
  • 1,742
  • 2
  • 11
  • 19
  • HI, if I am running the java program from cmd, how can I specify the VM arguments? any example would do – Dhruv Singhal Aug 20 '18 at 14:47
  • If you open an actual window you can have an argument with a person standing outside so it makes sense to some people that the Window menu is a good place to put default VM arguments. – H2ONaCl Sep 07 '18 at 21:56
  • Best place to put common arguments for munit tests in mulesoft's Anypoint Studio. Works across all mule projects. – vikram92 May 09 '19 at 06:39
40

Yes, right click the project. Click Run as then Run Configurations. You can change the parameters passed to the JVM in the Arguments tab in the VM Arguments box.

That configuration can then be used as the default when running the project.

Jivings
  • 22,834
  • 6
  • 60
  • 101
  • 4
    Thanks! Is there a way to set a default for all projects? – Thomas Johnson May 17 '12 at 16:53
  • 5
    I think that's done in the Java section of the main Eclipse settings. – Jivings May 17 '12 at 17:59
  • One question, when I configure it manually like you said, Will the configuration stick with java application when we build it to war file and deploy to websphere server? – Kay Sep 07 '17 at 03:11
  • 1
    Yes, but the MUCH BETTER WAY to do it, is by following Alice's way below because it makes it permanent for every project. – Aaron Esteban Jan 22 '21 at 17:20
5

As far as I know there is no option to create global configuration for java applications. You always create a duplicate of the configuration.

enter image description here

Also, if you are using PDE (for plugin development), you can create target platform using windows -> Preferences -> Plug-in development -> Target Platform. Edit has options for program/vm arguments.

Hope this helps

Ravi
  • 545
  • 3
  • 5