Java Programming on NetBeans IDE

We have learnt how to execute a simple Java program in a command prompt. But most of the people freak out at the thought of the “black screen” and the trouble of remembering the commands!!!

I have a solution for them here – NetBeans.

What is NetBeans?

NetBeans is a software that allows you to run Java programs and build Java application in a more graphically presentable and easy-to-use environment. Technically speaking it is an Integrated Development Environment (IDE) which serves as a platform for Java programming, Java Stand-alone Application development, Web Application, Enterprise Applications and many more.

Here we will just focus on how to run a java program using NetBeans.

What is an IDE?

IDE or Integrated Development Environment is a software application that can be used by programmers for software development. The main advantage of using an IDE is that it can integrate the different units of an application to be developed and also helps integrating different tools required for the purpose.

The most popular IDEs for Java Application development are NetBeans and Eclipse. Here we going to work on it and am sure you won’t find the other IDEs much too different. So let’s get started!

Steps to write a program in NetBeans

  • Installing
    • Java Development Kit (JDK) should be installed in the system
    • NetBeans IDE should be installed

[Both are available online for download]

After installing these we will find the NetBeans IDE icon like this:

Java Programming on IDE

NetBeans IDE

The version can be newer that the one shown, like 7.2 or 7.3.

  • Creating a project
    • Open the IDE
Java Programming on NetBeans IDE

NetBeans Window

  • Go to the File menu at the top left corner of the screen.
  • Select the New Project option:
Opening Java Project in NetBeans

Opening Java Project in NetBeans

  • New Project dialog box appears. Select Java under ‘Categories’ and Java Application under ‘Projects’. Click the next button:
Opening Java Project in NetBeans

Opening Java Project IDE

  • New Java Application dialog box appears. Here we have to enter the Project Name. Let it be ‘FirstProg’. The location of the project can be browed and selected. Here we keep the default location. And the name of the project is set as the name of the java file we are creating by default. For the time being we need not worry about any more details and just click the Finish button:
Opening Java Project in IDE

Opening Java Project in IDE

  • FirstProg will appear under the Projects tab:
New Java Project

New Java Project

As we can see that under the FirstProg project there is a folder named ‘Source Packages’ and inside it is the package named ‘firstprog’ and inside it the file where we are going to write the program. Package is a collection of distinct java classes i.e. no to class can have the same name within the same package.

On the right-hand side of the window appears the coding tab with the title We can see that NetBeans has already provided the program layout. The package name in which the file exists has to be specified at the very beginning as – package firstprog;

Just below the Projects tab is the Navigator tab where the different methods in a class are listed. We can move to the different parts of the program using this.

And below the program is the Output window where the result will be displayed after running the program.

  • Writing a program

The program is same as we had done using the Notepad and run in the command prompt in the previous lesson. The only difference is that we have to write less here since the structure of the program is already given and whenever there is an error it is notified to you using a red curvy line.

                package firstprog;

class FirstProg {

