How to Write Program and Class in Java Using Netbeans: Easy Steps

How to Write Program and Class in Java Using Netbeans: Easy Steps
Current Bid: $85.00
1st Paperback original. Bill S. Ballinger: Spy in the Java Sea: Signet 295552
Current Bid: $12.05

This is a step by step process on how to program in Java. First, you must have a Java compiler or Java IDE, the word IDE stands for Integrated Development Environment, Java IDE is use to make simple Java projects. There are many Java IDE’s, as for myself, I use Netbeans IDE for my Java programming projects, and in this tutorial I will also use Netbeans IDE as an example on how to program in Java. Either you have Netbeans or other Java IDE’s it does not really matter, what matters is you must have an idea on how to program in Java in order to make some Java simple projects on whatever Java IDE you have. If you do not have an IDE you can download a free Java IDE or better download Netbeans IDE on the web, just look for it; if you want a safe free download you may browse it at, just type cnet: Netbeans IDE on the google search box.

Updated: See how to install and where to download Netbeans IDE for Java Programming here!

How to Program in Java: Complete Simple Easy Steps

Assuming that you now have an installed Netbeans IDE.

Step 1: Open your Netbeans IDE

Step 2: Click FILE located at the left upper side, near the edge, and click the NEW PROJECT.

See all 9 photos
Netbeans IDE Start-up Page

Step 3: Click JAVA at the categories column and click JAVA APPLICATION on the projects column, then click NEXT button below the dialog box. See sample snapshot below.

See all 9 photos
Netbeans IDE snapshot 2

Step 4: Change the name of the PROJECT NAME in the dialog box to whatever names you want that will best describe your ‘will be’ java program, as for this tutorial, I will name the PROJECT NAME ‘javaSampleCoding’. After you finish typing the projects name, click FINISH button below the dialog box. See sample snapshot below.

See all 9 photos
Netbeans IDE Snapshot 3

Step 5: After clicking FINISH, a tab would open which has an embedded name ‘’. The interface should be like this.

See all 9 photos
Netbeans IDE Snapshot 4

On this tab, you can now code your first program. You can copy and paste my code on just click this link in a new tab. There are Java simple codes written there especially made for beginners, But before you proceed, read the NOTE below.

Note: Before you copy and paste the code on the link, make sure that you erase all the codes on the except for the codes in lined with package, as it would duplicate some of the codes if you don’t. The codes on my link above are already complete. You must try first the code that outputs: “This is just an example…” before the second given code. It is just actually like a hello world program. After copying and pasting, your interface should look like this.

See all 9 photos
Netbeans IDE snapshot 5

Step 6: Run it by pressing CTRL + F6 for keyboard shortcut or click RUN -> RUN MAIN PROJECT on the toolbar.

After clicking the RUN, wait a moment. You can see that the program is compiling by looking at the lower left side of the IDE. Then,finally, after a few seconds you can now see the output of the program. It will look like this.

See all 9 photos
Sample Output 1

Related Hubs

Java Tutorial Examples
5 Important Tips to Learn Java Programming and Other Programming Languages
Basic Knowledge Required in Programming
Java Simple Codes for Beginners
Java Tutorial for Beginners: A Beginners Guide on Learning Java Programming
Java Class: Learn More About Classes in Java

If you intend to make a new project, just repeat the steps above. You can experiment on System.out.print(); by changing the text inside it then run again the program to see the word you typed.

To further deepen your experience with Java programming and with Netbeans IDE, you should know how to make a Java class. Almost all of my sample Java source codes are in OOP (Object Oriented Programming), meaning the program is chopped in classes and methods. The codes are divided and is not all placed at the The purpose of programming in this way is for the programmers to easily debug the program. Meaning, if there is something wrong with the program the programmers can easily detect it because the codes are chopped in groups.

Furthermore, to make a program that contains Java class, just repeat the STEP 1 – STEP 5, then proceed to STEP 7 below. But before doing this read first the Note below.

Cool Android Phones!

HTC Droid Incredible Verizon Wireless Wifi 8.0 MP Camera 8GB Android Cell Phone
Current Bid: $64.95
HTC Evo 4G Sprint Android Smartphone 8MP Cam, GPS, Wi-Fi, Bluetooth (Black) B-
Current Bid: $43.00
Verizon Wireless HTC Droid Incredible WiFi GPS 8.0 MP Camera 8 GB Cell Phone
Current Bid: $52.50

Note: As an example for java program which contains class, I will pick the sample java source code for the RECURSIVE DIAMOND SHAPE,This is the link for it. You can name your PROJECT NAME: ‘recursiveDiamondShape’.

Moreover, to identify the codes for java class and the code for main class, find this sign ->//java class, and all the codes below it are java class codes and stop copying if you see this sign-> //main class, because the preceding codes below it is for

Now ready? After completing the STEPS 1-5, proceed to next step below.

STEP 7: Bring your cursor to PROJECTS, located at the left upper side just below the tool bar. Click it, then find your PROJECT NAME which is ‘recursiveDiamondShape’ click it, you will see SOURCE PACKAGES folder, then below it is the folder which name ‘recurseiveDiamondShape’, your program’s name. RIGHT CLICK it, then NEW-> then JAVA CLASS -> then name the CLASS NAME this: ‘Diamond’ then click FINISH button below, after that, a new tab will open at your Netbeans IDE which has a name

For your, copy and paste the //java class codes on the link below. The interface for the, after the copy and paste, should look like this.

See all 9 photos half body snapshot

For your, make sure to erase all except for the code in line with package. The interface for the should look like this.

See all 9 photos full body snapshot

Then run the program by CTRL + F6 while you are on the interface, the sample snapshot for the output looks like this.

See all 9 photos
Program’s output full body snapshot

The program’s output look like the snapshot above if the entered number is 12, to test the program again, just click Run, or CTRL + F6 and enter the number you want then hit ENTER on the keyboard.

Is this hub clear to you?

See results without voting

Java Video Tutorial

Java Programming Video Training tutorials CBT 30+ Hrs
Current Bid: $4.99
Advanced Java Programming Video Training tutorials CBT – 30+ Hrs – Master level
Current Bid: $4.99
Learn JAVA language -14h video & docs tutorials
Current Bid: $4.59

Java Books

Introduction to Java Programming, Comprehensive Version 9e by Y. Daniel Liang
Current Bid: $50.80
Java Programming Lab Manual by Blayne Mayfield Third Edition
Current Bid: $14.99
Programming with Java : A Multimedia Approach by Radhika S. Grover (2011,…
Current Bid: $.99

Other Java Source Codes Examples

Java Simple Codes for Beginners
Java source code: Print Different Asterisk Shapes in Recursion
Java Source Code: A Recursive Asterisk Diamond Shape
Java Source code: How to Add Numbers inside an Array using For Loop
Java Source code: How to Add numbers inside an Array Using Recursion
Java Source code Print String Backward using Recursion
Java Source Code on a Recursive Linear Search
Java Source Code: Binary Search in Recursion
Java Source Code: Sort Numbers in Bubble Sort
Java Source Code: Sort Numbers using Selection Sort
Java Source code on Printing the Greatest Common Divisor (GCD) using Recursion
Java source code: Recursive function for X to the power Y
Java Source Code Determine Person’s Salutation and Current Age
Java Source Code: Recursive Koch Snow Flakes