Java Programming: How to Learn

The most widely used programming language in the world today is Java (according to the PYPL measurement). With over 10 million active users and billions of devices, the Java language has shaped the modern world.

The power of the Java language has very little to do with the syntax or construction of the language itself, which is very similar to C and C++ in style.

Instead, the power behind the Java exists in the Java Runtime Environment (JRE), which is a platform that can run on any type of computer, and a huge variety of devices.

This extreme level of portability is possible because the JRE runs on what is known as a Virtual Machine. A virtual machine that can be made to run on any device, which means that software written in the Java language can run on any device.

With this setup, Java is both compiled and interpreted. Java code is fed into a compiler that processes code into bytecode. This gets run by a bytecode class loader, then split into tasks for both an interpreter and a machine code generator.

The Java Virtual Machine (JVM) platform does this all seamlessly for the developer, and can run on anything from a mainframe to a Mars rover.

Java's relationship with the mobile market has been controversial with the legal battle between Oracle and Google, but no one can argue how valuable Java's cross-platform capabilities have been in the mobile market.

Java 2 Platform Micro Edition (J2ME) & third-party Java tools, allow JRE implementation on all the major mobile operating systems, letting Java developers to code for any device they choose.

So Java is a popular language because the Java Platform is so easy to get setup and run on any device.

The language itself has been refined and is perhaps the most well-documented language of all. This combination of factors makes Java so popular, it's not just the language, it's the entire ecosystem.

Basic Knowledge

Java's Origin Story

A project at Sun Microsystems in 1991 was spearheaded by James Gosling, the goal was to create interactive television.

However, this proved to be too ahead of its time for cable providers, so the project pivoted to find a new primary use. The language was crafted using the familiar syntax of C++, under a project name called 'Oak.'

The key concept that remained central to the project however, was the 'Write Once, Run Anywhere' (WORA) approach to using the language, portability was key. The goals of the project can be summarized succinctly as:

  • It must be Simple, OOP, and Familiar to programmers

  • It must be robust and secure.

  • It needed to be architecture-neutral and totally portable across devices.

  • Interpreted, Threaded, Dynamic - and thus easy to use, easy to scale.

  • High Performance! Competition with C++ and other languages hinged on speed.

With all this packaged into one language and one platform, Java was released to the public in 1995. In the years to follow, browsers began to allow for Java applets to run on websites, and a strong evangelist team helped the Java enterprise take off.

By 2006, Sun released Java as open source under the General Public License, since most of their revenue came from their enterprise platform. In 2009, Sun Microsystems was acquired by Oracle.

Java vs Javascript

Despite the similarity in name, the two languages have very little in common and do not have any shared origin. There is a saying out there, "Java is to JavaScript as Ham is to Hamster."

JavaScript was created by Brendan Eich while working for Netscape Communications Corporation. The idea did have some influence from Java, Netscape wanted to have a distributed OS with a portable version of Java for running applets more natively.

However, they also wanted a lightweight interpreted language that could compete with Windows' Visual Basic.

JavaScript went through a variety of names, Mocha, LiveScript, and finally was released as JavaScript as part of a marketing push by Netscape.

The language itself is interpreted, and requires a JavaScript Engine to perform that interpretation, which is now part of every standard web browser.

Mozilla, who eventually became the curator of JavaScript, runs an engine called Rhino and one called Spidermonkey, while Google Chrome uses one called V8.

Once JavaScript became an ISO standard, it was officially renamed as ECMAScript (European Computer Manufacturers Association), however, that name is only used by the ISO organization, JavaScript has stuck as the common moniker.

JavaScript does have some similarities in syntax and styling, being influenced by C++ in some regards. However, the technology behind Java and JavaScript are very different. Java compiles to bytecode and runs on a virtual machine, JavaScript gets interpreted by your web browser and then just runs.

This means both are portable across operating systems and machines, but for different reasons. Be sure to never get these two languages mixed up, or you might get laughed at by experienced programmers.

Learning Resources

Getting Started

The first thing to do is try and understand the basics of the language. If you're new to programming, you will also want to become familiar with data types, object-oriented concepts, and the basic control statements like loops.

Here's some good resources for getting started with those basics:

Online Courses and Video Lectures

Enrolling for an online class, or just watching video lectures is a good way to make sure that you become familiar with all of the idea paradigms of the language. There are a lot of places to take classes online, either free, or for a small charge. Some might even provide certification.

Books and Resources

Books are great for people who want to have a comprehensive resource always readily at hand. Since Java is so big and well-used, there are a lot of free resources out there. Shop around and find a writing style you like, and be sure to watch out for the most recent editions.

Forums and Communities

Forums and online communities are a great place as well. Through online conversation, IRC, and sharing of information, you can become much more embedded into the active community of users.

This helps tremendously in learning quickly. Don't be afraid to ask questions on StackOverflow either.

Learning Java for Minecraft

One fun way to learn programming with Java is through the popular game Minecraft. While the game development community for Java is relatively small compared with C++ and C#, this title has a lot of users and utilizes Java for both game and server code.

There are a lot of resources out there for this, because parents have figured out that this is a good way to get kids interested in coding at an early age! Modding Minecraft can be fun for adults too, and is a great way to learn Java.

Where to go from here?

Learning the basics of programming in general can easily be accomplished by knowing Java. It's a great first language, and learning new ones after Java is highly recommended. Also, since Java is used for a multitude of devices and applications.

As you may have noticed while looking through all the available books, there are a ton of different uses for Java, and each one can become an entire arena of expertise.

As such an enormous platform, there will always be a need for Java developers. This could be about getting new devices Java capable, using Java to connect networks, or writing code to run web software.

All of these niche uses of the language and the platform come loaded with a tremendous career opportunities, so get out there, learn, make and explore!