如何将 NetBeans .form 文件转换为 .java?

发布于 2024-07-08 13:25:40 字数 288 浏览 8 评论 0原文

在不使用 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 技术交流群。

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

发布评论

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

评论(2

快乐很简单 2024-07-15 13:25:40

好吧,实际上必须与“意外”添加代码作斗争更多是过程问题,而不是技术问题。 我的步骤是:

  1. 防止在 CVS/SVN 存储库中提交生成的 .java 文件
  2. 在持续集成项目中嵌入 matisse 表单生成。

对于步骤 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:

  1. Prevent committing the generated .java files in the CVS/SVN repository
  2. Embed matisse form generation in a continuous integration project.

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.

昵称有卵用 2024-07-15 13:25:40
  • 从 Netbeans 复制代码并将其粘贴到 JCREATOR 中。
  • 保存文件。
  • 如果需要任何名称,则写下您在 Netbean 中创建的类的名称。
  • 保存。
  • JCREATOR中运行代码。
  • 它会自动将您的文件转换为 .java.class
  • 玩得开心和欢呼。
  • Copy the code from Netbeans and paste it into JCREATOR.
  • save the file.
  • if it requires any name then write the name of your class which you make in Netbean.
  • save it.
  • run the code in JCREATOR.
  • automatically it convert your file to .java and .class.
  • have fun and cheers.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文