                public static void main (String args []){

                                System.out.println (“Hello World”);


Hello World Java Program

Hello World Java Program

  • Executing
    • Go to the Run option in the menu bar.
    • Click on the Compile option:
Compiling Java Program

Compiling Java Program

Compiled Java Program

Compiled Java Program

  • If the program is compiled successfully click on the Run File option again under the Run menu as shown in the figure above. The output is displayed in the output window:
Output Java Program

Output Java Program

Thus we have successfully executed the ‘Hello World’ program using a IDE in a more easy way. By learning to use NetBeans to execute a simple Java program we have actually took the first short step in building a Java Application in future!!!

About The Author


Hi everyone... this is Debasmita, a Computer Science Engineer working with Tier 1 company in India and a passionate technology lover. My craving for knowledge in Java Programming and Website Designing has motivated me to share the same with the world. Being a budding engineer I am well acquainted with the difficulties and queries faced by the students and new learners. Willing to help people in learning things in a easy and interesting way.


  • Gautam

    August 30, 2013

    Nice tutorial mam.Thanks for sharing such good stuff.

  • Pritam

    September 3, 2013

    Hey Debasmita ,
    I have worked with Netbeans , its awesome for especially java , HTML , CSS.
    When we where doing our project in PHP I faced some problem ( with the local host ) with Netbeans.
    Glass fish which comes with Netbeans is great to work with !
    Keep writing !
    Pritam recently posted…Ultimate Guide To Write Great Blog PostMy Profile

  • Deepanshu Mittal

    September 4, 2013

    Hi Debasmita,
    Nicely explained, when i start learning java i was working on notepad and later i switch to Netbeans with the help of an article like your’s one and now i found interesting working on Netbeans.
    Deepanshu Mittal recently posted…HTC to unveiled it’s new smartphone Desire 601My Profile

  • Shreya

    September 5, 2013

    Hi Mam, Its a nice tutorial.
    Shreya recently posted…Why Feedly should be your GooGle Reader ReplacementMy Profile

  • Margarita

    September 5, 2013

    Debasmita, I am very impressed by the possibilities through NetBeans. Vey thorough and clearly explained tutorial. My daughter is very much into Java. She might need some tutoring. I will tell her about your site. By the way, you can do it yourself. kalinaslavkova dot com – she just graduated from high school and started college. Thank you for the great lesson in Java!
    Margarita recently posted…It Works by R.H. Jarrett | Book Review | Three Positive Rules Of AccomplishmentMy Profile

  • Debasmita

    September 8, 2013

    Hey Margarita…
    I really hope that the tutorial is helpful to your daughter….
    Thank you for your comment…:)
    And visit us again!!!
    Debasmita recently posted…Part 2: Java Program writingMy Profile

  • Debasmita

    September 8, 2013

