Skip to main content

Programming in Java Netbeans - A Step by Step Tutorial for Beginners

Danson Wachira is a certified Trainer in Computer Science and Safari enthusiast.

Welcome to this online tutorial on Programming in Java NetBeans. This tutorial will take you on step-by-step lessons covering specific topics in Java programming that are aimed at providing the fundamental skills needed for beginner programmers in Java.

The tutorial has simple explanations and includes copy and paste Java source code examples that are easy to follow. At the end of most lessons, exercises are provided to help the learner with more practice in Java programming.

If you would like more help on Java programming, you can send a mail on my profile page. I hope you shall find this tutorial being helpful. Please share, Pin it or Bookmark this tutorial to help others. You may also leave a comment here below.

Lesson 1 starts below after the Table of Contents.


Table of Contents


Lesson 1: Introduction to Java NetBeans IDE

Lesson 2: Understanding Java Code Window

Lesson 3: Writing Java Program

Lesson 4: Working with Variables in Java

Lesson 5: Working with user inputs in Java

Lesson 6: Working with Java Option Panes

Lesson 7: Control Structures in Java – IF statement

Lesson 8: Control Structures in Java – IF ... ELSE statement

Lesson 9: Control Structures in Java SWITCH statement

Lesson 10: Control Structures in Java – FOR Loop

Lesson 11: Control Structures in Java – WHILE Loop

Lesson 12: Control Structures in Java – DO…WHILE Loop

Lesson 13: Implementing Arrays in Java

Lesson 14: Manipulating Java arrays using loops

Lesson 15: Sorting values in Java arrays

Lesson 16: Multi-dimensional arrays in Java

Lesson 17: Arrays of string type in Java

Lesson 18: Arrays lists and iterators in Java

Lesson 19: Methods toUpperCase() & toLowerCase() in Java

Lesson 20: How to compare string values in Java

Lesson 21: How to search for a character or string in Java

Lesson 22: How to use substring() method in Java

Lesson 23: How to use equals() and charAt() methods in Java

Lesson 24: How to use replace() method in Java

Lesson 25: User defined methods (UDMs) in Java

Lesson 26: How to implement User Defined Methods in Java

Lesson 27: Working with classes in Java

Lesson 28: Java class constructors and setter methods

Lesson 29: More on Java classes and methods

Lesson 30: Java and Inheritance

Lesson 31: Types of programming errors

Lesson 32: How to handle errors in Java programming

Lesson 33: How to handle logical errors in Java

Lesson 34: How to read a text file in Java

Lesson 35: How to write into text files in Java

Lesson 36: How to create GUI Java forms

Lesson 37: Working with GUI controls: Label and Text field

Lesson 38: Working with GUI controls: Command buttons

Lesson 39: Working with GUI controls: Combo box

Lesson 40: Working with GUI controls: Check box & Text area

Lesson 41: Working with GUI controls: Radio buttons

Lesson 42: Working with GUI controls: Java Menus

Lesson 43: Working with Java Open File dialog box

Lesson 44: How to Customize Java Open File dialog box

Lesson 45: Using Java Open File dialog box to open files

Lesson 46: Using Java Save File dialog box to save files

Lesson 47: Java NetBeans and Databases

Lesson 48: Creating databases and tables in Java NetBeans

Lesson 49: Java NetBeans And SQL Commands

Lesson 50: Creating a database connection in Java NetBeans

Lesson 51: How to connect to a database in Java NetBeans

Lesson 52: How to connect Java forms to database in Java

Lesson 53: How to code for table navigation buttons in Java

Lesson 54: How to code for table Update button in Java

Lesson 55: How to code for Cancel and New buttons in Java

Lesson 56: How to code for Save and Delete buttons in Java



Lesson 1: Introduction to Java NetBeans IDE

This tutorial is aimed at beginners who may wish to start their career as programmers in Java applications. The tutorial assumes no prior knowledge in Java programming language and contains step by step instructions which are easy to follow.

The first thing you need to do is to prepare the environment for developing Java applications. You need to install and setup Java Netbeans IDE (Integrated Development Environment).

Java NetBeans is the platform that you will to write your Java code and applications. Java NetBeans is one of the most popular Java Environment for developing Java applications. For the purpose of this tutorial, we are going to use Java NetBeans 7.

Java is increasingly becoming the world’s programming language of choice. It has been used in developing desktop applications, client-server applications and even mobile phone applications including games.

One major advantage of programming using Java is that Java is platform independent, that means when you write your application in Java it can run on any other environment e.g. Windows, Linux or Mac. This is so because Java has its own Runtime Environment popularly known as Java Virtual Machine (JVM).

