Study Guide: Object Oriented Programming (OOP)
Study Guide: Object Oriented Programming (OOP)
Polangui, Albay
STUDY GUIDE
Study Guide #2
Lesson 2: The NetBeans IDE 8.0.2 Software
Topics covered:
Loading NetBeans IDE 8.0.2 for the first time
Creating a New Project
Java Comments
The Structure of Java Code
Running a Java Program
Sharing a Java Program
Objectives:
Lesson 2.1: Loading NetBeans IDE 8.0.2 for the first time
To load NetBeans IDE for the first time, there are several ways to consider, using Desktop, Start
Menu, and etc…
Using the Desktop: Double Click the icon Apache NetBeans IDE 11.3 or right click then click
Open to load NetBeans IDE.
Using the Start Menu: Click the Start Menu button, then look for the Apache NetBeans IDE
11.3 program from the list and then Click it.
Desktop:
Double Click
Desktop:
Right Click
The NetBeans IDE 2.0.8 (When you first run NetBeans)
File
New Project
2. The New Project window appears, select Java from the Categories: box, select Java Application
from the Projects: box, then click Next button.
Java
Java Application
Next
3. The New Java Application window appears, in the Project Name area, type the name of your
project. Project Location area is the default location to save your projects, you can change this if
you prefer. Project Folder area is also created by NetBeans with your project name. Click the
Finish button.
Project Location
Project Folder
Project Name
Finish Button
4. The NetBeans IDE 8.0.2 appears, which is compose of the Project Area and Coding Window.
You are now ready to work.
Example 1:
/*
This is a comment spreading
Over two lines or more
*/
Example 1:
/**
*this is a Javadoc comment
*/
NOTE: You can delete the comments that NetBeans generates for you.
2. The Package name is coded first, and notice the semicolon (;) at the end of the line, program will
not run if you miss semicolon:
package Program1;
3. The Class name, you can think of a class as a code segment, you should begin and end with a left
and right curly brackets. Anything inside the left and right curly brackets belong to that code
segment:
4. The Main Method, it is here the action begins, it is the main entry point for your program, it will
execute any codes within the curly brackets. You will get error messages if your do not have a
main method on your Java code:
public static void main(String[] args) {
When you type the full stop after “System”, NetBeans will try to help you by displaying a list
of available options:
2. Double click out to add it to your code, then type another full stop. Again a list of options
appears. Select println, this time.
3. Type your text ("My First project in Java"); and end it with semicolon, each complete line of code
in Java needs a semicolon at the end, miss out and the program will not compile.
4. Save your code, click File>Save or File>Save All or click the Save button in the toolbar.
5. There are a lot of ways to run a Java program, you can use any of the following:
Run
Run Project
Right Click Java source file in the Project window, then select Run File.
Source File
Run File
Lastly, is to Right Click inside the Code Area or Code Window, then Select Run File.
Code Area/Window
Run File
6. Using one of the above methods, execute or run your program. The possible output is shown in
the Output Window below:
1. Click Run menu at the top, select Clean and Build Project or press Shift+F11 from the keyboard.
The Run
menu
2. NetBeans save your work and then creates all the necessary files.
3. It will create a folder called dist and places all the file in there.
4. Look for the dist folder in your computers Documents Folder>NetBeansProjects>Program1
NetBeans project.
5. Double click the dist folder to display files inside the folder.
Location of
the dist
Files folder
Activity No. 1: Using NetBeans, create a class named: [YourName]. The program should output on the
screen:
Activity No. 2: Using NetBeans, create a class named: TheTree. The program should output the
following lines on the screen:
Things to do: Submit a screenshot of your codes and output in our Google drive under activity folder.
References:
1. https://www.homeandlearn.co.uk/java/getting_started_with_java.html
2. NetBeans IDE 8.0.2