Java, Software Development

Introduction to Java as Language and Platform

When someone says “Java”, he refers to the Oracle technology as he would refer to smartphone technology. It comprises many aspects. For instance, we can use a smartphone is myriad ways – for emails, voice calls, and even video conferencing – and the device itself is an environment that enables these features to run. Same with Java, we can use it for creating programs that only run in another aspect of Java – an environment. Therefore, Java is both a tool (programming language) and an environment (platform). This post is a reboot introduction to Java as a language and platform.

Introduction to Java as a Programming Language

The Java programming language is a high-level language that can be characterized by the following attributes:


Simple

The Java programming language is a simple language that enables new programmers to quickly learn the language and develop applications very fast.

Object-Oriented

The design of the Java programming language enables programmers to code in terms of objects that encapsulate data behaviors. Objects could model real-life entity, for instance, a car which has data and behaviors.

Distributed

Java programs can communicate with each other using Java Remote Method Invocation (RMI). RMI allows one program to call methods in another Java program without third-party libraries. But, nowadays, programs from different platforms communicate with each other via HTTP.

Multi-threaded

When we say a single thread, it means a program only does one work. Most of the time is inefficient like a person who couldn’t multitask. However, when we say multi-thread, a program does more than one task at any time. This is possible because the program could briefly pause one task and continue with another task.  Therefore, a multi-threaded program is like a person who multi-task.

Dynamic

Java is dynamic because we generally can swap out some components in our applications assuming they are compatible at API-level. For example, we have two classes – Main.class and MyLib.class. We updated the source file MyLib.java and compiled it again to MyLib.class. Then, we replaced the old copy with the new version of MyLib.class. Thereafter, we don’t need to recompile Main.class with the new MyLib.class. We could just run the application like we did before we made the changes.

Architecture-Neutral

When we build a Java program in Windows, we can run the same program is Linux within the Java environment platform (or Java Virtual Machine) for Linux.

Portable

Java is portable because there are no special codes for specific environments. Meaning, we can re-compile the same codebase in another operating system using the Java compiler for that operating system.

High-Performance

This relates to the multi-threaded buzzword. This means Java is high-performance because the Java environment platform supports multi-threading.

Robust

Java is robust because you don’t need to worry about an application’s memory management. The Java environment platform does that for the program.

Secure

Java codes are secure because the Java environment platform does security checks at the bytecode level and prevents malicious operations.


Sample Java Codes – Compile And Run

As a soft introduction to Java as a programming language, we write Java codes. We save them in files with .java extensions. Let’s say we have a Java source code file TurretaAppDemo.java which has these codes.

Now, consider the following screenshot. First, we list the directory using the MS-DOS dir command. We can see we have the file TurretaAppDemo.java. Then, step 2, we compile the file using the javac command. If we list the content of the directory again (step 3), we’d see the new file TurretaAppDemo.class which contains bytecodes instead of Java codes.

Windows 10

Lastly, at step 4, we run the Java program using the command java command plus the name of the class TurretaAppDemo. The program prints out “Hello world!” on the screen.

Introduction to Java as a Platform

Don’t you know that we can run the program TurretaAppDemo in another operating system without recompiling it? It’s possible – we just need to install a Java environment platform (or Java Virtual Machine) in the other operating system. Let’s try it out with Ubuntu18.04.3 LTS.

That’s it for a reboot introduction to Java as a platform and programming language.

This is part of a reboot Java tutorial.

You Might Also Like