72

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?

3 Answers 3

139

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
3
  • HI, if I am running the java program from cmd, how can I specify the VM arguments? any example would do Aug 20, 2018 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 7, 2018 at 21:56
  • Best place to put common arguments for munit tests in mulesoft's Anypoint Studio. Works across all mule projects.
    – vikram92
    May 9, 2019 at 6: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.

4
  • 4
    Thanks! Is there a way to set a default for all projects? May 17, 2012 at 16:53
  • 5
    I think that's done in the Java section of the main Eclipse settings.
    – Jivings
    May 17, 2012 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 7, 2017 at 3: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. Jan 22, 2021 at 17:20
6

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.