Introduction & Installation


Introduction to Java Programming 

Hi there!  This is our second programming language that I will share my knowledge with you and hopefully I will be able to give you a good introduction so you can start looking into it 🙂 Do you want to create an app or game? Then,  Java is one of the programs that you can use.  Let’s get started!

Java is a programming language engendered by James Gosling in 1991. It is a coding language that is used to develop desktop,mobile and web applications as well as games, database connections and much more.  Java is another most popular program in the world and it is open source and free. It works on different operating systems such as Windows, Mac, Linux, etc. This is also a language that does not require any pre learning.  If you are new to programming,  it is perfectly ok. 

Java is owned by Oracle and you need to install two things to start writing your first Java program;  Java Development Kit (JDK) which contains the resources that you need to execute and/or compile the program you write in an Integrated Development Environment (IDE) and NetBeans which is an IDE, a tool that you use to write codes. There are some other IDEs if you want to explore more, but personally I got experience with NetBeans and find it easy to use. 

Let’s look at how to install  Java Development Kit (JDK) and NetBeans. 

Installing Java Development kit (JDK) with NetBeans

Let’s go to the following link for the installation;

https://www.oracle.com/technetwork/java/javase/downloads/jdk-netbeans-jsp-3413139-esa.html

The page will look like following and the first step is to read what’s inside the red color framed box;

Then you should click on “Accept License Agreement” and it will look like following;

Select the one that works with your computer operating system. I have a Mac and it did not allow me to download it when I click on it, and also I have been told that the Windows version has the same issue. If you also face the same issue,  I will suggest to right click on the installer, open in a new window and refresh the page.  It will automatically start downloading the installer. As we said, this step will allow you to download NetBeans installer;

After NetBeans 8.2 version installer is downloaded,  click on *.exe file and follow the installation steps. After installation is finished,  you will see the following cubic icon for NetBeans 8.2 version.

 if you open it up,  it should look like this;

I know that you all want to start coding, so we need to create a project first which is located in files. Go to File on the top menu and click on New Project…, It will open a small window. 

On the window, click on Next bottom.  It will open the following window.  Give a name and set a location for your Java project.  I named it as MyFirstPrg and located it in a specified folder that I created in my C drive. CLick on the Finish button.

After you create a new project, then a page should open up like this;

Doing so should allow you to do whatever you want to code. I will now explain our very basic first codes with examples.

Example 1 

Write your code under Source and click on Run Project from the top manu. You will see your program output on the right bottom corner output window. As you notice,  there are four main windows (there are more windows but do not appear if you are not performing a specific task). Top left shows your project folder and name.  Bottom left shows the navigation window. Top right, source window where you write your code and as we said, bottom right where you print your output after you run your program. If you want to explore more about the NetBeans IDE,  you can go to Help from top manu.

Notice that coding started with the package and my folder name.  It will be this way if you save your project in a specified folder. Package name needs to be the same as your project name.

Every line of code that runs in Java must be inside a class. Class name needs to match file name.  In our example, we denominated the class “MyFirstPrg”. A class should start with an uppercase first letter. Java is case-sensitive; for example, “MyFirstPrg” and “myfirstprg” have different designations. The designation of the java file must match the class denomination. When preserving the file, add “.java” to the end of the filename when you save the file. 

The public static void main() method is required and you will visually perceive it in every Java program because any code inside the method will be executed. As optically discerned in the code to print text on the screen, we utilize System.out.println()

Commenting is possible on Java, having the utilization to integrate information describing what’s going to transpire, make it more facile to understand or to cut a code transitorily. There are two ways of integrating the comment, either with // or /* */.

Example 2

We can even have multiple lines of text with words or numbers. 

Example 3

If we want to we can use the print command to even draw.

Please go ahead and complete your required installations to start java programming.  In the next post,  we will look into variables and data types.

Leave a comment