CV Dropoff

Challenge us to steer your career in the right direction by uploading your CV today.

Upload your CV

IT & InnovationA Cup of Java: The Basics all Developers should know

Share this article
Mert Amcaoglu
Posted byMert Amcaoglu

Mert specialises in Belgium, working with Open Source language professionals. Connect on LinkedIn today:

Java, originally named Oak, was developed in 1991 by revolutionaries James Gosling and Patrick Naughton for Sun Microsystems Inc. At its core, Java is a programming and computing platform, the basis for many websites and applications that wouldn’t even run unless Java was installed. It developed out of the need for a multi-purpose and platform language that could be used to create software incorporated into a range of electronic devices. Since 1991, Java has evolved into something much more than was ever originally imagined.

But first… Java is not JavaScript.  

Jeremy Keith rightly points out:

“Java is to JavaScript as ham is to hamster.”

Whereas JavaScript is a 00P scripting language, meaning browser or application requests are interpreted and the script creates a response, Java is a 00P programming language, meaning it helps to build long-running applications and can handle multiple requests at once. Other differences include:

  • Java can be run on a virtual machine or browser, whereas JavaScript is just the latter
  • Java code must be compiled whereas JavaScript code is already in text
  • JavaScript is typically used within HTML documents such as web pages, whereas Java is more commonly used for apps located within those web pages.

So, what exactly is Java?

Java is a programming language, enabling users to write electronic instructions using words instead of numbers. Such as in the English language, Java has a set of rules that stipulate how instructions should be written, known as syntax. Once this has been written, they are translated into numeric codes that devices can decipher and execute.

How do I create a Java code?

To create a java code, notepad, text pad or an integrated development environment (IDE) can be used. You first enter the program, then compile and run it. For example, a simple code may contain the following:

As you may have figured out, this produces the welcome message, ‘Hello World’. The code allows the following:

A folder that will archive files generated after compilation.A class called WelcomeMessage.States a method called printMessage and defines its working code.Initiates the creation of the object.Save the file in Java with an appropriate name. For example, ‘WelcomeMessage.Java’.Open the command prompt and find this file.To compile, write ‘javac’ and then press ‘Enter’.A new file will appear, which will contain the byte code of the program. This allows the message to run on various platforms such as Windows and Mac.To execute, type ‘java WelcomeMessage’ and the output, ‘Hello World’ will appear on the device.

Initialization begins the loop and sets a loop control variable linked to an initial value.The condition assesses the control variable each time the loop restarts. If the test produces a true response, the loop continually repeats. If a false response occurs, the loop stops.

Source: Java: A Beginner’s Guide

You may have guessed from the line, ‘for(count = 0; count < 5;  count = count+1)’ that the outputs are the numbers 0-4.

In the above sequence, count is the loop control variable and numbers are generated until 5, the false statement is reached.

The above command can also be written like this:

for(count = 0; count < 5; count++)

The plus signs indicate the number increase. Similarly -- could be added to initiate a decrease.

What can Java be used for?

Java has many worldwide applications. Many websites, apps, trading systems and games such as Minecraft have Java at its heart. Banks such as Goldman Sachs and Barclays use Java for their trading, data processing and settlement systems. Other big name companies using Java include Accenture, Netflix, Canon, TripAdvisor and Spotify. Siftery claim that over 4000 companies use Java, proving it can be useful for many types of jobs. Ten examples of such are outlined in New Relic’s article and we especially like, ‘Mad Scientist’.

What are the advantages of Java?

Reliability: Java can reduce human error due to being object-oriented. This means that because you define the data and the actions allowed to produce responses, this becomes inherent. Java also performs continual run-time checks, increasing its robustness.Secure: Java created an applet in its execution environment that disallows Java from accessing other parts of the device, minimising risk of viruses, bugs and other unwanted attacks.Interchangeable Usage: Java runs on many operating systems and types of hardware, switching between them quite easily. Java can run in any environment in which there is a Java run-time system.Multithreading: Java permits a program to perform multiple tasks at the same time, improving efficiency and effectiveness.Java is distributed: Java can be distributed on more than one system (e.g. device) and be connected to each other using an internet connection.

The future of Java

Java is continually updating, with Java 8 being the most recent release. This includes a new Stream API, Nashorn, the new JavaScript engine and default methods. With Java 9 being pushed back until July, it will be exciting to see the new directions in which it takes.

© Copyright Eurostaff / Site designed and developed by Venn Digital

Video Test