Java and NetBeans
NetBeans is an IDE, an Integrated Development Environment. It ships with a built in code editor, compiler/interpreter and debugger. When you first open NetBeans for the first time you a likely to see the Start Page which contains information on recent projects, plugins and features. You have the option to prevent this page from opening when you stat NetBeans in the future, simply uncheck the box in the top right corner of the Start Page, as indicated in the image below:
Starting a new Project
When starting to create a program in NetBeans you must first create a new project. You can do so from the file menu in the top left hand corner and clicking on the New Project… icon, this looks like a folder with a green plus symbol in the upper left corner of the folder. You will find the same icon on the menu bar.
New Project Window
Once you have clicked New Project… you will see a large dialogue box that will give you options for choosing a category and project type.
By default the category should be java and the Project should be Java Application but before you proceed you should check that those setting have been selected.
Once you have ensured you are creating a Java Application click t he next button to proceed.
New Java Application Window
The next window is the New Java Application window. Here you will give your application a name and a location where NetBeans will store the application and all associated files and folders. The options in this window are:
- Project Name: Give your application a name the makes sense its intended function or use so that when you or someone else is looking at the file later you have a good idea of what it might be. Try to not use the default name as you will end up with lots of files called JavaApplication.
- Project Location: The default location that projects are saved to is a dedicated folder in your documents folder called NetBeansProjects. To change this location click on the Browse… button and choose a location that makes sense to you. Some developers store all their applications on their hard drive, others use external hard drives to store their applications for security, others use cloud storage so that they can pick up where they left off on any computer.
- Use Dedicated Folder for Storing Libraries: If you check this box, all your project libraries will be copied into the specified folder instead of referencing them from your file system. For now leave this unchecked.
- Create Main Class: This sets up a default starting point for your project. Unless you are creating a Java Form project, make sure you this is checked.
Once you’re happy with your choices, hit Finish to create your first project.
The next screen you will see is the main interface. This is comprised of 4 main areas:
- Project Tab
- Code Editor
- Project Tab: The projects tab allows you to manage, add to, and delete from all your projects. All open projects will be visible here. You can right click on any file or folder for further options.
- Navigator: The navigator allows you to jump between sections of the class your currently working on.
- Code Window: This window is where you would create, manage and test your code as you write it. The line numbers of the left side of this window can be very useful when debugging or sharing code with team members. We recommend you keep line numbers visible. To toggle line numbers click:
- View > Show Line Numbers
- Output: This is the output panel is used to print results of your code. This is also where error messages will appear, very useful for debugging.
Run Project Button
Before building a program (creating it for use outside of the IDE) NetBeans allows you to test the program by running the project to ensure that there are no errors or issues with expected results.
To run the project, click the Green Arrow in the upper ribbon.
In the next lesson we will introduce you to the Java Programming Language and discuss the structure of a Java Program.