No. 4: How To Install Java

I. Why learn Java?

  1. Over 3 Billion Devices
  2. Well maintained and active developer community since 1995.
  3. “Write Once. Run Anywhere.”

James Gosling developed Java at Sun Microsystems in 1995. Originally named Oak after the oak tree outside Gosling’s office, and later Green, before iterating into the more familiar Java Coffee and eventually shortened to Java. Java is one of the most widely used programming languages actively maintained today.

Over 3 Billion devices run Java, including smart phones, computers, televisions, electronic devices, software services, and network systems. Java is a well maintained language whose standards and features are currently maintained by Oracle, since its acquisition of Sun Microsystems in 2010. (Here’s some more background on the continuation of Java products after the merger: https://www.itworld.com/article/2883967/the-oracle-sun-merger-5-years-on-how-suns-products-have-fared.html.)

James Gosling released Java under the banner of “Write once. Run anywhere.” Java’s current wide scale use and implementation seems to confirm the theory. Java programs are extremely portable due to their being compiled down to bytecode and then interpreted by the Java Virtual Machine, which can be installed on almost any OS. The JVM provides a runtime environment (JRE) in which to execute the commands written into the Java .class files.

  • JVM:
    Java Virtual Machine
    specification provides the runtime environment in which Java bytecode can be executed.
  • JRE:
    Java Runtime Environment
    implements the JVM and provides all class libraries to run programs
  • JDK:
    Java Development Kit
    the tools necessary to compile, document, and package Java programs (includes JRE).

Based on C and C++, Java is a class based, object-oriented, statically-typed high-level language with extensive libraries and features like garbage collection, exception handling, concurrency, and multithreading. Java has a huge developer community that’s been around since the early 90s, is fifth on StackOverflow’s most used languages of 2019, and there’s a very good chance that any place you end up working at will be using some form of Java somewhere in their infrastructure. There are advantages and disadvantages to every language. Certain things one language does well another will handle awkwardly. Java’s simple syntax and large library of developer created learning materials can make it a great first choice, but others might point you towards Scala, Python, JavaScript, or Golang as possible alternatives.

Reddit.com/whyDoesJavaGetSuchABadRap?


II. How To Install Java on Windows

Windows Command Line Tutorial.

Java comes preinstalled out-of-the box on most Windows computers. You can check what version of Java is on your device by running the following line in the command prompt.

java -version

This will return the version number of the Java runtime that your computer is running.

C:\Users\User>java -version
java version "13.0.2" 2020-01-14
Java(TM) SE Runtime Environment (build 13.0.2+8)
Java HotSpot(TM) 64-Bit Server VM 
(build 13.0.2+8, mixed mode, sharing)

And if its missing you’ll see the following.

C:\Users\User>java -version
'java' is not recognized as an internal or external command,
operable program or batch file.

Installing Java takes three simple steps.
1. Downloading.
2. Installing.
3. Adding the path to your environment variables.


  1. Agree to the license agreement and click Download.
    https://www.oracle.com/java/technologies/javase-jdk13-downloads.html
  2. Follow the instructions on the installer.
    Approve license permissions where necessary.
  3. Locate the newly bind directory of the newly installed Java folder which should be in: C:\Program Files\Java\jdk-13.0.2\bin.
    -copy this path to the clipboard and then run a search for
    “Environment Variables”.
Select Environment Variables.

Select Environment Variables, and then select PATH and paste the location of the Java bin directory as an additional value to PATH.

Add java/bin location to path.

Verify Java has been installed by running a fresh instance of terminal and launching the following commands.

C:\Users\User>java -version
java version "13.0.2" 2020-01-14
Java(TM) SE Runtime Environment (build 13.0.2+8)
Java HotSpot(TM) 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)

C:\Users\User>javac -version
javac 13.0.2

III. How To Install Java On Mac

  1. Check if Java is currently installed.
  2. Follow Oracle install instructions.
  3. Add to path.
  1. $ where java
    More than likely Java is already installed on your Mac as so many programs depend on the JRE to run. The easiest way to verify your Java installation is to run the following command in terminal:
java -version

which should return the following description:

You could also run the where java command to return the location of Java’s path variable.

2. Oracle Downloads and Install Wizard Links
Java Downloads: https://www.java.com/en/download/manual.jsp
Mac Install Wizard Walkthrough: https://www.java.com/en/download/help/mac_install.xml

You can grab the Mac installer from the downloads page. Launching the executable will automatically proceed through the install steps detailed in the second link.

3. echo $PATH

What is PATH?
-Path is another way of referring to the environment variables that are set on any operating system. Typing echo $PATH in terminal should return a list of the environment variables that have already been set for your machine.

To set JAVA_HOME in your environment variables open a text editor through terminal using vi or nano and access the following file:

vi ~/.bash_profile

vi = calls the vim text editor
~ = refers to the root directory
bash_profile = refernces the default variables set for the current user

Type i to enter insert mode and enter the following:

JAVA_HOME = $PATH:/usr/bin/java;
export JAVA_HOME;

Click esc to exit insert mode.
And type :wq to save and quit the editor.

Relaunching terminal and entering the echo $PATH command once more should return the updated list of variables with the Java path included.

IV. Hello World

Here’s a sample of some Java code using the classic “Hello World!” example.

package default_package;

public class HelloWorld {

	public static void main(String[] args) {
		System.out.println("Hello World!");
	}
}

V. Summary

In this article we learned a little bit about Java, how it came into being, and how to install it on various platforms.