Java, Java Tutorial, Software Development

Chapter 1: Introduction to Java as Language and Platform

When we say “Java,” we refer to the Oracle technology with two aspects – Java as a programming language and Java as a platform. Java as a programming language allows us to create Java programs, while Java as an environment allows us to run those Java programs. 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 the following attributes can characterize:


Simple

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

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 the API level. For example, we have two classes – Main.class and MyLib.class. We updated the source file MyLib.java and recompiled it to MyLib.class. Then, we replaced the old copy with the new version of MyLib.class. After that, 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 in 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

Java’s high-performance characteristic relates to the multi-threaded buzzword. It 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 gentle 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, in step 2, we compile the file using the javac command. If we list the directory content again (step 3), we’d see the new file TurretaAppDemo.class which contains bytecodes instead of Java codes.

Windows 10

Lastly, in 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 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.

What’s Next?

Next, we’ll talk about why you should learn Java programming.

Chapter 2: Why You Should Learn Programming With Java

Loading

Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.


You Might Also Like