Search this site
Getting started with Java in NetBeans
We assume that you've obtained a JDK and IDE for your machine: these are the things you need to get started programming Java. In this guide, we'll assume that you're using the NetBeans IDE, which simplifies certain aspects of getting started for absolute beginners. However, if you have chosen another IDE such as Eclipse, it shouldn't matter terribly. Much of the principles are the same, but some of the dialog boxes you will see in Eclipse have extra options which you can generally ignore for the time being.
Creating your first project
When working with an IDE, you don't generally stick bits of program willy-nilly all over your hard disk (which was definitely a possibility in the heyday of BASIC, for example). Instead, you tell your IDE to use a particular directory to store your projects in, and each of your projects (in effect, each application you write) has its own directory inside that "master" directory.
Selecting the New Project button or menu option will bring up the following dialog box. The purpose of this dialog is to select the Project Type. Make sure that Java Application is selected on the right and click Next.
The next dialog to appear allows you to select the name and location for your project. I suggest you create a project called TestProject which you can use for 'playing about' with Java. (Even later on, it's often useful to have a test project for testing ideas, or for the occasional "throwaway" program.)
Below the project name field are two directory locations, which you may be able to leave as their default settings:
For your first project, you can leave the Create Main Class option as it is.
Finally, click Finish. You will now be presented with a skeleton project.
Next: adding your first line of code
If all has gone well so far, you should now have a "blank" project ready to add your first line of Java code. On the next page, we look at writing your first line of Java code and running your first Java program.
Written by Neil Coffey. Copyright © Javamex UK 2012. All rights reserved.