Projects in Netbeans

Open Netbeans and select File --> New Project

Java with Maven is probably the default, change this to Java with Ant, and accept Java Application. 

(The first time you do this, however, Netbeans may have to do some setup.  If so, check both boxes in the Finding Features window and choose Download and Activate to install. )

In the New Java Application window, set your Project Name.  You need to fill in the project name, based on the name of the assignment and how you are turning it in (e.g. hwk02jsmith or cwk02g03 depending on if you are turning in homework 2 as an individual or a classwork 02 as a group). 

Note the Project Folder where it says it is saving your work.  That is the directory you will later zip and submit.  At home, it is just important to notice the location so you can find it again when turning in.  In the classroom, you will probably need to change the project location to a thumb or network drive so you don't leave your work on a classroom machine and lose it. 

If Create Main Class is checked, it will create a class with a main() for you.  You can change the name of that class here, by changing the text after the dot.  If you get rid of the text before the dot, you will end up in the default package.  You can also rename the main class later.

When all this is set up correctly, click Finish.

The project will be created for you.  It should also create a package inside the project, using the project name (unless you deleted the text in front of the dot!).

To add a new class to a package, you can right-click the package and select New...

Once your project opens, on the left side expand the Source Packages.  Since Netbeans is designed for producing real production code, they create a package (a unit of organization in your program) based on the default company name.  There is no need to change this for us.  You can right click on the package to create a New Java Class.  Or, if you need a new class with a main, to save a little typing you can go down into Other and find Java Main Class, which comes with a main method already in it.

In many cases the assignment will tell you what to name your classes.  If it does not, you may choose your own name, but remember that you want me to be able to find your work easily, so meaningful names are a good choice.  Remember also that there are naming conventions for classes in Java.

Once you have added some code, go to Run>Run File or press SHIFT+F6 to run.  This is a good habit to get into; just Run runs the project, which means it will run whichever Netbeans currently believes is the current main in the current project, which may not be the one you're looking at right now.

The first time you run a main, Netbeans may generate a lot of extra output at the bottom of the screen before showing you the output of your program (and if you didn't print, remember you won't see any output!). 

A few Netbeans Hints: