Creating a Java Project Using Wizard

Let's start with a Java project. There is not much configuration to be done with this kind of project, but this will help in familiarizing with the IDE. It will also will give some insight on how to create other, more advanced projects since the flow is almost identical.

Getting ready

If you do not have NetBeans installed on your machine yet, please visit:

http://netbeans.org

It is also necessary to have Java installed; please visit: http://www.oracle.com/technetwork/java/javase/downloads/index.html

How to do it...

  1. Let's create a New Project. This can be achieved by either clicking File and then New Project, or by pressing Ctrl+Shift+N.
  2. In the New Project window, two panes will be shown. Choose Java on the Categories pane and Java Application on the Proejcts pane, then click Next.
  3. At the Name and Location step, Project Name should be filled with HelloWorld.
  4. At Create Main Class, append com to the beginning of helloworld.Main, giving com.helloworld.Main.
  5. Leave all the other options marked and click Finish.

The configuration window should look like the following screenshot:

How to do it...

How it works...

While the project location can be specified, since we did not change the folder, NetBeans automatically adds the project to NetBeansProjects, which is the NetBeans default project folder.

Use dedicated Folder for Storing Libraries is marked since we would like to have a specific project folder where all of the libraries will be stored, making packaging and distribution easier in the future. Libraries are packaged as JAR files. A JAR file is an example of a library that contains Java sources, which enable the developer to extend the functionality of applications.

NetBeans will automatically generate a main class called Main, add a main() method, and generate default comments through the class when the Create Main Class option is marked.

How it works...

NetBeans will create the package structure, which will consist of Source Packages and Test Packages. The code templates provided by the IDE will correctly place the files in their respective folders. For example, if one JUnit test is created, the file will be placed under the Test Packages folder automatically.

One node containing libraries will also be shown in the projects view. This is where NetBeans will copy the necessary libraries. In the Java project, for example, NetBeans copies and configures the JUnit libraries into our newly-created project by default. Different projects will have different dependencies.

There's more...

You should play a bit with other project wizards. Most of the popular frameworks are supported in NetBeans IDE. It is good to get to know them.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.154.16