From Simple English Wikipedia, the free encyclopedia
Duke (Java mascot)
Java is the name of aprogramming language created bySun Microsystems. This company was bought out byOracle Corporation, which continues to keep it up to date. It is designed to be platform-independent, which means that code written in Java can run on any device or operating system that has a Java Virtual Machine (JVM) installed. This makes Java a popular choice for developing cross-platform applications and games. Additionally, Java has a large and active community, and a wide range of libraries and frameworks available for use.[1] As of March 2023[update],Java 20 is the latest version (will be supported until September 2023), while Java 17, 11 and 8 are the currentlong-term support (LTS) versions. Being an LTS version means that it will continue getting updates for multiple years. The next planned LTS version is Java 21 (LTS), planned for September 2023.[2]
Being an open-source platform, Java isn't just supported by Oracle, e.g. Eclipse Adoptium also supports Java (JVM), to at least May 2026 for Java 8, and at least September 2027 for Java 17.
Java, which was calledOak when it was still being developed, isobject oriented, meaning it is based onobjects that work together to make programs do their jobs. Java code looks similar toC,C++, orC#, but code written in those languages will not work in Java in most cases without being changed.[3]
Java is both a language, but its also a platform, and a number of languages compile to the same bytecode meant for that JVM platform, and can then work alone (without Java, the language, or with it). Google, that previously recommended Java, now recommendsKotlin language over Java for its Android platform, and it, like any JVM language, can also work with or without Java in all other contexts where Java alone would have been used.
TheJava platform refers to a group ofsoftware products fromSun Microsystems. The platform is used to develop and run Java programs. The platform includes the execution engine (called aJava 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".
There are many resources available for learning Java programming, including books, tutorials, and online courses.[11]
// This is a simple program in Java. It shows "Hello World!" on the screen.publicclassHelloWorld{publicstaticvoidmain(String[]args){System.out.println("Hello World!");}}
There are many types of Java programs which run differently:
Java application – executes on a client computer. If online, it has to be downloaded before being run.
Java applications do not generally run on mobile platforms, but Android has historically also used Java, and Android apps written in Java, to run on Android still work; those applications do not work on other operating systems in general, unlike regular Java applications, and Google now recommends using theKotlin language over using Java to write such applications.
JAR file (Java archive) – used to package Java files together into a single file (almost exactly like a.zip file).
Servlet – runs on aweb server and helps to generate web pages.
Swing application – used to build an application that has aGUI (windows, buttons, menus, etc.).
EJB – runs on a web server and is used to develop large, complex websites.
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 eachmethod declares a return type—the method should always return a value, except if its return type isvoid. This also prevents bugs.
Java comes with a large set of classes and methods, the JavaAPI 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 aLinux computer or a Mac computer.
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 usingtype 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 unsignedinteger 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.
TheIEEE has defined a standard for floating-point arithmetic,IEEE 754. Java only supports a part of the features of this standard.