You need to download JVM and install on your machine. Java is owned by Sun Microsystems so to download Java Virtual Machine and the Java Development Kit (JDK), you can download using this link.

Check first if you have Java Runtime Environment (JRE) in your machine by clicking the link "Do I have Java?" This link is under the big red “Free Java Download” button at the top of the page. The download may take time due to its big size (about 140MB).


How to install Java

1. Once you have downloaded the Java Virtual Machine (JVM) and Java Development Kit (JDK), install JVM first. (You can skip this step if you already have JVM in your machine).

2. Restart your machine and install Java Development Kit (JDK). Be patient as it may take some time before JDK is installed.

Select the location of where to install Java NetBeans

Scroll to Continue

Java takes some time to install so be patient and don't interrupt.


There you go, Java Successfully installed!

Java NetBeans icon

Java NetBeans icon

After everything is installed and running correctly, now it is time to learn about Java programs. You will write your code in a text editor. In the NetBeans there is a code editor that you will use to write your code.

The Java code you are going to write is called a source code, and is saved with the file extension .java.

The source code is then compiled by another program called Javac and turned into a Java byte code that has a file extension .class if no errors are encountered. This class file is the one that is usually run on the Java Virtual Machine.

Don’t worry how you are going to do all these, once you write your source code in the Java code editor, Java will handle the code compiling and running of your program. Java will even alert you if there is an error.

Now, double click the NetBeans icon on your desktop to open the Java Netbeans IDE. You are ready now to start learning Java programming using NetBeans. Lets meet in Programming in Java Lesson 2.

Lesson 2 >>

Want to make money online?

This content is accurate and true to the best of the author’s knowledge and is not meant to substitute for formal and individualized advice from a qualified professional.

© 2012 Danson Wachira


deepika on January 19, 2014:


Cool Roy on January 14, 2014:

its awesome bro... thank you soooooooooooooooo much.....

milton barua. on January 02, 2014:

I am a very none programmer.I have been watching science two years ago a good , easy and comprehensible java programming tutorial.

At last I found your step by step programming tutorial for beginners. It is "VERY VERY HELP"me to learn java .I have finished it 1 to 56 lessons.Now I start it again to learn very clearly.

thank you sir.

Philip on November 13, 2013:

Thanks a lot a very great tutorial,

Mamitha on October 10, 2013:

Java Lessons are good.Add J2EE Tutorials if possible . Thank You for sharing

Rick on August 27, 2013:

If I may give u some suggestions: Could you add some lessons on how to fill a jTable properly using the output of some methods from our program? And also could you add a lesson on how to create proper JavaDoc? Thx man!

Rick on August 27, 2013:

This tutorial is so clearly written and easy to understand. One of the best Java tutorials I have seen so far. Thank you for sharing your knowledge with us man!

ahmad on August 03, 2013:

hello there.. thx man.. i got an a- on my object oriented programming...

bcuz of u,, i manage get a.. thx again man.. :)

Danson Wachira (author) from Nairobi, Kenya on July 26, 2013:

Hi Thanks for the visit, this tutorial can not be downloaded for now.

Alasker on July 26, 2013:

Hi, thank you for this amazing tutorial! .How i can download it?

Larney on June 16, 2013:

I seriously love this tutorial !! It is extremely helpful !! Is there anyway I can download all the lessons in order to print it??

Nebnoma on June 15, 2013:


Thanks for this amazing tutorial!!!

Danson Wachira (author) from Nairobi, Kenya on May 13, 2013:

Hi Brett, when i was in school i wished if i could get the information i was looking for all at one place. I guess i am just trying what i imagined then. Thanks for the visit and comment.

Brett C from Asia on May 13, 2013:

This is amazing for anyone wanting to learn Java. You really have put together an extensive guide that talks to people in easily understood terms. I have bookmarked it to follow the rest and see if it is something I enjoy.

Shared, pinned, tweeted, up, useful and AWESOME.

Danson Wachira (author) from Nairobi, Kenya on April 30, 2013:


It depends on how much work is needed to craft a lesson, some just takes hours while others can take days. Thanks for the visit and query.

BRIAN on April 29, 2013:


Danson Wachira (author) from Nairobi, Kenya on April 26, 2013:

Hi Bala,

More lessons coming up soon, thanks for stopping here and commenting.

Danson Wachira (author) from Nairobi, Kenya on April 26, 2013:

Hi sol,

MySQL or SQL server will be probable choices for database. Thanks for the visit and comment.

Bala on April 26, 2013:

Many thanks. This tutorial is very helpful. But it is good if you post further lessons

ahmad on April 25, 2013:

u so good man

Danson Wachira (author) from Nairobi, Kenya on April 25, 2013:

Hi Anuradha,

Glad that this tutorial is helpful. Thanks for the visit and comment.

