Java (programming language)
![](http://upload.wikimedia.org/wikipedia/commons/thumb/5/5d/Duke_%28Java_mascot%29_waving.svg/220px-Duke_%28Java_mascot%29_waving.svg.png)
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. 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 current long-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 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 similar to C, C++, or C#, but code written in those languages will not work in Java in most cases without being changed.[3]
Java runs on many different operating systems, including Android, the world's most popular mobile operating system[4] (while Java continues to be used on Android, even by its maker Google, they no longer prefer Java; now Kotlin is their preferred language, though it 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, a Java Virtual Machine interprets (or just-in-time compiles) the bytecode.[5]
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 recommends Kotlin 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.
- High-profile JVM languages
- Java, a statically-typed object-oriented language
- Groovy, a dynamic programming language (also with static typing) and scripting language[6]
- Kotlin, a statically-typed language from JetBrains, the developers of IntelliJ IDEA[6] and Google's preferred language for Android
- Scala, a statically-typed object-oriented and functional programming language[7]
- Clojure, a dynamic, and functional dialect of the Lisp programming language[6] (ClojureScript is an implementation targeting the web with JavaScript, not the JVM.)
Java concepts
[change | change source]Java was developed to achieve five main goals. These are:[8][9][10]
- Java should be easy to learn, object-oriented, and distributed.
- Java should be safe and strong.
- Java should not depend on any computer architecture or platform.
- Java should function well.
- Java should be able to have an interpreter written for it (for better portability), support parallelism, and use dynamic typing.
Java platform
[change | change source]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".
There are many resources available for learning Java programming, including books, tutorials, and online courses.[11]
Programming example
[change | change source]An example of a "Hello World" Java program:
// This is a simple program in Java. It shows "Hello World!" on the screen.
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
Types of Java programs
[change | change source]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 the Kotlin 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 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.
- Java Applet – small program written in Java and that was automatically downloaded from a website and historically could be executed within a web browser on a client computer; such applets were introduced in 1995, could run in most web browers, but beginning in 2013, major web browsers began to phase out support for the underlying technology applets used to run, with applets becoming completely unable to be run by 2015–2017. Java applets were deprecated by Java 9 in 2017.[12][13][14][15][16]
Benefits
[change | change source]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.
Criticism
[change | change source]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, IEEE 754. Java only supports a part of the features of this standard.
References
[change | change source]- ↑ "20 Best Java Coding Websites in 2023 - codershot". 2023-01-15. Retrieved 2023-01-21.
- ↑ "Oracle Java SE Support Roadmap". Oracle. 2021-09-13. Retrieved 2022-03-05.
- ↑ "Java vs. C++: Which Language Is Right For Your Software Project?". Hiring | Upwork. 2016-12-21. Retrieved 2018-10-05.
- ↑ "I want to develop Android Apps — What languages should I learn?". Android Authority. 2017-12-24. Retrieved 2018-10-05.
- ↑ "How is Java platform independent? - GeeksforGeeks". GeeksforGeeks. 2017-06-23. Retrieved 2018-10-05.
- ↑ 6.0 6.1 6.2 Urma, Raoul-Gabriel (2014-07-01). "Alternative Languages for the JVM. A look at eight features from eight JVM languages". Oracle. Retrieved 2019-03-13.
- ↑ Wampler, Dean (15 January 2009). "Adopting New JVM Languages in the Enterprise (Updated)". objectmentor.com. Archived from the original on 22 May 2009. Retrieved 18 June 2009.
- ↑ James Gosling, Henry McGilton: The Java Language Environment. 1.2 Design Goals of the Java Programming Language. Mai 1996.
- ↑ The Java Language: An Overview. James Gosling, February 1995
- ↑ Shadow (2020-05-25). "Understanding Bytecode and Java Virtual Machines". CodersLegacy. Retrieved 2020-05-29.
- ↑ "20 Best Java Coding Websites in 2023 - codershot". 2023-01-15. Retrieved 2023-01-21.
- ↑ "Java 9 Release Notes". Oracle.com.
- ↑ "JEP 289: Deprecate the Applet API". Openjdk.java.net. Retrieved 22 March 2022.
- ↑ "JPG blog: Moving to a Plugin-Free Web". Blogs.oracle.com.
- ↑ "JPG blog: Further Updates to 'Moving to a Plugin-Free Web'". Blogs.oracle.com.
- ↑ "Java Client Roadmap Update" (PDF). Oracle.com. Retrieved 22 March 2022.