Open main menu

Java (programming language)

object-oriented programming language

Java is the name of a programming language created by Sun Microsystems. This company was bought out by Oracle Corporation, which continues to keep it up to date. The latest version is Java 12, released in March 2019. However, Java 12 is not a Long Term Support (LTS) version. The latest Long Term Support (LTS) version is Java 11,[1] released on September 25, 2018; Oracle released for the "legacy" Java 8 LTS the last free "public update".

Java, which was called Oak when it was still being developed, is object oriented, meaning it is based on objects that work together to make programs do their jobs. Java code looks like C, C++, or C#, but code written in those languages will not work in Java in most cases without being changed.[2]

Java runs on many different operating systems, including Android, the world's most popular mobile operating system[3] (while Java continues to be used on Android, even by its maker Google, they no longer prefer Java; now Kotlin is their preferred language, that can also be used with all Java code). This makes Java platform independent. It does this by making the Java compiler turn code into Java bytecode instead of machine code. This means that when the program is executed, the Java Virtual Machine interprets the bytecode and translates it into machine code.[4]

Java conceptsEdit

Java was developed to achieve five main goals. These are:[5][6]

  • Java should be easy to learn, object-oriented, and distributed.
  • Java should be safe and strong.
  • Java shouldn't depend on any computer architecture or platform.
  • Java should function well.
  • Java should be able to have an interpreter written for it, and support parallelism and use dynamic typing.

Java platformEdit

The Java platform refers to a group of software products from Sun Microsystems. The platform is used to develop and run Java programs. The platform includes the execution engine (called a Java Virtual Machine) that allows Java programs to do the same thing on different computer systems.

This capability of being able to develop software on one platform and running it on other platforms is called "cross-platform capability".

Java program exampleEdit

An example "Hello World" Java program:

/**
 * This is a simple program in Java. 
 * It shows "Hello World!" on the screen. 
 */
class HelloWorld {
    public static void main(String[] args) {
         System.out.println("Hello World!"); 
    }
}

Types of Java programsEdit

There are many types of Java programs which run differently:

  • Java Applet - small program written in Java and that is downloaded from a website and executed within a web browser on a client computer.
  • Application - executes on a client computer. If online, it has to be downloaded before being run.
  • JAR file (Java archive) - used to package Java files together into a single file (almost exactly like a .zip file).
  • Servlet - runs on a web server and helps to generate web pages.
  • Swing application - used to build an application that has a GUI (windows, buttons, menus, etc.).
  • EJB - runs on a web server and is used to develop large, complex websites.

BenefitsEdit

Java is commonly used to teach students how to program as a first language, but is still also used by professionals.

  • Java requires that each variable be initialized. Some older languages such as C, allow variables to go uninitialized, which can cause random failures with mysterious bugs.
  • Java requires that each method declares a return type—the method should always return a value, except if its return type is void. This also prevents bugs.
  • Java comes with a large set of classes and methods, the Java API that can be used without having to develop as much code "from scratch".
  • Unlike C, Java primitive types, such as int, are always the same size in the number of bits which helps achieve cross-platform compatibility.
  • Java used to be thought of as being slower than C, but that's become less important in recent years because computers are faster.
  • Java has exception-handling that requires a programmer to handle error-conditions such as Input/Output errors.
  • Code compiled on one Java platform can be run on other platforms that support Java without modification of either the source-code nor the byte-code. This means that a person can make a Java program for a Windows computer and have it run a Linux computer or a Mac computer.

CriticismEdit

Java has also been criticized. Some of the criticisms are:

  • Generics were added to Java in such a way so that existing code would still keep running. This was done using type erasure. This means that during compilation, the actual type of a generic argument is removed. This can lead to the Java interpreter to behave in unexpected ways at times.
  • Java has no unsigned integer types, which languages like C heavily use. This also means that it is impossible to directly exchange numeric data between C and Java programs. Cryptography also relies on such types to some extent; this makes it more difficult to write applications that use cryptography in Java.
  • The IEEE has defined a standard for floating-point arithmetic, IEE 754. Java only supports a part of the features of this standard.

ReferencesEdit

  1. "Java SE Versions History". CodeJava. 4 October 2018.
  2. "Java vs. C++: Which Language Is Right For Your Software Project?". Hiring | Upwork. 2016-12-21. Retrieved 2018-10-05.
  3. "I want to develop Android Apps — What languages should I learn?". Android Authority. 2017-12-24. Retrieved 2018-10-05.
  4. "How is Java platform independent? - GeeksforGeeks". GeeksforGeeks. 2017-06-23. Retrieved 2018-10-05.
  5. James Gosling, Henry McGilton: The Java Language Environment. 1.2 Design Goals of the Java Programming Language. Mai 1996.
  6. The Java Language: An Overview. James Gosling, February 1995

Other websitesEdit