● The Java SE Development Kit (JDK) is required to install before you install your
NetBeans.
● System Requirements Operating System: Windows XP SP3, Windows Vista SP2,
Windows 7, Windows 8.0, Windows 8.1, and Windows 10. CPU: Pentium processor at
90 MHz or higher Memory:16 MB RAM
STEPS ON DOWNLOADING JDK:
1. Download Java 8 from Oracle's Java official website (You will see two options, 32- and
64-bit versions for download).
*Oracle does not permit you to download older versions of Java such as Java 8 without
being registered with Oracle. Thus, it is better to have an account.
2. Start the installation process by double clicking it. You will see the installation wizard
3. You can modify certain installation defaults. To alter the installation directory, click on
change.
*installation begins.
4. Specify the default installation folder for JRE by accepting the default >> next.
5. After this the installation will proceed. Wait for some time for the installation process to
be completed.
6. You will see the Installation complete message and then click the close button.
● After you installed the JDK on your computer, you need to install Netbeans 8.2.
● Netbeans is a popular Java Integrated Development Environment (IDE).
● It is a software tool to compile your java program, but the actual compilation is
accomplished by using Java JDK.
STEPS ON DOWNLOADING NETBEANS:
1. You can download Netbeans 8.2 from the Netbeans official website. For beginners
choose the first entry "Java SE".
2. To install, give the Windows permission and on the installer, windows click on Next to
download the Required file to setup.
3. Place a check on “I accept the terms in the license agreement”
4. You get an option to change the installation directory. You can modify the location of the
installation by clicking browse.
5. Click next to continue.
6. A summary of all options is given on the next screen, review first.
7. After the installation completes click on Finish to complete the setup process.
‘
STEPS ON CREATING PROJECT:
1. Open your Netbeans IDE.
2. choose File > New Project
3. expand the Java category and select Java Application
4. Write your project name
5. Finish button.
NETBEANS IDE COMPONENTS
1. Project Window – you will see a tree view of the components of the created project, among
them the source files, libraries, test packages, and test libraries.
2. Source Window – you will be able to see the program code of the existing file that you are
working on.
3. Navigator window – you could use it to quickly navigate among elements within the selected
class.
JAVA PROGRAM STRUCTURE
Java Source Package – it is a directory which includes all your Java source and class files of
your classes that belong to the same package. There may only be one package statement in a
Java program, and it must be at the beginning of the code before any class declaration.
Class – Your code must be inside the class body for the Java runtime engine to run it. Every
programs in Java will contain at least one class along with the main method. The entire class
must be surrounded by curly brackets.
Main Method- It is considered as the entry point of the Java program. When you run the
program, it will start from the main method (). It also is defined within curly braces.
System.out.print – it is used to output text (strings) in the same line
System.out.println – it is used to output text (strings) and moves cursor to the next line
COMPILING JAVA PROGRAM
1. compiling your program just click on Run then Build Project or F11.
● Once you create your program, it will automatically be compiled when you save it. You
do not need to build your project to run in your Netbeans IDE. To disable the automatic
compilation of your program and activate your Build command, just go to project
properties and uncheck compile on save then click OK.
● If there is no error in your program, the Output window will display a successful
message.
DEBUGGING JAVA PROGRAM
The common error you may encounter is syntax error (i.e. misspelled a Java command or forgot
to write the semicolon at the end of your declaration, capitalization, spelling, the use of
inaccurate special characters, and error of correct punctuation.)
RUNNING PROGRAM
1. Click run project (green play button)/right click then choose run file/use F6 or Shift + F6
CREATE JAVA CLASS IN EXISTING JAVA PROJECT
1. Right click your existing project. Choose New >> Java Class
2. Write class name >> finish button
DECLARING AND INITIALIZING
1. In declaring your variable, you need to follow the syntax stated below: [= initial value];
2. Before you declare a variable, be sure that you declared the main method
DISPLAYING VARIABLES
1. Use System.out.println or System.out.print.
USING SCANNER
- use the Scanner class found in the java.io package to get input from the keyboard.
- The Scanner class in Java is located in the java.util package.
- Java provides different ways to read input from the keyboard, the java.util. Scanner class
is one of them
- Scanner class provides various methods that allow us to read inputs of different data
types.
1. ADD import.java.util.Scanner at the top of the code
* Java Application Programming Interface (API) contains hundreds of predefined classes which
you can use in your programs. These classes are arranged in what we call packages.
*The java.io package contains classes that allow programs to input and output data. The
statements can also be rewritten as, import java.io.*; which will load all the classes found in the
package, and then you can use those classes inside your program.
2. Add Scanner in = new Scanner (System.in), this is a way to create an object for your
scanner. Make sure your object name used will be distinct to your variable declarations
to eliminate syntax error.
3. Declare variables the same in the illustration below.
● variable names are initialized to an empty String "" and set the integer value to 0.
It is always good to initialize your variables as you declare them
4. the next line will output String on the screen asking for the user's input.
5. the last line will display a String which contains the values stored in your variables.
6. Run
METHODS AND THEIR PURPOSE
1. nextLine() - reads a line of text
2. nextInt() - reads integer value
3. nextDouble() - reads a double value
4. next() - reads a word
5. nextFloat() - reads float value
6. nextBoolean () - reads boolean value
7. chartAt(0) - reads specified or defined index