Java from A-Z

Java is a programming language that is used to create software for multiple platforms.

The appeal of Java is to have one application codebase for Windows, Linux and Mac. Chrome OS is also (unofficially) supported.

Linux and Windows-based servers are also supported which means you will be able to run a single Java app on Laptops, Desktops, and Servers without any extra effort from the developer provided the client has JDK installed.

How does Java Work?

Java itself is only a programming language, what makes it unique is the Java Development Kit.

The JDK consist of a bunch of tools (needed in Java development) but the most important are the Java Compiler and the Java Virtual Machine (JVM).

When you write an application with Java syntax. The application gets compiled (with the help of Java Compiler) to byte code. This bytecode can then run on any Java Virtual Machine regardless of the underlying Computer CPU Architecture or Operating System.

Take a look at the diagram below

Advantages of Java

Platform independence: Ability to run one app on different OS and CPU architecture

Automatic Memory allocation and management

Object Orientation

Easy to Learn

1. Platform independence

App developers do not need to worry about the nitty-gritty of different operating systems or computer CPU architecture when building application software. In fact, the motto of Java is “Write Once, Run Anywhere” (WORA)

An App built with Java is guaranteed to run on any machine that has JVM installed.

An often overlooked benefit of Java is the ability to run a java app regardless of the CPU architecture.

Computers require Computer Processing Unit (CPU) to work, the CPU requires instructions from a computer programmer, in other to perform a specified task. The instructions given to a computer is often known as “Code”. A CPU understands machine language aka binary language (zeros and ones).

Modern programming languages have a syntax that looks like human language (eg English). A compiler is used to compile our “Code” to binary language which a CPU can understand.

There are many types of CPU.

CPUs can be differentiated based on their architecture.

Companies design CPU architectures to create new CPUs or improve/fix previously made CPUs.

The problem however is, different machine code is required for different CPU architectures. Let’s say you built an app for the x64 CPU architecture, you will need to build a compatible version of the same app for x86 architecture.

Java obliterates this boring, dull and redundant work.

2. Automatic Memory allocation and management

Java automatically assigns RAM memory to variables and objects and uses what is known as Garbage Collection to clear off unused data that occupy memory space.

3. Object Orientation

Object-Oriented Programming is a style of programming that gives us the power to model complex systems while simultaneously create modular code, that is easy to maintain and update.

Java Development Kit (Java, Java Compiler and JVM)?

Oracle Corporation maintains JDK.

There are two versions of JDK provided by oracle.

Open-Source JDK

Commercial JDK

The commercial oracle Java JDK is released under the Oracle Technology Network (OTN) License. The OTN License is free for personal use (developing, testing or demonstrating). Companies using the JDK commercially in their product need to pay a license fee.

The commercial and open-source JDK are functionally identical.

Why did Oracle Open Source the JDK?

To create hype around the product (Java) and increase user adoption.

Many open source projects are run by companies and generating profits. The idea is simple: create hype around the technology, make everyone use it, then introduce some paid options and services. Not every user will pay you, but if 0.1% does – it may be enough, since licenses cost a fortune.

Suppose there is an IT company that writes software, they see that Java is a nice technology, lots of developers around, so they choose it.

Then, a big non-tech client comes to them asking to develop some software. They tell him – okay, we’ll do it using Java-Oracle technologies, it will cost you X$ for development and Y$ for licenses. Customer doesn’t know anything about technologies, but he heard that something called Oracle and Java is cool, so he agrees. Thus Oracle gets it’s share via license fees.

Why get the Commercial License?

1. Commercial support – let’s say, a banking software encountered a bug that sometimes corrupts $1B worth of data. With the free version, you can report it and wait for the patch in a month or so. With commercial support, the bug can be fixed in hours. Rarely happens, so this is a typical insurance scheme.

2. Commercial support of older versions – again, if you’re a bank running old Java release which isn’t supported anymore and can’t just move to newer version quickly you’ll likely buy commercial support to get patches just in case.

3. JDK commercial features – important for enterprises.

4. Developer certification – Oracle provides certification courses, this is useful for Enterprise Corporations, to prove that the employee knows what he has learned, which can ensure promotion or pay increase.

What can you build with Java?

1. Android Apps and Games

You can build android apps in Java Language but using Kotlin is far more productive and efficient.

Java would have been the perfect language to build games with but it missed the opportunity to position itself as game development language due to technical and non-technical reasons, but technically you can build a fully functioning game in Java. Minecraft is a popular game written in Java.

Unity (uses C#) and Unreal Engine (uses C++) are the most popular and recommended tools to develop games.

Android uses a heavily modified version of the JDK hence apps written for android in java will not run on JVM.

Side Note: C#, is a programming language by Microsoft. It is a carbon copy of Java used for cross-platform Game development in Unity3d. C# was created in 2000 because Sun, (later bought by Oracle) blocked Windows from using Java. So, Microsoft chose to create their own language instead.

2. Frontend Web Development

Java Applets used to be used for frontend web application development but is now outdated in favor of HTML, CSS & Javascript.

3. Backend Web Development

Here, Java is a contender but is rapidly losing market share to Node JS which in comparison, is fast to deploy and has fewer lines of code.

Java is still a popular backend choice with banks and government because it is robust, secure and actively maintained and supported by Oracle Corporation.

4. Embedded Systems

There is a version of JDK meant for embedded systems (MP3 and DVD players, Microwave Ovens, Washing Machine, etc.) but in practice, JDK is not widely adopted in embedded system programming because of large memory requirements.

C or C++ is preferred in embedded Systems.

5. Desktop Apps

This is one of the places where Java shines the most.

You can build one app, in java, and it will run on either Mac, Linux or Windows.

Without Java, you would have to create different apps for different platforms.

Eclipse, Android Studio is built with Java.

The popularity of Desktop Apps is going down. In today’s world, everything is moved to either the web or mobile.

If you want to build a Desktop application, you should consider Kotlin with TornadoFX (for graphical User Interface)

Is Java still Relevant?

Java is still relevant.

What makes a Language relevant is what you can build with it. Check the section “What can you build with Java?”.

Java is most relevant for server-side applications in web application development (running on Linux servers) and cross-operating system development.

Banks love to use Java, for reasons stated under the section “Why get a commercial License”

You can be sure that the backend that powers most ATMs worldwide is written in Java.

You will find most job listings are from banks like Goldman, Morgan, Citi.

One of the major reasons why Investment banks prefer Java is its concurrency features. Java has in-built support for multithreading which is needed for performance-intensive, mission-critical applications on banks.

When to use Java?

Use Java when you want to build:

An app for multiple platforms (Mac, Window and Linux)

server-side technology of a web application

Kotlin over Java

Without getting technical, Kotlin is better than Java.

Kotlin has its own compiler, that converts Kotlin code to bytecode, which can run on any JVM, same as Java.

If Java turns out to be what you need to build an App, I recommend you opt for Kotlin instead.

For Desktop: use Kotlin (Backend) and TornadoFX (GUI)

For Servers: use Ktor

For Android: use Kotlin

Job Opportunities for Java Developers

For reasons stated under “is Java Still Relevant?” They are companies where using Java is the only realistic language for what they do, e.g Banks and Other Large Scale Organization. You can find Job opportunities with these companies.

These companies pay their developers well.

Should you Learn Java?

Yes, absolutely!

Why?

You can use Java to build real, useful and beautiful apps.

The learning curve of Java can be steep but if you get over the hump picking up other languages would be a breeze!