NetBeans Tips
Installing and starting NetBeans
Installing and starting NetBeans
A great guide to installing and using NetBeans
Getting the NetBeans IDE
If you feel adventurous, you
could also setup your own IDE development environment such as Eclipse,
NetBeans, or the regular
JDK to develop your programs on your own PC. However,
please be aware that if you download your own copy for your own
computer, you will be on your own without support for any installation
problems as well as for any troubleshooting problems. Installing your
own distro and/or Java development environment is certainly an excellent
pedagogical tool but ONLY if you are willing to do your own
support.
That being said, if you do feel ambitious, here are two excellent videos
showing how to download and run NetBeans for Java:
https://www.youtube.com/watch?v=DubAg24zLb8
and https://www.youtube.com/watch?v=BXMp0xmrZps.
The steps, in brief, are as follows:
- Download the Java + NetBeans Bundle called "Java SE and NetBeans CoBundle" from here: https://www.oracle.com/technetwork/java/javase/downloads/jdk-netbeans-jsp-3413139-esa.html
- On the next screen, Download the version of the bundle appropriate for your Operating System and install it
-
Launch the NetBeans IDE and create your first project!
Getting Started with NetBeans
attribution to Frederic
- You can start using NetBeans by first creating a new project
- This will create the file structure for the classes, virtual machine, etc.
-
Just like starting a new Word template, you start with a basic stub/outline that you can customize as desired:
- After you have created and saved your project, you can re-open it to make changes, additions,etc.
Getting a handle on the User Interface
-
The NetBeans IDE is composed of the following components:
-
If you ever lose the Output Window, you can click Ctrl-4 (hold
down the Control Button, then press the 4 key) to bring it back
- If the Output Window is maximized across the entire botton
"band" of the NetBeans window, you can use the "Dock" icon (it looks like two
squares laying on top of each other) to re-size the Output Window.
- This same process holds true for all of the "windows" inside NetBeans.
If you click on the "Window" menu in the Menu bar near the top of the
NetBeans console, you will see a list of the keyboard shortcuts.
NetBeans Interface Tips
Managing files, classes, etc.
-
Adding a class to a project
How to add a new class (or file) to a NetBeans project
-
Running Java Programs
Great reference detailing how to run the whole project or an individual file
-
Rename a class
How to rename (or refactor) a class, variable, etc.
(refactoring/renaming a class automatically changes the .java file's
name appropriately for you!)
General Tips
-
NetBeans Project Management: Start new projects and choose
Properties->Run
to set main class
-
Java Tips:
scan.nextInt()
doesn't flush buffer so issue a scan.nextLine()
after it
-
NetBeans Project Files Location
Where does NetBeans store its project files?
Shortcuts in NetBeans
-
Type
sout
and hit TAB
for System.out.println();
-
Type
psvm
and hit TAB
for public static void main(String args[]) {}
-
NetBeans Configuration
-
Incorporating Images: To incorporate images into your NetBeans project (as opposed to
other IDEs like Eclipse), either put them in the
project's root folder or add a folder of type resources or images
and then put the image there (in Eclipse you can put it directly in src).
Or use
ImageIcon fillingIcon = new ImageIcon(getClass().getClassLoader().getResource("filling.jpg"));
to do it in a package independent way (in a static method, use
CLASSNAME.class.
instead of getClass().
).
-
Code Completion (pre-v8): Unlike other IDEs like Eclipse, NetBeans makes you press
CTRL-SPACE
in order to do code completion.
In order to have code completion occur automatically as you type, you
can go to Tools -> Options -> Editor -> Code Completion
, choose Java
as your Language
, and then check the Auto Popup on Typing Any Java Identifier Part
checkbox.
If you further set the Completion Selectors
to [.,;:([+-=]
(note the
extra space at the end), you will get completion for both variables
and methods, as well.
-
Ricky J. Sethi, PhD <rickys@sethi.org>
Last updated: Wednesday, October 3 2018
(sethi.org/tutorials/tips_netbeans.shtml)