One of the difficult things about getting started with Java is installing everything you need. Even before you write a single line of code, the headaches begin! Hopefully, the following sections will make life easier for you. We're going to write all our code using a free piece of software called NetBeans. This is one of the most popular IDEs (Integrated Development Environment) in the world for writing Java programmes. You'll see what it looks like shortly. But before NetBeans will work, it needs you to install Java
How to Install Java
The first thing you need is Java itself, which is all the code libraries and technologies that make a Java program work. Then you need to download Netbeans, which is the software you'll use to write your code. To download Java, go to this page:
Click the link download link, Oracle JDK. At the time of writing, the latest version of Java is 11. But get whatever the latest version is, because you can use any version of Java for this course.
You need to accept the licence agreement on the Oracle website, and then select your operating system. For Windows users, you can get the exe file by clicking the link. After that, it's just a normal download and install.
Once Java has installed on your system, the next step is to download and install Netbeans.
How to Install NetBeans
You write the actual code for your programmes in a text editor. (In NetBeans, there's a special area for you to write code.) The code is called source code, and is saved with the file extension .java. A programme called Javac is then used to turn the source code into Java Byte Code. This is known as compiling. After Javac has finished compiling the Java Byte Code, it creates a new file with the extension .class. (At least, it does if no errors are detected.) Once the class file has been created, it can be run on the Java Virtual Machine. So:
- Create source code with the extension .java
- Use Javac to create (compile) a file ending in .class
- Run the compiled class
NetBeans handles all the creating and compiling for you. Behind the scenes, though, it takes your sources code and creates the java file. It will launch Javac and compile the class file. NetBeans can then run your programme inside its own software. This saves you the hassle of opening up a terminal window and typing long strings of commands.
You can get NetBeans from here (drop me a line, if the link below is not working):
The latest version is Netbeans 10, at the time of writing. But you can use earlier versions (or later ones).
Under the Downloading heading, click the Binaries link to download
the ZIP file. Once the Netbeans file is on your computer, unzip it.
Then double-click the netbeans-bin folder to see a netbeans
folder inside of that:
Double click the netbeans folder to see lots of folders and files:
Locate the bin folder and double click it. You'll see a few files:
To launch the Netbeans software, you could double click the netbeans.exe file or the netbeans64.exe file, depending on your system. But it's a good idea to add a shortcut at this point. That way, you won't have to keep coming back to this folder every time you want to launch NetBeans. In Windows you can right click to see some shortcut options:
Select Pin to Start, or Pin to taskbar. (Or you can do both and have a shortcut on your Start menu and on your taskbar.)
Now that you have a general idea of how Java works, launch your NetBeans
software. Then click the link below to go to continue with the lesson.