How can I set VM options in a Java Netbeans Platform Modular Project?

35,349

Solution 1

It is quite easy, in fact. Just modify project.properties file to include the following line:

Edited:

run.args.extra=-J-Xmx768m

Of course, you can include any other JVM options there.

Enjoy.

Solution 2

I was finally able to solve this based on information at https://web.archive.org/web/20130830023832/http://activeintelligence.org/blog/archive/gephi-increasing-xmx-memory-in-netbeans/

What I did was modify the project.properties file, as JB said, but the correct way to do it was to add a -J before the args. E.g.,

run.args.extra=-J-Xms256m -J-Xmx756m

That did it! Not sure why it took 3 months to figure that out. Definitely a fail for the Netbeans documentation. They should really make this editable from the properties menu instead of making users hunt through nondescript config files!

Solution 3

I thought i'll put some contribution on this topic, When I was developing a netbeans platform application i also faced the same problem, I added run.args.extra=-J-Xmx768m and updated my project.properties file but it didn't ! But when i added run.args.extra=-J-Xmx768m in my platform.properties file then it worked, again this only works when i was in development environment. When I packeged the application for windows the problem remained same my min heap size was 24m and max is 64m. Then I found out that if I update and add default_options="--branding my_project -J-Xms64m -J-Xmx1G" in my_project.conf in my installed directory C:\Program Files\my_project\etc then run my application and checked the ide log i can now see the change. By the way i wasn't lucky enough to see even the run node when i right click and go to the project properties dialogue in netbeans 7.0.1. Its upto netbeans dream team to make us feel lucky.

Solution 4

I had this issue and after some digging around and reading a lot of docs I was able to deduce that most of those values were coming from templates in the harness.

So if you go to your IDE_home/harness/etc/ you will find the "app.conf" file. This file is renamed during a distro build and the "app.conf" becomes your "application name.conf". Edit this file with the default values you would like in you application.

In my case I replaced the line that read: default_options="--branding ${branding.token} -J-Xms24m -Xmx64m" with default_options="--branding ${branding.token} -J-Xms64m -Xmx512m" as my application was needing more memory. By changing the template I dont have to touch every deployment and change the memory CLI for the VM.

Hope this helps!

Solution 5

For maven projects:

As described in this question, you can use etcConfFile parameter of nbm-maven-plugin:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>nbm-maven-plugin</artifactId>
    <configuration>
        <etcConfFile>src/main/resources/app.conf</etcConfFile>
    </configuration>
</plugin>

More info: Geertjan's Blog

Share:
35,349
Makoto
Author by

Makoto

Updated on January 18, 2021

Comments

  • Makoto
    Makoto over 3 years

    I have a Netbeans Platform modular project, not a regular Java project. I want to set VM options to increase memory, but under the "properties" dialog, there is no way to do this for a modular Netbeans platform project. This has cost me huge amounts of time and I still have not found a good way to set the VM args.

    Does anyone know how to set VM args using a Netbeans platform modular project, when compiling and running the program in Netbeans 7? Given the amount of trouble, I am almost ready to give up on Netbeans to create modular applications.