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

后端 未结 7 1920
暖寄归人
暖寄归人 2020-12-15 07:10

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

相关标签:
7条回答
  • 2020-12-15 07:17

    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>
    
    0 讨论(0)
  • 2020-12-15 07:23

    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!

    0 讨论(0)
  • 2020-12-15 07:23

    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:

    0 讨论(0)
  • 2020-12-15 07:30

    I was finally able to solve this based on information at 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!

    0 讨论(0)
  • 2020-12-15 07:33

    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

    0 讨论(0)
  • 2020-12-15 07:39

    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.

    0 讨论(0)
提交回复
热议问题