简体   繁体   English

使用Netbeans的Google Web工具包?

[英]Google web toolkit with Netbeans?

I prefer to use Netbeans as my IDE rather than Eclipse. 我更喜欢使用Netbeans作为我的IDE而不是Eclipse。 A few years ago when I looked into Google Web toolkit, there was no good Netbeans plugin for GWT and everyone suggested to use Eclipse. 几年前,当我查看Google Web工具包时,GWT没有好的Netbeans插件,每个人都建议使用Eclipse。 How is the situation now? 情况现在怎么样? Is there any better plugin on the market, or is Eclipse the best option? 市场上有没有更好的插件,或Eclipse是最好的选择?

I prefer Netbeans over Eclipse too. 我也喜欢Netbeans而不是Eclipse。 To develop for GWT, I used the following setup steps without installing gwt4nb plugin. 为了开发GWT,我使用了以下设置步骤而没有安装gwt4nb插件。 Since I use an IDE for code analysis and editing help only, and feel quite comfortable manipulating files and directories in the source tree directly. 由于我只使用IDE进行代码分析和编辑帮助,因此可以直接在源代码树中操作文件和目录。 Though this may not fit your case, I guess for many developers the steps should be good enough because you can treat gwt development just a normal java project. 虽然这可能不适合您的情况,但我想对于许多开发人员而言,步骤应该足够好,因为您可以将gwt开发视为普通的Java项目。

  1. Install JDK, NetBeans-SE. 安装JDK,NetBeans-SE。 Extract gwt package. 提取gwt包。 I have a note for gwt-1.7.1 . 我有一个关于gwt-1.7.1的说明 If running on a windows 64bit version, install 64bit netbeans and jdk, and also a 32 bit JRE. 如果在Windows 64位版本上运行,请安装64位netbeans和jdk,以及32位JRE。

  2. Copy the Hello sample from gwt directory to a directory out of gwt package directory. 将Hello示例从gwt目录复制到gwt package目录之外的目录。 Create a project of existing java source code, and put the project under the same Hello directory. 创建现有Java源代码的项目,并将项目放在同一个Hello目录下。 Then netbeans will create two files in the Hello directory: nbbuild.xml and manifest.mf, and create its own nbproject directory under Hello. 然后netbeans将在Hello目录中创建两个文件:nbbuild.xml和manifest.mf,并在Hello下创建自己的nbproject目录。 I simply ignore these files. 我只是忽略这些文件。

  3. In netbeans "Projects" window, right click on "Libraries" and choose "Add JAR" to add the jar files from the gwt directory. 在netbeans“Projects”窗口中,右键单击“Libraries”并选择“Add JAR”以从gwt目录添加jar文件。

  4. In netbeans "Files" window (not the "Projects" window), you will see the original "build.xml" file that comes with the Hello sample. 在netbeans“文件”窗口(而不是“项目”窗口)中,您将看到Hello示例附带的原始“build.xml”文件。 Edit this file so the "gwt.sdk" points to the location of gwt package directory. 编辑此文件,以便“gwt.sdk”指向gwt包目录的位置。 On windows 64bit, also add a "jvm" property under "java" task. 在Windows 64bit上,还在“java”任务下添加“jvm”属性。 It shall look like (only jvm=... is newly added): 它看起来像(只有jvm = ...是新添加的):

    <target name="hosted" depends="javac" description="Run hosted mode"> <target name =“hosted”depends =“javac”description =“运行托管模式”>
    <java failonerror="true" fork="true" classname="com.google.gwt.dev.HostedMode" <java failonerror =“true”fork =“true”classname =“com.google.gwt.dev.HostedMode”
    jvm="C:\\\\Users\\\\youhere\\\\Programs\\\\jre6.32\\\\bin\\\\java"> JVM = “C:\\\\用户\\\\ youhere \\\\程序\\\\ jre6.32 \\\\仓\\\\的java”>
    <classpath> <类路径>

  5. Use "Files" window, click to expand "build.xml" file node. 使用“Files”窗口,单击以展开“build.xml”文件节点。 Then right click on "hosted" ant target under "build.xml" and choose "Run Target" in the context menu to build and run the hosted mode. 然后右键单击“build.xml”下的“托管”ant目标,并在上下文菜单中选择“Run Target”以构建和运行托管模式。

