In this exercise, you are going to build a simple Hello application using NetBeans IDE.
1.
Start NetBeand IDE
2.
Create a NetBeans project
3.
Build and run the program
(1.1) Start NetBeans IDE
1. Double
-
click NetBeans IDE Icon on the desktop to start the NetBeans IDE. Observe the NetBeans
IDE gets started.
(Figure
-
2.10 below)
Figure
-
2.10: NetBeans IDE
(1.2) Create a NetBeans project
1. Select
File
from top
-
level menu and select
New Project
or press
Ctrl+Shift+N
.
(Figure
-
2.20
below)
Figure
-
2.20: Create New Project
2. Observe that the
New Project
dialog box appears.
3. Select
J
ava
under
Categories
section and
Java Application
under
Projects
section. (Figure
-
2.21
below)
4. Click
Next
.
Figure
-
2.21: Create Java Application project
5. Under
Name and Location
pane, for the
Project Name
field, enter
MyHelloProject
.
6. For the
Create Main Class
field, enter
Hello
.
(Figure
-
2.22 below)
For
Project Location
field,
which indicates the directory in which you are creating a NetBeans project, you can leave it as it is.
7. Click
Finish
.
Figure
-
2.22: Give a project name
8. Observe
that the
MyHelloProject
node is created under
Projects
pane of the NetBeans IDE.
9. Modify the IDE generated
Hello.java
as shown in Figure
-
2.23 below.
The code fragment that you
want to add is highlighted in
bold and red
-
colored font
.
public
class Hello {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println("This is my first Java program!");
}
}
Figure
-
2.23: M
odified Hello.java
10. Introduce a syntax error in the program and observe that NetBeans IDE immediately highlights
the problem as shown in Figure
-
2.24 below.
It detects that the keyword
void
is misspelled as
voidx
.
Figure
-
2.24: NetBeans
IDE detects a syntax error (compile error)
11. Remove the syntax error.
(1.3) Build and run the program
1. Right click
MyHelloProject
and select
Run
. (Figure
-
2.30 below)
Figure
-
2.30: Build and run the project
2. Observe that the
Hello.java
is compil
ed and then run.
(Figure
-
2.31 below)
Figure
-
2.31: Result of running the MyHelloProject
Summary
In this exercise,
you have built and run Hello Java application using NetBeans IDE.
Enter the password to open this PDF file:
File name:
-
File size:
-
Title:
-
Author:
-
Subject:
-
Keywords:
-
Creation Date:
-
Modification Date:
-
Creator:
-
PDF Producer:
-
PDF Version:
-
Page Count:
-
Preparing document for printing…
0%
Σχόλια 0
Συνδεθείτε για να κοινοποιήσετε σχόλιο