    Hey Pratim…
    Welcome to our blog…
    Good to know that you work with Netbeans…
    As you said GlassFish is definitely good with Netbeans…even Apache Tomcat works quite well!!!
    Thanks for your comment and visit us again…:)
    Debasmita recently posted…Part 2: Java Program writingMy Profile

  • Debasmita

    September 8, 2013

    Hi Deepanshu…
    Welcome to our blog…
    Hope you found this post useful…
    Thanks for commenting and do visit us again…:)
    Debasmita recently posted…Nervousness is GOOD for your JOB InterviewMy Profile

  • Sue Price

    September 9, 2013

    Hi Debasmita

    That is an excellent tutorial. I am such a nontechnical person and am in admiration of people like you.

    Nice blog you have here.

    Sue Price recently posted…Moving Forward : Accepting Change – part 3My Profile

  • Debasmita

    September 14, 2013

    Hi Sue…

    I am glad to that you liked the tutorial and stopped by to comment…

    Thank you and hope you visit us again…:)
    Debasmita recently posted…Part 2: Java Program writingMy Profile

  • Sylviane Nuccio

    September 15, 2013

    Hi Desbasmita,

    Wow, this is really technical for someone like me 🙂 Technical stuff is always scary for someone who’s not techy, you know.

    Anything Java is a bit like Greek to me. Recently I had people telling me that they couldn’t comment on my blog because they were getting a Java Script error message, but unfortunately, I wouldn’t be able to help them as I have no idea what it mean.

    If you could give me some light on that, that would be great.

    Thanks for the detailed information.
    Sylviane Nuccio recently posted…How Would You Feel If Your Favorite Singer Came Into Your Living-Room?My Profile

  • debasmita

    September 17, 2013

    Hey Sylviane…

    Firstly thanks a lot for visiting our blog and leaving a comment…:)

    Let me tell you that Java and Java Script are different things. Java Script is a scripting language to add more functionalities to HTML pages and make it more interactive.

    A website having Java Script will not work properly when one try to open it with a browser in which Java Script is disabled in the browser settings.

    So you can ask your readers to either open your website with a different browser, or enable Java Script in the settings (Content Settings) of the browser they are using.

    Its a pleasure that you asked my help in sorting your problem. Hope this information will help you…:)

    Thanks and hope to see you again!!!
    debasmita recently posted…Part 2: Java Program writingMy Profile

  • Guy Martin

    September 18, 2013

    Hi Debasmita,

    Love the way you show each step to take along the way. You make a wonderful teacher.

    Thanks for making the effort to help.

    Guy Martin recently posted…Does Discipline Equate Productivity?My Profile

  • Pst Bless

    September 20, 2013

    Thanks for sharing, i love the post.
    Pst Bless recently posted…4 Tactics for Always Having Blog Posts to WriteMy Profile

  • Adesanmi Adedotun

    September 21, 2013

    Hi Debasmate,

    Programming!!! Love to be a programmer one day and a strategy is on the goal because I love to creative technologically, I once learn HTML on my own but when it gat to a stage I need a tutor… Love this but need to learn it. Mathematician for that matter.
    Adesanmi Adedotun recently posted…SEO: How to increase blog SEO through commentMy Profile

  • debasmita

    September 21, 2013

    Hi Guy,

    Welcome to our blog…
    So good to see that you liked the tutorial!

    Thank you for the words of appreciation. Hope to see you again…:)
    debasmita recently posted…Part 2: Java Program writingMy Profile

  • prince ramgarhia

    September 21, 2013

    i am using net beans in linux and you have show in very define way great post.. thanx
    prince ramgarhia recently posted…You Can Use Upto 8 AdSense Ads UnitsMy Profile

  • Joy Healey

    September 21, 2013

    Hi Debasmita

    I’ve never ventured into Java myself, but with that clear explanation I can quite see how someone would be able to do so.

    You have a good and useful site. I’m sure it will find plenty of followers.

    Joy Healey recently posted…Free Traffic MethodsMy Profile

  • debasmita

    September 22, 2013

    Hi Joy,

    Really glad to see you found the site useful..:)

    Thanks for stopping by and hope to see you again!
    debasmita recently posted…Part 2: Java Program writingMy Profile

  • debasmita

    September 23, 2013

    Hey Adesanmi,

    I am happy to see your interest in programming. I am sure you will be a good programmer someday! 🙂

    Hope this site will help you through.

    Thanks for visiting and hope to see you again…:)
    debasmita recently posted…Part 2: Java Program writingMy Profile

  • Gilbert Samuel

    September 24, 2013

    Hi Debasmita

    You got it right, I hate command prompt due to its background, it makes it look old schools like operating on old windows
    I’m a dummy in the aspect of programming and coding, particularly java andd I guess I need to put more effort and try focusing on Netbeans. Well this is a great and epic tutorial and I’m glad I found this blog. Css and html haven’t been that problematic but php is my worst enemy, I’m sure I’ll definitely get helpful tutorials from S4C.
    Have a great week ahead.
    Gilbert Samuel recently posted…Smackhunt Review – Cheapest Web Hosting ServiceMy Profile

  • debasmita

    September 27, 2013

    Hey Gilbert,

    Welcome to S4C. I am happy that you found the site helpful..:)

    Hope this tutorial will help you through Java programming and you are free to ask if you have any problem.

    Thanks for stopping by and hope you visit us again!
    debasmita recently posted…Java Tutorial: Data types, Variables and ArraysMy Profile

  • Obasi Miracle

    October 5, 2013

    Thanks for this clear tips buddy, I have worked with netbeans in recent years, does a bit better than notepad++ by making most of my jobs so easy and quick.

    I hope to become a regular reader of your blog too. keep sharing this special tutorials buddy
    Obasi Miracle recently posted…Kaspersky Internet Security Review: a Proven Protection for Computer and DevicesMy Profile

  • kailash pradhan

    October 17, 2013

    Thanks for the nice writing.I am a long time admirer of your writing.
    With best regards

  • Baskar

    February 26, 2014

    Hi Debasmita ,

    It is good that you show each step to explain. I have never used netbeans for developing Java. So It is very helpful for me to use netbeans.

    Thanks and keep going …!

  • Kalpesh Patil

    March 14, 2014

    Thanks debasmita…I appreciate your detailed work on this post..
    for free Java projects click here

Leave A Response

* Denotes Required Field

CommentLuv badge

This blog uses premium CommentLuv which allows you to put your keywords with your name if you have had 3 approved comments. Use your real name and then @ your keywords (maximum of 2)