Anuradha on April 25, 2013:

thanks a lot dear.........

I love this proggamming site a I am a teacher...It helps me a lot.

sol on April 24, 2013:

can i ask? what is the easiest database to use in java??

Danson Wachira (author) from Nairobi, Kenya on April 23, 2013:

Ahh! really? All the same, thanks for the visit and comment.

sami2013 on April 23, 2013:

Thank you so much sir your explanation is better than my teacher

thank you again bro

hasin masin on April 11, 2013:

hello bro.. can u show how to use a progress bar ?

dj on April 10, 2013:

thanks, it is kl tnx

Danson Wachira (author) from Nairobi, Kenya on March 30, 2013:

Thanks, am glad it was helpful. I do appreciate the visit and comment.

jennifer2223 on March 30, 2013:

It is very much useful for java beginners. java training in chennai.

Danson Wachira (author) from Nairobi, Kenya on March 21, 2013:

Hi Michelle,

I know how it feels to look for something over the net and not finding it, i have been there too. Am glad that this tutorial was helpful. Thanks for the visit and comment.

Michelle on March 21, 2013:

Thank you so much for taking the time to post this. I'm majoring in computer science and wanted to learn some basic programming before starting my first programming class. This is a very easy to follow guide. I love programming! I'm having so much fun with it.

Neville on March 15, 2013:


manan on March 02, 2013:

this is good info

Danson Wachira (author) from Nairobi, Kenya on February 27, 2013:

Hi Max Cline,

I was once in your place, looking for worthy materials over the internet and and i know it can take time before one get a concrete tutorial. Although i would have liked this tutorial to be better than this, it is positive comments like your that reminds me i still have to make it better and better. I wish you all the best in your computer engineering program, you shall make it. Thanks for the visit and comment.

Max Cline on February 27, 2013:

I must say, I have never in my life picked up an IDE but I have been able to clearly follow your lessons and am really having a lot of fun. I am starting a computer engineering program next month so I really appreciate that someone out there has created such a clear and easy to follow guide. THANK YOU SINCERELY!

(I spent hours looking for a good guide, yours was the only one I was able to find that started in the correct place and actually continued beyond the very first lesson)

Danson Wachira (author) from Nairobi, Kenya on January 29, 2013:

Hi Shahriyar Mehdi,

Thanks for the visit and comment. I hope you found this tutorial being helpful.

Shahriyar Mehdi on January 29, 2013:

thank you!!!!!!!

Baku, Azerbaijan

Max on January 21, 2013:

Very detailed and useful!

Danson Wachira (author) from Nairobi, Kenya on January 21, 2013:

Hi ahmad,

Thanks for the visit and comment, i will add Lesson 41 and 42 shortly. Check later please.

ahmad on January 21, 2013:

hey there.. thanx for being help!! :) im just wondering,,where is lesson 41?

Danson Wachira (author) from Nairobi, Kenya on January 20, 2013:

Hi programmingpad,

Thanks for the visit and comment, am glad that this tutorial was helpful.

Priya Singh from US on January 20, 2013:

Nice Tutorials....:)

very Informative and helpful for java beginners..

thank You Dwaricha

Danson Wachira (author) from Nairobi, Kenya on October 21, 2012:

Hi yatramantra,

Thanks for visiting my tutorials on Java programming. Enjoy your day!

yatramantra on October 21, 2012:

thanks for this java tutorial :)

Danson Wachira (author) from Nairobi, Kenya on September 29, 2012:

@MSuthaN, thanks for the visit but am sorry you can't download this tutorial for now.

MSuthaN on September 28, 2012:

how to download this.....

Danson Wachira (author) from Nairobi, Kenya on July 05, 2012:

Thanks sparkster for stopping by and reading, I'm glad you enjoyed it.

Marc Hubs from United Kingdom on July 05, 2012:

Fantastic tutorial, this should come in very useful.

Danson Wachira (author) from Nairobi, Kenya on June 23, 2012:

Petfriends, i think the world is being taken by programming, everything seems to be about a program. Thanks for reading.

Petfriends from New England Area on June 22, 2012:

Ok, I'm coming back to really "read" this (maybe I should say comprehend) when I've had a little more coffee. I'm intrigued by this world and want to know more. Thanks for sharing.

Danson Wachira (author) from Nairobi, Kenya on June 22, 2012:

Angela Brummer, you will never stop amazing me with your kindness and generosity. Thanks for sharing.

Angela Brummer from Lincoln, Nebraska on June 22, 2012:

Thank goodness that some of us (meaning you) grasp such concepts and are able to share them so clearly! I am here to give you some hub love by sharing with hub following, twitter, facebook and google+.

Related Articles