The ant targets from "build.xml" you usually use: 您通常使用的“build.xml”中的ant目标:

  • "build": Use this to build the javascript. “build”:使用它来构建javascript。
  • "hosted": Use this to build java and start hosted server and browser. “托管”:使用它来构建java并启动托管服务器和浏览器。

Once the hosted server is started, you can run "build" target to build the javascript and to have the result served by the running hosted server immediately without restarting the server. 启动托管服务器后,您可以运行“build”目标来构建javascript,并在不重新启动服务器的情况下立即使运行的托管服务器提供服务。 Use your normal browser to see the javascript version at "localhost:8888". 使用普通浏览器查看“localhost:8888”的javascript版本。 You can set a different port by editing the "build.xml" file. 您可以通过编辑“build.xml”文件来设置不同的端口。

Usually I copy the Hello sample to a different directory, and use that as a start point of a new project. 通常我将Hello示例复制到另一个目录,并将其用作新项目的起点。 After that manually edit the files to match the project naming and directory structure. 之后,手动编辑文件以匹配项目命名和目录结构。

I also copy the other samples from gwt package to a new directory, then build and run them to use that as a code reference. 我还将其他样本从gwt包复制到一个新目录,然后构建并运行它们以将其用作代码引用。 If you want to also develop the servlet, take a look at the servlet of DynaTable sample and create or copy the files into the same directory structure in your project. 如果您还想开发servlet,请查看DynaTable示例的servlet,并将文件创建或复制到项目中的相同目录结构中。

A note about gwt4nb plugin: I installed it but figured out it is too heavy weight for me. 关于gwt4nb插件的说明:我安装了它,但发现它对我来说太重了。 With the above manual setup, I can do everything that I need to without any difficulty. 通过上面的手动设置,我可以毫无困难地完成我需要的一切。

I would say Eclipse is the best free option. 我会说Eclipse是最好的免费选择。 Intellij IDEA (paid edition) has also good GWT support but it is not as good as Eclipse . Intellij IDEA (付费版)也有很好的GWT支持,但它不如Eclipse好。

I think the only official support goes for eclipse, see here : https://developers.google.com/web-toolkit/download 我认为唯一的官方支持是eclipse,请看: https//developers.google.com/web-toolkit/download

Based on my personal experience, if you want to have a good integration between GWT and your IDE , go for Eclipse . 根据我的个人经验,如果您希望在GWTIDE之间实现良好的集成,请选择Eclipse If you intend to use Maven , I also suggest M2E http://m2eclipse.codehaus.org/ 如果你打算使用Maven ,我也建议使用M2E http://m2eclipse.codehaus.org/

EDIT 编辑

Forgot to say the most important thing. 忘了说最重要的事情。 Netbeans by the way, seems to have a nice support of GWT but I never tested, see : http://netbeans.org/kb/docs/web/quickstart-webapps-gwt.html 顺便说一句, Netbeans似乎得到了GWT的很好的支持,但我从未测试过,请参阅: http//netbeans.org/kb/docs/web/quickstart-webapps-gwt.html

I am sure this is not the correct and suitable answer. 我相信这不是正确和合适的答案。 But if you like to trade off, this is just an idea. 但如果你喜欢权衡,这只是一个想法。

sudo -i
cd ~/gwt
./projectCreator -ant build -out projects/myapplication
./applicationCreator -out projects/myapplication myapplication.client.MyApp

Then, you can import the project ... 然后,您可以导入项目...

  1. In Netbeans create a new projects and choose 'Java Project With Existing Ant Script', 在Netbeans中创建一个新项目并选择“Java Project With Existing Ant Script”,
  2. Set Location to the myapplication folder created earlier Set Build Script to the build.ant.xml file created by projectCreator Set Project Name to something more appropriate 将Location设置为先前创建的myapplication文件夹将Build Build Script设置为projectCreator创建的build.ant.xml文件将Project Name设置为更合适的
  3. Open the project properties and under Java Sources click Add Folder. 打开项目属性,在Java Sources下单击Add Folder。 Select the projects/myapplication/src folder and press OK 选择projects/myapplication/src文件夹,然后按OK

Please excuse, if you didn't like this approach. 请原谅,如果你不喜欢这种方法。

Sounds similar with Battle for Eclipse and Netbean but you are talking about concern with GWT . 听起来与Battle for Eclipse和Netbean类似,但你在谈论对GWT的关注。 So , I think you can choice as you more prefer depends on your experiences. 所以,我认为你可以选择,因为你更喜欢取决于你的经验。 You can do GWT developing in various IDE because I assume GWT runs on it's SDK not on IDE . 您可以在各种IDE中进行GWT开发,因为我假设GWT运行在它的SDK而不是IDE上。 But there has some points of views. 但是有一些观点。 Example : easy to generate , test , develop ..etc on each IDE. 示例:在每个IDE上轻松生成,测试,开发..etc。

I also personally love NetBean due to beautiful GUI :) . 由于美丽的GUI :)我个人也喜欢NetBean。 But I am working with Eclipse IDE because our team has been developed and configured on it for a long time so we have hard to change IDE ( sometimes very hard to change Eclipse version because we can't imagine new version will more reliable for our projects ).But I don't mean Eclipse is the best option , as I described you may configure your GWT projects on any other IDE also as your experiences via GWT SDK . 但我正在使用Eclipse IDE,因为我们的团队已经在其上开发和配置了很长时间,所以我们很难改变IDE( 有时很难更改Eclipse版本,因为我们无法想象新版本对于我们的项目会更可靠但是我并不是说Eclipse是最好的选择 ,正如我所描述的那样你可以在任何其他IDE上配置你的GWT项目,也可以通过GWT SDK来体验。

"...and everyone suggested to use Eclipse." “......每个人都建议使用Eclipse。” . Yes you will see most of sample projects for it were figured with Eclipse IDE. 是的,您将看到大多数示例项目都是使用Eclipse IDE进行计算的。 Only aspect for GWT , I think you have chance to choose NetBean IDE without any worries. 只有GWT的方面,我认为你有机会选择NetBean IDE而不用担心。

You can develop GWT project on NetBean IDE as follow... 您可以在NetBean IDE上开发GWT项目,如下所示......

1.) First off, download and install the gwt4nb plugin. 1.)首先, 下载并安装gwt4nb插件。 ( you may have exp for install plugin on NetBean IDE ) (您可能在NetBean IDE上安装了exp for install插件)

2.) download GWT SDK and extract it to your specific location. 2.) 下载 GWT SDK并将其解压缩到您的特定位置。

3.) create a new Java Web –> Web Application . 3.)创建一个新的Java Web - > Web应用程序 Name your application and hit Next until you get to the Frameworks tab. 为应用程序命名,然后单击“ 下一步”,直到进入“ 框架”选项卡。 If you have successfully installed the gwt4nb plugin you should see Google Web Toolkit listed. 如果您已成功安装gwt4nb插件,则应该会看到列出的Google Web Toolkit。 Select the Google Web Toolkit framework. 选择Google Web Toolkit框架。

4.) Next, browse to the GWT SDK installation folder. 4.)接下来,浏览到GWT SDK安装文件夹。 Name your GWT module and hit Finish . 为您的GWT模块命名并点击Finish

5.) Clean and Build your project.(don't be forgot to wait until successfully finished Build.) 5.)清理并构建项目。(不要忘记等到成功完成构建。)

6.) Run the project, your browser should launch and the button “Click me!” and the text “Hello, GWT!!!” should be visible. 6.)运行项目,你的浏览器应该启动,按钮“Click me!”和文本“Hello,GWT !!!”应该是可见的。

Cheer ! 干得好! now you can create GWT sample project on NetBean IDE. 现在您可以在NetBean IDE上创建GWT示例项目。

You can also create GWT's 你也可以创建GWT

  • Test Case 测试用例
  • Constants 常量
  • Module
  • RPC Service RPC服务
  • UiBinder UiBinder的

By right click on your_project > Other... > Google Web Toolkit . 右键单击your_project > Other ... > Google Web Toolkit

Have some useful tips for you ! 有一些有用的提示给你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM