What is "java"

Java (not to be confused with Javascript) is a high-level language, with object-oriented programming, platform-independent and an integrated execution environment. The Java language derives much of its syntax from and , but its object model is simpler than the one found in C++ and has fewer low-level features. Java applications are typically compiled to bytecode (called class files or class files) which can be run by a Java virtual machine , independent of computer architecture. The manage the memory with the help of a garbage collector (see ), in order to deal with removing objects from memory when they are no longer used, unlike other languages such as C++ where the memory should be manually displaced.

Java is designed to have as few deployment dependencies as possible, allowing application developers to use the concept "write Once, run Anywhere" (WORA) where the code is written once and runs on one platform without being recompiled to run on another. Java is a popular programming language, especially for web applications , with 10 million reported users. Java was originally developed by James Gosling at Sun Microsystems (which since merged with Oracle Corporation) and released in 1995 as a core component of the Sun Microsystems Java platform.

Principles

The Java language was created with the following main objectives:

  1. Simplicity, and familiarity with object orientation.
  2. Robustness and safety.
  3. Neutral and portable architecture.
  4. High performance execution.
  5. Interpreted, multi-threaded, and dynamic.
  6. Write once, run anywhere (WORA).

Historic

The main Java reference implementation is open source (the Openjdk), and is supported by large companies including Oracle, Apple, SAP and IBM.

The installation of Java, for computers with , is usually performed through the free download of Java Runtime Environment (JRE) no java with.. On computers , the user/user will be asked to download Java when an application requires it to be started. In and similar systems, Java is installed normally through the package manager.

JRE is the necessary environment for the execution of programs in Java, its main components being the Java Virtual Machine (JVM - Java Virtual Machine) and the standard library suite. However, to develop Java programs, developers often need additional tools that are available on Java Development Kit (JDK), which includes the Java compiler, and also has JRE. For the Windows environment, JDK can be downloaded from Oracle and installed manually.

Java is compiled in a format called bytecode which is interpreted in the JVM through the compilation Just-In-Time (JIT) for native code. Computers are not able to execute Java code directly, requiring JVM for this. The reason why this occurs is that in the name of portability, since the execution is intermediated by the JVM, it is ensured that the format and semantics of the instructions in bytecodes function completely uncoupled and independent of the details of how each computer performs its instructions on each type of hardware and operating system. Initially this was seen as a low-performance point, but improvements in JVM and JIT compilation made this a minor concern, and in some cases, the JVM may even be faster than native compiled code, since the JIT compilation takes advantage of the existence of information present only at runtime and specific to the computer on which it is running, thus obtaining better opportunities for code optimization.

Note: There are other vendors, but almost all have license fees. For Linux and other platforms, see the operating system documentation.

Versions

Notable Java versions, code names, and release dates are:

  • JDK 1.0 (23 January 1996)
  • JDK 1.1 (19 February 1997)
  • J2SE 1.2 [Playground] (December 8, 1998)
  • J2SE 1.3 [Kestrel] (May 8, 2000)
  • J2SE 1.4 [Merlin] (6 February 2002)
  • J2SE 5.0 [Tiger] (30 September 2004)
  • Java SE 6 [Mustang] (December 11, 2006)
  • Java SE 7 [Dolphin] (28 July 2011)
  • Java SE 8 [JSR 337] (18 March 2014)
  • Java SE 9 [JSR 379] (21 September 2017)
  • Java SE 10 [JSR 383] (20 March 2018)
  • Java SE 11 [JSR 384] (scheduled for September 2018)

For more code names and release dates, visit J2SE Code Names. To view the JDK release notes, visit Wikipedia.

Java SE 10 is the latest version and can be downloaded from Oracle website.

Java SE 11 is the next release. However, builds still in the development process can be obtained as Early Access Download.

The dates of End Of Public Updates (Formerly called End Of Life) sane:

  • J2SE 1.4 - October 2008
  • J2SE 5.0 - October 2009
  • Java SE 6 - February 2013
  • Java SE 7 - April 2015
  • Java SE 8 - January 2019

Initial help

Before asking a question, use the search box in the upper right to see if it has been requested earlier by other people.

Naming conventions

Java programs must adhere to the following naming conventions to increase readability and decrease the chances of accidental errors. By following these naming conventions, you will make it easy for others to understand your code and help you.

  • The type names (classes, interfaces, enums, etc.) must begin with an uppercase letter, and capitalize the first letter of each subsequent word. Examples include: String, ThreadLocal and NullPointerException. This is known as Pascal Case.

  • The names of the methods must use Camel Case, that is, they should start with a lowercase letter and then capitalize the first letter of each subsequent word. Examples: indexOf, printStackTrace, interrupt.

  • The names of the fields must be Camel Case as well as method names.

  • Constant expression names (immutable objects ​​static final) must be written in ALL_CAPS, with underlining separating each word. Examples: YELLOW, DO_NOTHING_ON_CLOSE. This also applies to the values of a class enum. However, references static final for non immutable objects must be Camel Case.

Hello World

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

Compilation and invocation of Hello World:

javac -d . HelloWorld.java
java -cp . HelloWorld

In this example above, the command javac is used to invoke the compiler and compile the program HelloWorld.java. The Java source code (present in the file HelloWorld.java) is compiled to an intermediate form (instructions from bytecode to the Java Virtual Machine), which is stored in a file HelloWorld.class. Finally, with the command java, the program compiled in the archive (HelloWorld.class) can finally be executed.


Learning Resources

Where to learn more about Java.

Books

To learn more

A good suggestion of links with diverse material about Java is this page of Zeef.