default configuration of NetBeans plugin

Hello.

I’m using Netbeans 7.0.1 with the latest version of netbeans plugin. So far it is working fine with some basic tutorials. The only problem is that it creates some weird MyApplication.java automatically every time I want to start a new project.

By weird I mean:

  • it contains unused imports,
  • @author and @version situated below imports,
  • it is already filled with some application logic (hello vaadin user), even tho I’m creating a new project and not a Samples project.

Is there a template I can modify or any other way to change the content of this file (instead of doing it manually for each project)? Please keep in mind that I’m new both to NetBeans and programming.

After thinking about this for a bit more it hit me that this file sits in com.example.vaadin package. I think I should simply delete this package and create a new one with new java class (and I can create a NetBeans template for this).

Yes it does create the Application class for you with some code in it, but it has to, otherwise the plugin would be of little use. The project file initializes the web.xml file for you as well, and it has to know which class should be mapped to Application. The code within that class is the necessary code (with exception of the label) that every Vaadin app needs to have, mainly initializing and setting the mainWindow. This is virtually the same as creating a standard Jave SE project with the first class having main() in it. The project needs to have a file that will be ran when the app is first interacted with, otherwise it would not be an application but something closer to a library.

You can delete this class or change in any way you wish, as long you make sure to make the appropriate changes in your web.xml config file as well as making sure that other necessary aspects of every Vaadin app class are still present.

Thank you for your explanation it was very helpful. Probably I’m just picking on details but I really don’t like the content of this default class file. It looks ugly (doesn’t respect your preferred formatting) and requires manual modifications that could be automated (for example Licence).

Now I’ve got it down to just a few mouse clicks to get it replaced by a proper one. No rocket science but I’m a newbie and it took me a while to figure out. In case if somebody else is interested here’s what I’m doing.

Create a new template (Tools → Templates) called for example “Vaadin Application Class” and containing this code:

<#assign licenseFirst = "/*">
<#assign licensePrefix = " * ">
<#assign licenseLast = " */">
<#include "../Licenses/license-${project.license}.txt">

<#if package?? && package != "">
package ${package};

</#if>

import com.vaadin.Application;

/**
 *
 * @author ${user}
 *
 */
public class ${name} extends Application {

    @Override
    public final void init() {
        // TODO code application logic here
    }

}

Now after creating a new project you can immediately remove both default files (MyApplication.java and VaadinExampleUtils.java). Then right click on the package and select New → Vaadin Application Class. The only thing you have to remember is to give it the same name that was given as “Vaadin Application Class” in step “4. Frameworks” (which is MyApplication by default).