如何在 Java Netbeans 平台模块化项目中设置 VM 选项?
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
事实上,这很容易。只需修改 project.properties 文件以包含以下行:
已编辑:
当然,您可以在其中包含任何其他 JVM 选项。
享受。
It is quite easy, in fact. Just modify project.properties file to include the following line:
Edited:
Of course, you can include any other JVM options there.
Enjoy.
我终于能够根据 https://web.archive.org/web/20130830023832/http://activeintelligence.org/blog/archive/gephi-increasing-xmx-memory-in-netbeans/
我所做的是修改正如 JB 所说,project.properties 文件,但正确的方法是在 args 之前添加 -J 。例如,
做到了!不知道为什么花了三个月才弄清楚。 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.,
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!
我想我会对这个主题做出一些贡献,当我开发 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.
我遇到了这个问题,经过一番挖掘和阅读大量文档后,我能够推断出大部分值都来自线束中的模板。
因此,如果您转到 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!
对于 Maven 项目:
如本 问题,你可以使用etcConfFile nbm-maven-plugin:
更多信息:Geertjan 的博客
For maven projects:
As described in this question, you can use etcConfFile parameter of nbm-maven-plugin:
More info: Geertjan's Blog
如果您想使用 Netbeans 设置 VM 选项,而不必担心要编辑哪个文件,那么我们可以:
在相应的文本框中添加您的选项,例如:-Xms10m
要回答
user1156544
疑问:If you want to use Netbeans to set the VM options without bothering about which file to edit, here we go:
Add your option in the corresponding text box for example: -Xms10m
To answer
user1156544
doubt:您必须将这些行添加到项目属性文件中。
you have to add these lines to your project properties file.