Java is an object oriented programming language. It is frequently used by companies to build software because of the flexibility and speed that it gives a software developer. Many schools teach students to program in Java so there are a lot of developers writing Java.
With many other languages source code is compiled to machine code. This means that to support a different operating system or a different CPU architecture the code need to be recompiled. As we discussed in a previous post, Python is an interpreted language meaning its interpreter compiles as it runs the code. Java is different. It is both a compiled and interpreted language at the same time. This is thanks to the Java Virtual Machine (JVM). The Java source code is compiled to Java bytecode. The virtual machine runs the compiled bytecode. This means as long as a JVM is installed on a computer it should easily be able to run any Java program thrown at it. The Java Virtual Machine has a garbage collector. This means that the developer doesn’t have to worry about allocating and de-allocating memory.
Java requires classes and is usually implemented in an object oriented way. Object oriented means the data structures and program logic are combined together into objects. Java developers are encouraged to write code in an object oriented style. This is much different than what we did in Python.
To compile and run Java, you need a Java Development Kit commonly referred to as a JDK. The JDK includes a compiler, virtual machine, and other tools. You can download the JDK from either https://aws.amazon.com/corretto or https://www.oracle.com/java/technologies/downloads/.
Create a file Hello.java and add the following code.
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, world");
}
}
Compile using javac Hello.java
Run the code with java Hello

Java is a statically typed language. This means that you must specify the type of a variable when it is created. Here is an example of declaring an int and a String.
int itemPrice = 5;
String hello = “Hello World”;
You can’t change the type of a variable once it is defined. It would be an error if we tried to say itemPrice = hello; Likewise if we want to convert a String to an int we must use a function.
String price = "16";
itemPrice = Integer.parseInt(price);
Java has an excellent Collections framework with fast, efficient implementations of Lists, Maps, and Sets which makes it’s easier to write good code.
Pros and Cons
- Pros
- Medium difficulty
- Good for building enterprise software
- Static types
- Garbage collected
- Cons
- Extremely verbose
- Seen as old and other languages are more popular
To learn more about Java a good book is “Head First Java” or try many of the online classes. Perhaps try Code Academy.