如何将 NetBeans .form 文件转换为 .java?
在不使用 NetBeans IDE 本身的情况下将 NetBeans (Matisse) .form 文件转换为 .java 文件的最佳方法是什么? 理想情况下,我想将 .form 文件与源代码一起打包,并在构建时生成 .java 文件。 这将防止开发人员“意外”使用其他 IDE 将代码添加到生成的 .java 文件中,这样下次在 GUI 设计器中编辑表单本身时,该代码可能会被 NetBeans 覆盖。
我在 Google 上进行了搜索,发现人们都说“使用 NetBeans IDE 生成 .java 文件”,这在构建时很难做到。
What's the best way to convert NetBeans (Matisse) .form files into .java files, without using the NetBeans IDE itself? Ideally I'd like to package the .form files along with my source code, and generate the .java files at build time. This will prevent developers from "accidentally" adding code to the generated .java file using some other IDE, which could then get overwritten by NetBeans the next time the form itself is edited in the GUI designer.
I've searched Google and all I can find is people saying, "Use the NetBeans IDE to generate the .java file," which is kind of difficult to do at build-time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,实际上必须与“意外”添加代码作斗争更多是过程问题,而不是技术问题。 我的步骤是:
对于步骤 1:
使用合理的命名约定并坚持所有 gui 对象的标准,例如:将所有表单放入一个公共包中,并对其中的 java 文件使用 .svnignore 指令。
对于步骤 2:
Fabrizio Giudici 有一个很好的教程,介绍如何在持续集成环境中构建 netbeans 项目(是的,使用 matisse)。
http://weblogs.java.net/blog/fabriziogiudici/ archive/2006/11/setting_up_netb.html
请注意,他谈到首先在带有 GUI 的计算机上安装 netbeans,然后将 jar 文件移动到无头计算机中。 IIRC 可以在无头环境中安装 Netbeans 版本 4.x,而无需使用 gui(因为它是一个 java 应用程序,唯一要做的步骤是解压缩文件并创建一个合理的 shell 文件,使用正确的 jvm 启动应用程序) /类路径组合)。
无论如何,如果您无法强制执行这两个规则,或者您无法找到如何在 CI 服务器中生成 matisse 工件,请考虑完全放弃使用 matisse 的可能性。
Well, actually having to fight with "accidental" addition of codes is more a problem of process rather than a problem with technology. My steps would be:
For step 1:
Use a sensible naming convention and stick with the standard for all the gui object, e.g.: put all the forms inside a common package and use the .svnignore directive on java files in it.
For step 2:
Fabrizio Giudici has a nice tutorial on how to build a netbeans project (yes using matisse) inside a continuous integration environment.
http://weblogs.java.net/blog/fabriziogiudici/archive/2006/11/setting_up_netb.html
Note that he talks about installing netbeans first on a machine with a gui then moving the jar files in an headless machine. IIRC it was possible to install Netbeans version 4.x in an headless environment without using the gui (since it is a java application, the only steps to do were to unzip the files and create a sensible shell file launching the application with the correct jvm/classpath combo).
Anyway, if you can't enforce both rules, or you can't find how to generate the matisse artifacts in the CI server, consider the possibility to scrap the use of matisse entirely.
.java
和.class
。.java
and.class
.