ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

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

Updated on November 12, 2019
dwachira profile image

Danson Wachira is a certified Trainer in Computer Science, Information Technology and related studies.

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

_______________________________________

Source

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

Source
Source

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

Source

There you go, Java Successfully installed!

Java NetBeans icon
Java NetBeans icon | Source

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.

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

Comments

    0 of 8192 characters used
    Post Comment
    • profile image

      deepika 

      5 years ago

      awesome....

    • profile image

      Cool Roy 

      5 years ago

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

    • profile image

      milton barua. 

      5 years ago

      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.

    • profile image

      Philip 

      6 years ago

      Thanks a lot a very great tutorial,

    • profile image

      Mamitha 

      6 years ago

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

    • profile image

      Rick 

      6 years ago

      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!

    • profile image

      Rick 

      6 years ago

      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!

    • profile image

      ahmad 

      6 years ago

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

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

    • dwachira profile imageAUTHOR

      Danson Wachira 

      6 years ago from Nairobi, Kenya

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

    • profile image

      Alasker 

      6 years ago

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

    • Larney profile image

      Larney 

      6 years ago

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

    • profile image

      Nebnoma 

      6 years ago

      Hi!

      Thanks for this amazing tutorial!!!

    • dwachira profile imageAUTHOR

      Danson Wachira 

      6 years ago from Nairobi, Kenya

      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.Tesol profile image

      Brett C 

      6 years ago from Asia

      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.

    • dwachira profile imageAUTHOR

      Danson Wachira 

      6 years ago from Nairobi, Kenya

      Hi BRIAN,

      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.

    • profile image

      BRIAN 

      6 years ago

      IN A WEEK,,HOW MUCH DID U UPDATE THE LESSON?

    • dwachira profile imageAUTHOR

      Danson Wachira 

      6 years ago from Nairobi, Kenya

      Hi Bala,

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

    • dwachira profile imageAUTHOR

      Danson Wachira 

      6 years ago from Nairobi, Kenya

      Hi sol,

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

    • profile image

      Bala 

      6 years ago

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

    • profile image

      ahmad 

      6 years ago

      u so good man

    • dwachira profile imageAUTHOR

      Danson Wachira 

      6 years ago from Nairobi, Kenya

      Hi Anuradha,

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

    • profile image

      Anuradha 

      6 years ago

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

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

    • profile image

      sol 

      6 years ago

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

    • dwachira profile imageAUTHOR

      Danson Wachira 

      6 years ago from Nairobi, Kenya

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

    • profile image

      sami2013 

      6 years ago

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

      thank you again bro

    • profile image

      hasin masin 

      6 years ago

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

    • profile image

      dj 

      6 years ago

      thanks, it is kl tnx

    • dwachira profile imageAUTHOR

      Danson Wachira 

      6 years ago from Nairobi, Kenya

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

    • profile image

      jennifer2223 

      6 years ago

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

    • dwachira profile imageAUTHOR

      Danson Wachira 

      6 years ago from Nairobi, Kenya

      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.

    • profile image

      Michelle 

      6 years ago

      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.

    • profile image

      Neville 

      6 years ago

      Awesome

    • profile image

      manan 

      6 years ago

      this is good info

    • dwachira profile imageAUTHOR

      Danson Wachira 

      6 years ago from Nairobi, Kenya

      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.

    • profile image

      Max Cline 

      6 years ago

      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)

    • dwachira profile imageAUTHOR

      Danson Wachira 

      6 years ago from Nairobi, Kenya

      Hi Shahriyar Mehdi,

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

    • profile image

      Shahriyar Mehdi 

      6 years ago

      thank you!!!!!!!

      Baku, Azerbaijan

    • profile image

      Max 

      6 years ago

      Very detailed and useful!

    • dwachira profile imageAUTHOR

      Danson Wachira 

      6 years ago from Nairobi, Kenya

      Hi ahmad,

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

    • profile image

      ahmad 

      6 years ago

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

    • dwachira profile imageAUTHOR

      Danson Wachira 

      6 years ago from Nairobi, Kenya

      Hi programmingpad,

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

    • programmingpad profile image

      Priya Singh 

      6 years ago from US

      Nice Tutorials....:)

      very Informative and helpful for java beginners..

      thank You Dwaricha

    • dwachira profile imageAUTHOR

      Danson Wachira 

      7 years ago from Nairobi, Kenya

      Hi yatramantra,

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

    • profile image

      yatramantra 

      7 years ago

      thanks for this java tutorial :)

    • dwachira profile imageAUTHOR

      Danson Wachira 

      7 years ago from Nairobi, Kenya

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

    • profile image

      MSuthaN 

      7 years ago

      how to download this.....

    • dwachira profile imageAUTHOR

      Danson Wachira 

      7 years ago from Nairobi, Kenya

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

    • sparkster profile image

      Marc Hubs 

      7 years ago from United Kingdom

      Fantastic tutorial, this should come in very useful.

    • dwachira profile imageAUTHOR

      Danson Wachira 

      7 years ago from Nairobi, Kenya

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

    • Petfriends profile image

      Petfriends 

      7 years ago from New England Area

      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.

    • dwachira profile imageAUTHOR

      Danson Wachira 

      7 years ago from Nairobi, Kenya

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

    • Angela Brummer profile image

      Angela Brummer 

      7 years ago from Lincoln, Nebraska

      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+.

    working

    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, hubpages.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://hubpages.com/privacy-policy#gdpr

    Show Details
    Necessary
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
    Features
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Marketing
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Statistics
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
    ClickscoThis is a data management platform studying reader behavior (Privacy Policy)