如何在 Java Netbeans 平台模块化项目中设置 VM 选项?

发布于 2024-11-19 13:05:58 字数 229 浏览 1 评论 0原文

我有一个 Netbeans 平台模块化项目,而不是常规 Java 项目。我想设置 VM 选项来增加内存,但在“属性”对话框下,无法为模块化 Netbeans 平台项目执行此操作。这花费了我大量的时间,但我仍然没有找到设置虚拟机参数的好方法。

有谁知道在 Netbeans 7 中编译和运行程序时如何使用 Netbeans 平台模块化项目设置 VM 参数?考虑到麻烦的数量,我几乎准备放弃 Netbeans 来创建模块化应用程序。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

南薇 2024-11-26 13:05:58

事实上,这很容易。只需修改 project.properties 文件以包含以下行:

已编辑:

run.args.extra=-J-Xmx768m

当然,您可以在其中包含任何其他 JVM 选项。

享受。

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.

何以畏孤独 2024-11-26 13:05:58

我终于能够根据 https://web.archive.org/web/20130830023832/http://activeintelligence.org/blog/archive/gephi-increasing-xmx-memory-in-netbeans/

我所做的是修改正如 JB 所说,project.properties 文件,但正确的方法是在 args 之前添加 -J 。例如,

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

做到了!不知道为什么花了三个月才弄清楚。 Netbeans 文档绝对是失败的。他们确实应该从属性菜单中对其进行编辑,而不是让用户通过不伦不类的配置文件进行搜索!

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!

燃情 2024-11-26 13:05:58

我想我会对这个主题做出一些贡献,当我开发 netbeans 平台应用程序时,我也遇到了同样的问题,我添加了 run.args.extra=-J-Xmx768m
并更新了我的 project.properties 文件,但没有!但是当我在我的 platform.properties 文件中添加 run.args.extra=-J-Xmx768m 时,它就起作用了,同样,这只在我处于开发环境中时才起作用。当我打包 Windows 应用程序时,问题仍然相同,我的最小堆大小为 24m,最大堆大小为 64m。然后我发现,如果我在安装目录 C:\Program Files\my_project\etc 中的 my_project.conf 中更新并添加 default_options="--branding my_project -J-Xms64m -J-Xmx1G"然后运行我的应用程序并检查 ide 日志,我现在可以看到更改。顺便说一句,当我右键单击并转到 netbeans 7.0.1 中的项目属性对话框时,我什至没有幸运地看到运行节点。让我们感到幸运的是netbeans梦之队。

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.

你在看孤独的风景 2024-11-26 13:05:58

我遇到了这个问题,经过一番挖掘和阅读大量文档后,我能够推断出大部分值都来自线束中的模板。

因此,如果您转到 IDE_home/harness/etc/,您将找到“app.conf”文件。该文件在发行版构建期间被重命名,并且“app.conf”成为您的“应用程序名称.conf”。使用您希望在应用程序中使用的默认值编辑此文件。

就我而言,我替换了以下行:
default_options="--branding ${branding.token} -J-Xms24m -Xmx64m"

default_options="--branding ${branding.token} -J-Xms64m -Xmx512m" 因为我的应用程序需要更多内存。通过更改模板,我不必触及每个部署并更改虚拟机的内存 CLI。

希望这有帮助!

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!

‘画卷フ 2024-11-26 13:05:58

对于 Maven 项目:

如本 问题,你可以使用etcConfFile nbm-maven-plugin

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

更多信息:Geertjan 的博客

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

假装不在乎 2024-11-26 13:05:58

如果您想使用 Netbeans 设置 VM 选项,而不必担心要编辑哪个文件,那么我们可以:

Run -> Set project configuration -> VM Options

在相应的文本框中添加您的选项,例如:-Xms10m

要回答 user1156544 疑问:

在此处输入图像描述

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

时光无声 2024-11-26 13:05:58

您必须将这些行添加到项目属性文件中。

<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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文