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

时间:2022-10-30 14:54:31

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.

将NetBeans(Matisse).form文件转换为.java文件的最佳方法是什么,而不使用NetBeans IDE本身?理想情况下,我想将.form文件与源代码一起打包,并在构建时生成.java文件。这将阻止开发人员“意外地”使用其他IDE将生成的.java文件添加到生成的.java文件中,然后在下次在GUI设计器中编辑表单时,NetBeans会覆盖这些IDE。

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.

我搜索过谷歌,我所能找到的就是人们说“使用NetBeans IDE生成.java文件”,这在构建时很难做到。

2 个解决方案

#1


1  

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. 阻止在CVS / SVN存储库中提交生成的.java文件

  3. Embed matisse form generation in a continuous integration project.
  4. 在一个持续集成项目中嵌入matisse表单生成。

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.

对于第1步:使用合理的命名约定并坚持使用所有gui对象的标准,例如:将所有表单放在一个公共包中,并对其中的java文件使用.svnignore指令。

For step 2: Fabrizio Giudici has a nice tutorial on how to build a netbeans project (yes using matisse) inside a continuous integration environment.

对于第2步:Fabrizio Giudici有一个很好的教程,介绍如何在持续集成环境中构建netbeans项目(是的,使用matisse)。

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

请注意,他谈到首先在带有gui的机器上安装netbeans然后在无头机器中移动jar文件。 IIRC可以在无头环境中安装Netbeans版本4.x而不使用gui(因为它是一个java应用程序,唯一要做的就是解压缩文件并创建一个合理的shell文件,使用正确的jvm启动应用程序/ classpath组合)。

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.

无论如何,如果您不能强制执行这两个规则,或者您无法找到如何在CI服务器中生成matisse工件,请考虑完全废弃使用matisse的可能性。

#2


0  

  • Copy the code from Netbeans and paste it into JCREATOR.
  • 从Netbeans复制代码并将其粘贴到JCREATOR中。

  • save the file.
  • 保存文件。

  • if it requires any name then write the name of your class which you make in Netbean.
  • 如果需要任何名称,则写下您在Netbean中创建的类的名称。

  • save it.
  • run the code in JCREATOR.
  • 在JCREATOR中运行代码。

  • automatically it convert your file to .java and .class.
  • 自动将您的文件转换为.java和.class。

  • have fun and cheers.
  • 玩得开心,欢呼。

#1


1  

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. 阻止在CVS / SVN存储库中提交生成的.java文件

  3. Embed matisse form generation in a continuous integration project.
  4. 在一个持续集成项目中嵌入matisse表单生成。

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.

对于第1步:使用合理的命名约定并坚持使用所有gui对象的标准,例如:将所有表单放在一个公共包中,并对其中的java文件使用.svnignore指令。

For step 2: Fabrizio Giudici has a nice tutorial on how to build a netbeans project (yes using matisse) inside a continuous integration environment.

对于第2步:Fabrizio Giudici有一个很好的教程,介绍如何在持续集成环境中构建netbeans项目(是的,使用matisse)。

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

请注意,他谈到首先在带有gui的机器上安装netbeans然后在无头机器中移动jar文件。 IIRC可以在无头环境中安装Netbeans版本4.x而不使用gui(因为它是一个java应用程序,唯一要做的就是解压缩文件并创建一个合理的shell文件,使用正确的jvm启动应用程序/ classpath组合)。

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.

无论如何,如果您不能强制执行这两个规则,或者您无法找到如何在CI服务器中生成matisse工件,请考虑完全废弃使用matisse的可能性。

#2


0  

  • Copy the code from Netbeans and paste it into JCREATOR.
  • 从Netbeans复制代码并将其粘贴到JCREATOR中。

  • save the file.
  • 保存文件。

  • if it requires any name then write the name of your class which you make in Netbean.
  • 如果需要任何名称,则写下您在Netbean中创建的类的名称。

  • save it.
  • run the code in JCREATOR.
  • 在JCREATOR中运行代码。

  • automatically it convert your file to .java and .class.
  • 自动将您的文件转换为.java和.class。

  • have fun and cheers.
  • 玩得开心,欢呼。