17

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.

7 Answers 7

12

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.

8
  • 1
    When I try this by adding the run.args.extra option that you specify, I get this error: "Ignored unknown option: -Xmx768m"
    – Makoto
    Jul 11, 2011 at 23:53
  • Sorry, missed the -J prefix :(
    – JB-
    Jul 12, 2011 at 7:04
  • What if you have more than one argument to pass to jvm? multiple lines or spaces between each entry?
    – simgineer
    Jun 23, 2014 at 19:50
  • 1
    ...or use run.jvmargs= property Oct 17, 2014 at 16:34
  • 1
    run.args.extra only works in development, see forums.netbeans.org/topic5312.html
    – iberck
    May 9, 2016 at 3:05
8

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!

3
  • Nope, the answer - as far as I can tell - only applies to Ant-based projects in NetBeans IDE.
    – peterh
    Nov 26, 2013 at 14:39
  • Sounds like it's unknown as to how we do this in maven? We have an ant project and need to convert it to a maven project. So definitely have to figure out the maven way too.
    – simgineer
    Jul 1, 2014 at 14:24
  • @simgineer did you find a way for maven project?
    – coder247
    May 20, 2016 at 6:32
5

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.

2
  • 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 cant now see the change.this option is not work for License version of Windows 7.because when i change from "--branding my_project -J-Xms24m -J-Xmx64m" to "--branding my_project -J-Xms64m -J-Xmx1G",it will give warning and not upadated.means i cant change at this path C:\Program Files\my_project\etc .so any other option?
    – Jay
    Jun 30, 2012 at 6:14
  • Any other option for giving more heap memory at making installer of (My App which is done as netbeans platform modulars project) netbeans platform App in netbeans IDE.
    – Jay
    Jun 30, 2012 at 6:18
3

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!

2
  • Thansk a lot, that what i was looking for for a while Dec 22, 2015 at 7:51
  • Thanks a lot, was looking for this!
    – digz6666
    Sep 28, 2016 at 7:21
2

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

2

If you want to use Netbeans to set the VM options without bothering about which file to edit, here we go:

Run -> Set project configuration -> VM Options

Add your option in the corresponding text box for example: -Xms10m

To answer user1156544 doubt:

enter image description here

1
  • I dont see this option, just a selection between default and a release-profile Oct 11, 2017 at 11:28
1

you have to add these lines to your project properties file.

<target name="build-launchers" depends="suite.build-launchers">
<replace file="build/launcher/etc/${app.name}.conf" token="--branding graphsimulator -J-Xms24m -J-Xmx64m" value="--branding graphsimulator -J-Xms128m -J-Xmx512m"/>
</target>
2
  • Exactly which file?
    – digz6666
    Sep 28, 2016 at 7:21
  • Thanks, I found it, build.xml.
    – digz6666
    Sep 28, 2016 at 7:39

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.