Introduction to Netbeans



Introduction to Netbeans

0 0


CSCI5828_Netbeans

CSCI 5828 Fall 2015 Presentation on the Netbeans IDE

On Github dSouthard / CSCI5828_Netbeans

Introduction to Netbeans

Presented by Diana Southard

CSCI 5828, Presentation 3, Fall 2015

Table of Contents

Getting Started Setting up a Project Creating a Class Running the Program Advantages of Netbeans Conclusion Sources

Getting Started

First, need to download the program at Netbeans.org

This program works on any platform with a Java Virtual Machine. This tutorial will use screenshots from Ubuntu running Netbeans 8.0.2. Follow the download instructions on the website.

Setting up a Project

Assume that you have successfully installed NetBeans on your machine. Start NetBeans. The NetBeans main window should appear, as shown below.

Here are the steps to create a demo project:

  • Choose File, New Project to display the New Project dialog box.
Select General in the Categories section and Java Application in the Projects section and click Next to display the New Java Application dialog box. Type desired project name in the Project Name field and desired location in Project Location field.
Click Finish to create the project. The new project is displayed

Netbeans automatically includes a customizable license header at the top of each new file. It also automatically includes relevant comments before auto-created classes/methods (author, parameter descriptions, etc.)

Creating a Class

Here are the steps to create a new Java class in the demo project:

  • Choose File, New File to display the New File dialog box.
Check that in the Project drop-down menu, the demo project is currently displayed. Otherwise, use the menu to select the demo project. In the Categories menu on the left, select Java. In the File Types menu on the right, select Java Class. Then select Next to display the New Java Class dialog box.
In the New Java Class dialog box, enter in the desired name for the new class in the Class Name field. Check again that the demo project is selected in the Project field, and that the new class is being created in the same location as the demo project as indicated in the Created File field. (These fields are auto-populated and should be correct). Click Finish.
The new class is created and displayed.

If you start to use classes whose packages have not yet been imported, Netbeans highlights the discrepancy and then suggests importing the class.

You can place your cursor onto the word that is underlined in red, hit Alt-Enter on the keyboard for a list of suggestions on how to correct the error, and then hit Enter again for the program to automatically include the import.

One nice thing about Netbeans is the auto-generated code that is capable of being done by the program. If, in your new class, you had several private variables, as seen in the previous two figures, it is easy for the program to automatically create Getter and Setter methods.

You can either right click on the desired variable and select Insert Code from the menu, or place your text cursor in the word and hit Alt-Insert on the keyboard to immediately bring up the Generate menu.

Netbeans is capable of generator Constructor, Logger, Getter, Setting, toString and other commonly-used methods. Selecting one of these options brings up the associated Generate __ dialog box, which also gives you the ability to generate the same methods for other variables to save you time. It also gives the option to automatically encapsulate the fields!

With just a few seconds and a few clicks on the mouse, the most trivial methods of my class can be created for me!

Running the Program

To compile the project, select Run and choose Compile File, or simply press F9. Providing no errors were found, the Output pane will display a successful build message.

To run the project, select Run and choose Run File, or simply press Shift + F6. The output is displayed in the Output pane.

To insert debugging breaking points, simply click on the line number to the left of the code you are debugging. Netbeans allows for variable watching, stepping through/over code, and running the code to a desired line while debugging.

Advantages of Netbeans

There are many advantages to using Netbeans, such as the ones listed below:

  • powerful built-in Profiler
  • natively supports Ant and Maven
  • excellent support for the latest Java EE features, no need to download plugins
  • excellent integration with GlassFish/JBoss/Tomcat/WebLogic
  • Ant debugger
excellent support for JavaFX code completion with JPA and queries includes new features for editing/debugging HTML5 rich framework for building desktop Java applications written using Swing built-in support for version control systems clean intuitive UI can actually change settings in NetBeans to have it use 'Eclipse' shortcuts, if you’re really used to using Eclipse extensive online community for help solving problems

Conclusion

Netbeans can sometimes be an overlooked IDE, compared to others such as Eclipse. Hopefully this presentation provided some basics on how to use it as well as some reasons to give it a try!

Sources

  • Screenshots were all taken on my own laptop.
  • Basics of Netbeans were adapted from Netbeans' Quick Start Tutorial, as well as from personal experience.

Thank You

0 out of 24
Introduction to Netbeans Presented by Diana Southard CSCI 5828, Presentation 3, Fall 2015