Google web toolkit with Netbeans? - java

I prefer to use Netbeans as my IDE rather than 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. How is the situation now? Is there any better plugin on the market, or is Eclipse the best option?

I prefer Netbeans over Eclipse too. To develop for GWT, I used the following setup steps without installing gwt4nb plugin. 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. 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.
Install JDK, NetBeans-SE. Extract gwt package. I have a note for gwt-1.7.1. If running on a windows 64bit version, install 64bit netbeans and jdk, and also a 32 bit JRE.
Copy the Hello sample from gwt directory to a directory out of gwt package directory. Create a project of existing java source code, and put the project under the same Hello directory. Then netbeans will create two files in the Hello directory: nbbuild.xml and manifest.mf, and create its own nbproject directory under Hello. I simply ignore these files.
In netbeans "Projects" window, right click on "Libraries" and choose "Add JAR" to add the jar files from the gwt directory.
In netbeans "Files" window (not the "Projects" window), you will see the original "build.xml" file that comes with the Hello sample. Edit this file so the "gwt.sdk" points to the location of gwt package directory. On windows 64bit, also add a "jvm" property under "java" task. It shall look like (only jvm=... is newly added):
<target name="hosted" depends="javac" description="Run hosted mode">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.HostedMode"
jvm="C:\\Users\\youhere\\Programs\\jre6.32\\bin\\java">
<classpath>
Use "Files" window, click to expand "build.xml" file node. 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.
The ant targets from "build.xml" you usually use:
"build": Use this to build the javascript.
"hosted": Use this to build java and start hosted server and browser.
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. Use your normal browser to see the javascript version at "localhost:8888". You can set a different port by editing the "build.xml" file.
Usually I copy the Hello sample to a different directory, and use that as a start point of a new project. 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. 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.
A note about gwt4nb plugin: I installed it but figured out it is too heavy weight for me. 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. Intellij IDEA (paid edition) has also good GWT support but it is not as good as Eclipse.
I think the only official support goes for eclipse, see here : 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. If you intend to use Maven, I also suggest 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

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 ...
In Netbeans create a new projects and choose 'Java Project With
Existing Ant Script',
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
Open the project properties and under Java Sources click Add Folder.
Select the projects/myapplication/src folder and press 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.
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 . But there has some points of views. Example : easy to generate , test , develop ..etc on each IDE.
I also personally love NetBean due to beautiful GUI :) . 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.
"...and everyone suggested to use Eclipse." . Yes you will see most of sample projects for it were figured with Eclipse IDE. Only aspect for GWT , I think you have chance to choose NetBean IDE without any worries.
You can develop GWT project on NetBean IDE as follow...
1.) First off, download and install the gwt4nb plugin. ( you may have exp for install plugin on NetBean IDE )
2.) download GWT SDK and extract it to your specific location.
3.) create a new Java Web –> Web Application. 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. Select the Google Web Toolkit framework.
4.) Next, browse to the GWT SDK installation folder. Name your GWT module and hit Finish.
5.) Clean and Build your project.(don't be forgot to wait until successfully finished Build.)
6.) Run the project, your browser should launch and the button “Click me!” and the text “Hello, GWT!!!” should be visible.
Cheer ! now you can create GWT sample project on NetBean IDE.
You can also create GWT's
Test Case
Constants
Module
RPC Service
UiBinder
By right click on your_project > Other... > Google Web Toolkit.
Have some useful tips for you !

Related

Import Java Project from Eclipse to NetBeans [duplicate]

Is there a way to share the same *.java files between Netbeans and Eclipse?
You can import an eclipse project into netbeans,
or you can create an eclipse project from existing sources.
Sharing the Java source files is not the problem - just put them into some source control system, and then import them in both IDEs. Usually the configuration, especially the build process, is the main problem.
In practice, the solution is likely that you maintain separate project configuration files for both IDEs, but use a common build script (e.g. ant) that is supported by both. The project configuration allows you to use IDE-specific features, while the build script makes sure that both environments produce the same output.
Of course. eclipse supports linked source folders. The sources files don't have to be located in an eclipse project folder.
Inside an eclipse java project, select New -> Folder, then select "Advanced" and check "Link to alternate location" (eclipse 3.6, may be slightly different on other eclipse versions). "Browse" to choose the source folder from the netbeans project, press Finish.
Now you have linked (standard) folder to the Java files inside the netbeans project and modifying those files will modify them at the remote location.
Finally - right-click on this linked folder and choose Build Path -> Use as source folder.
(I leave the other way round to the netbeans experts)
In the ideal case you have your code stored in a version controlled repository (SVN, CVS, etc.). Then it is not as big of a factor whether you are using Eclipse or Netbeans.
This article, taken from a NetBeans 6.2 version of documentation, explains how you can import an Eclipse project into NetBeans and work with both together. NetBeans will create new project files but will link to the Eclipse source files, allowing sharing between the two. I have not tried this yet myself, but may be going down this path soon. After switching to NetBeans just this week, noticed that a significant feature in Eclipse is not in NetBeans - that of being able to create different run configurations that are not incorporated and stored into the POM. At this point in time, I do not have a solution to the run configuration issue, but if you do, please update the SO question here.

How to Point Apache Towards a Vaadin (Java) Project?

Sorry if this is the wrong kind of question but currently I have an Apache server which is configured for Pyjamas. All I used to have to do was: pyjsbuild example.py and the GUI would appear in my browser.
I decided to switch to Java, so I picked Vaadin as my framework. How do I do the equivalent for Vaadin? All I want to do is compile the java and have Apache recognise it.
I'm using linux and I'm very new to building web applications, previously I only ever built the GUI side of things, I never had to touch the server.
You need Apache Tomcat to serve java pages. Install it separatly or see http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html for information on how to hook them together.
Vaadin projects work just as any web project. You have to crate a WAR file.
For example, if you are using Eclipse, right-click on the project, choose "Export..." and under "Web" choose "WAR file".
If you are using Netbeans or something else, google "create war in netbeans/intellij/..." to find out how to do this step.
This will generate a file with the extension .war, which you will have to copy in the "webbaps" folder of your Tomcat installation. Restart Tomcat and the application will be automatically deployed.
If you do not have access to the webapps folder, go to Tocatmcat's "Manager App" in the browser and
under the section "Fichier WAR à déployer"(WAR file to depploy) choose the generated file and click Deploy.
To start with, make sure that go through Getting Started chapter in Book of Vaadin. In this chapter you will find overview of the required toolchain and step-by-step installation instructions. Your Linux distribution might have more documentation about installing JDK (For example, see Ubuntu wiki for Oracle JDK installation).
It will be convenient for you to connect Tomcat to Eclipse IDE. This makes starting Tomcat and updating your application easy. For example, see this [blog] for some videos about connecting Eclipse to Tomcat.
Please note that using Eclipse is just one approach and later you might want to see if IntelliJ IDEA or command line works better for you.

Eclipse: Is it possible to publish Javascript edits to an external Tomcat instance

I am converting an application from Flex to Javascript. My workflow within Eclipse for Flex was to use Maven to start my Java web app in Tomcat and then have Eclipse configured to compile edited Actionscript files to a SWF and save it to my exploded WAR directory (that Maven/Cargo uses).
It worked very well for a long time allowing me to edit actionscript source code, flip over the browser, refresh the screen and see the changes.
I am new to Javascript however, and am struggling to get the same workflow up and running. The part I don't understand is how to tell Eclipse that I would like my edited Javascript files to be written out to a particular directory (that contains the exploded WAR). In my WAR project (a WTP dynamic web project) there is something that looks like a Javascript build path called "Javascript resources", but there is no output directory.
I would really like to continue to run Tomcat and Jetty via Maven if at all possible. I realize I can do what I want via WTP (M2E-WTP), but would prefer to use Maven/Cargo.
Denis's suggestion to create custom builder is probably best solution if you want to continue using pure Maven/Cargo approach with Eclipse.
If you are deploying to an exploded war directory, then another similar idea would be to use a File Synchronization plugin. These will automatically copy modified files to configured folders. See:
http://andrei.gmxhome.de/filesync/
https://wiki.onehippo.com/display/CMS7/Use+Filesync+Eclipse+plugin+for+faster+turn+around
-------------
FWIW, I don't think Maven:Tomcat/Cargo plugins are ideal for real-time web development, especially on the frontend side of things. They are useful mainly for controlled deployments or bootstrapping a server without initial setup. My thoughts:
Eclipse WTP used to be great for real-time web development, but I stopped using it a few years back as it just got way too hard to make it work correctly in a Maven environment. Fwiw, my preferred approach these days looks like this:
Do not install or use Eclipse WTP.
Use m2eclipse to integrate Maven with Eclipse.
Use Maven to do clean builds and generate exploded WAR directory in target folder.
Setup independent Tomcat server to load webapp from the exploded target folder.
I suspect the tomcat setup/startup could be integrated into Maven. It's not worth the extra complexity to me though.
Then, I configure JRebel (automatically via Maven) to handle java and web resource file changes. With this setup, I almost never have to redeploy or restart Tomcat. All changes (java, html, js, etc.) are seen immediately.
I think the same setup could be used without JRebel (for non-java files only) by configuring the web source folders as source folders in Eclipse with custom target output path being the corresponding directory in the exploded war directories. If that didn't work, then it would definitely work by using the custom builder or file synchronization solutions mentioned above.
Eclipse introduces the concept of "builder" to build a project. It comes with hardcoded builders such as the java compiler or the war builder of WTP.
But eclipse also enable to setup your own Builder using ant files : on your project, right click the project properties, go to section Builders, click on the new button.
You can use arguments to your ant file and use variables defined in by eclipse to build them
Do not forget to fill the refresh tab if you want eclipse to by notified of the produced files.
Do not forget the fill the Build options tab, section "Specify working set of relevant resources" in order to have your builder called each time a source used by the build file is changed inside eclipse.
Also go to the "targets" tab to specify during which type of build phase your ant file is called and which target is called.
I knwo this solution may not be the best for you since your build process will be described more than once but it may help you achieve your goal.

How can I open non-Netbeans Java project using Netbeans?

I'm using Netbeans for my Java development, and every time I download a project that has been developed using other IDE, I can't run the project because of errors.
Is there any way to open regular people's projects easily without headache.
Note : the project am trying to open is not an Eclipse project, so I can't use the Eclipse importer.
And usually what are Java developers using for development?
Most Java developers are split between Eclipse , IntelliJ Idea and NetBeans. NetBeans is capable of opening Eclipse projects and Idea can export to Eclipse. So this should solve most problems.
Another way is to check if you project is using Maven or a similar model. Generally there are plugins for Netbeans that can handle import from this sort of sources.
I've had some luck using File > New Project… > Java > Java Project with Existing Sources, which "Imports an existing Java application into a standard IDE project. The Java application can have multiple source folders. Standard projects use an IDE-generated Ant build script to build, run, and debug your project." Conveniently, the generated script includes targets that can be overridden to alter the build process, as seen here.
We have several projects with existing ant build scripts and all I want is to have NetBeans as my code editor ...so far.
We aim for that the projects are independent of IDE as we have been used to just use emacs and ant for coding/building, which means that independant on platform you should be able to checkout the code and just build it no matter if it is within an IDE or just a shell/"DOS prompt". If you have projects like that use the "Java Free-Form project" and add all jars that you have defined in build script to also be included in Netbeans CLASSPATH.
This type of project will use your ant scripts for everything and will still work even if someone in your project prefer to use other coding environment.
Hope this can help

Deploy java (command line) app using Netbeans / ant

I've finally managed to create a Netbeans project out of an old standalone (not Web-) Java application which consisted only out of single .java sources. Now I have basically two questions regarding Netbeans Subversion interaction and application deployment:
Do you check in all the Netbeans project files into the repository, normally?
If I build the project using Netbeans (or ant) I get a .jar file and some additional jar libraries. In order for the app to run properly on the server, some additional config files and directories (log/ for example) are needed. The application itself is a J2SE application (no frameworks) which runs from the command line on a Linux platform. How would you deploy and install such an application? It would also be nice if I could see what version of app is currently installed (maybe by appending the version number to the installed app path).
Thanks for any tips.
No, not usually. Anything specific to NetBeans (or Eclipse, IntteliJ, etc), I don't check in; try to make it build from the command line with your ant script and produce exactly what you want. The build.xml is something that can be used for other IDEs, or in use with Anthill or CruiseControl for automated builds/continuous integration, so that should be checked in. Check in what is needed to produce/create your artifacts.
You don't specify what type of server, or what exact type of application. Some apps are deployed via JNLP/WebStart to be downloaded by multiple users, and have different rules than something deployed standalone for one user on a server to run with no GUI as a monitoring application. I cannot help you more with that unless you can give some more details about your application, the server environment, etc.
Regarding the config files, how do you access those? Are they static and never going to change (something you can load using a ResourceBundle)? ? You can add them to the jar file to look them up in the ResourceBundle, but it all depends on what you are doing there. If they have to be outside the jar file for modification without recompiling, have them copied with an installer script.
As for directories, must they already exist? Or does the application check for their existence, and create them if necessary? If the app can create them if absent, you have no need to create them. If they need to be there, you could make it part of the install script to create those folders before the jar files are installed.
Version number could be as simple as adding an about box somewhere in the app, and looking up the version string in a config/properties file. It has to be maintained, but at least you would be able to access something that would let you know you have deployed build 9876.5.4.321 (or whatever version numbering scheme you use).
Ideally, you should not tie down your application sources and config to a particular IDE.
Questionwise,
I suggest you do not. Keep you repository structure independent of the IDE
You might have to change your application so that it's structure is very generic and can be edited in any IDE.
Is this a web app? A standalone Java app? If you clarify these, it would be easier to answer your query.
We don't check in the /build or the /dist directories.
We tend to use this structure for our Netbeans projects in SVN:
/project1/
/trunk
/tags/
/1.0
/1.1
/binaries/
/1.0
/1.1
When a change is need we check out the netbeans project from trunk/ and make changes to it and check it back in. Once a release of the project is needed we do an SVN copy of the netbeans project files to the next tag version. We also take a copy of the deployable (JAR or WAR) and place it in the version directory under binaries along with any dependencies and config files.
By doing this we have a clean, versioned deployable that is separate from the source. Are deployables are version in the name - project1-1.0.jar, project1-1.1jar and so on.
I disagree with talonx about keeping your source non-IDE specific - by not storing IDE files in SVN along with you source you are adding extra complication to the checkout, change, checkin, deploy cycle. If you store the IDE project files in SVN you can simply check out the project, fire up the IDE and hit build. You don't have to go through the steps of setting up a new project in the IDE, including the files you SVNed, setting up dependencies etc. It saves time and means all developers are working with the same setup, which reduces errors and discrepancies. The last thing you want is for a developer to check out a project to make a small bug fix and have to spend time having to find dependencies and set stuff up.
To answer question #2 -- who's your consumer for this app?
If it's an internal app and only you (or other developers) are going to be deploying it, then what you have is perfectly all right. Throw in a README file explaining the required directories.
If you're sending it out to a client to install, that's a different question, and you should use an installer. There are a few installers out there that wrap an ant script and your resources, which is a nice approach particularly if you don't need the GUI... just write a simple ant script to put everything in the right place.
Version number is up to you -- naming the JARs isn't a bad idea. I also have a habit of printing out the version number on startup, which can come in handy.

Categories