Your First Project with IT Mill Toolkit in Netbeans IDE 6.1
IT Mill Toolkit manual has detailed instructions on how to create your first project with IT Mill Toolkit in Eclipse IDE. This article shows you how to accomplish the same using Netbeans IDE 6.1 instead of Eclipse. This tutorial assumes you have downloaded a bundle of Netbeans 6.1 that includes the Apache Tomcat server (for example the "Web & Java EE" package) and the latest release of IT Mill Toolkit.
Creating the Project
Launch your Netbeans IDE and follow the following steps to create a new web project using IT Mill Toolkit.
- Select File -> New Project to open the New Project dialog window.
- Select Web from the categories and Web Application from the project selection and click Next to proceed.
- Type in a name and location for your project (I use HelloToolkit as the name and my default project folder) and click Next.
- Select the Apache Tomcat 6.0.16 server if not already selected and type in preferred context path or use the default (the project name). The context path will define the URL of your application (for example http://localhost:8084/HelloToolkit). Click Finish to create the project.
- You can close and ignore the index.jsp, which is opened to the editor by default after the project has been created.
Including IT Mill Toolkit Libraries
Next you need to include the IT Mill Toolkit library JAR package to the project you just created.
- Right-click the Libraries node on your project and select Add JAR/Folder.
- Select your copy of the IT Mill Toolkit JAR package from the opening file dialog.
- Now you should see the JAR package under the Libraries node.
Writing the Code
Next we create the application class for our simple example application.
- Select New -> Java Class on your project to open the New Java Class dialog.
- Type in your a name and package for your class (I use a class name of HelloToolkit and a package com.itmill.toolkit.netbeans.tutorial).
- Select Finish to create the Java class.
This class will be the main application class of our IT Mill Toolkit application. Therefore it must extend the abstract com.itmill.toolkit.Application class and implement the init() method.
Type in or copy-paste the following code to the newly created file:
package com.itmill.toolkit.netbeans.tutorial; import com.itmill.toolkit.Application; import com.itmill.toolkit.ui.Label; import com.itmill.toolkit.ui.Window; public class HelloToolkit extends Application { @Override public void init() { Window mainWindow = new Window("Hello Toolkit window"); mainWindow.addComponent(new Label("Hello Toolkit")); setMainWindow(mainWindow); } }
Defining Deployment Descriptor
To run your application you must define a deployment descriptor for it. Open Web Pages -> WEB-INF -> web.xml file on your project. By default the file is opened in a graphical editor but you can select the XML tab to edit the XML file directly. Type in or copy-paste the following to the contents of the file.
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <servlet> <servlet-name>HelloToolkit</servlet-name> <servlet-class>com.itmill.toolkit.terminal.gwt.server.ApplicationServlet</servlet-class> <init-param> <param-name>application</param-name> <param-value>com.itmill.toolkit.netbeans.tutorial.HelloToolkit</param-value> </init-param> </servlet> <servlet-mapping> <url-pattern>/*</url-pattern> <servlet-name>HelloToolkit</servlet-name> </servlet-mapping> </web-app>
Running Your Application
Now we can run (or debug) the application by simply selecting Run -> Run Main Project (or Run -> Debug Main Project). This starts the Apache Tomcat server and opens up your application in your default browser.
Attachments
- add-libraries.png (17.3 kB) - added by Teemu Pontelin 2 months ago.
- new-project-dialog.png (30.5 kB) - added by Teemu Pontelin 2 months ago.
- hello_toolkit_running.png (20.7 kB) - added by Teemu Pontelin 8 weeks ago.

