Java, a software platform and computer programming language, is one of the most pervasive technologies in the modern world.
Java is commonly used to refer to the Java platform, a set of tools allowing for easy cross-platform application development, as well as the Java programming language, which is a general-purpose programming language often used to develop programs for this platform.
The important thing about Java that differentiates it from many other technologies is that it is designed such that code written in Java can be run on any system that a Java virtual machine (JVM) can run on. This concept of write once, run anywhere was used as a slogan to promote Java’s cross-platform abilities. Java environments can be found on all sorts of devices, large and small, and therefore a Java developer has more flexibility when it comes to being able to treat code as agnostic to the system on which it runs.
The Java programming language itself is an object-oriented language, which is syntactically similar to C++. Unlike some other languages which came before it, which implemented classes but did not require their use, Java programs are always designed with an object-oriented design.
While the Java language and the Java virtual machine which runs Java code are closely paired, the two are separate. Code from other languages which is designed specifically for the JVM, like Groovy and Scala, can also run on the Java virtual machine.
What is Java used for?
Java can be found in all sorts of places, perhaps even in your pocket or on your wrist. Android, Linux-derived open source operating system powering millions of mobile devices around the world, uses the Java language along with its own special set of libraries as the basis for mobile applications built for its platform.
But even though Java isn’t as commonly found as the front-end for web applications these days, it is still a very popular language behind the scenes on many websites and web applications. Through the capabilities of Java Enterprise Edition and open source Java application servers like WildFly and Apache Tomcat, Java has a rich ecosystem of tools for powering and connecting massively scalable applications which keep some of the largest websites and business operations out there up and running.
Is Java open source?
The subject of Java licensing is a long and complicated story, but today, most major components of Java are available under open source licenses, and those which are not available under open licenses typically have drop-in replacements which are open.
Sun, the original developers of Java, placed much of Java under the GNU General Public License in 2006. Projects like IcedTea filled in the gaps for the portions of the Java Development Kit not available under an open license, meaning today, it is possible to run Java applications without using any proprietary code.
How to run a Java application
Since Java 9, the language has been moving toward a modular design. Many modern Java applications bundle a small Java module as part of the software itself. This means there are some applications you can run without even downloading Java.
This is by no means universal yet, however. To run many Java applications, you must have a Java runtime environment (JRE) installed. Because Java is open source, there isn't just one JRE, so you can choose the JRE that best suits your needs. Linux distributions typically provide an OpenJDK or IcedTea JRE. Windows users can download a JRE installer from Red Hat's Developer portal. MacOS (and Windows and Linux) users can also download JRE installers from OpenJDK.java.net or the Zulu community at Azul.
Because the JRE you install has been created specifically for your OS, any Java application can run on your computer. By installing Java, you provide your system with a layer (technically a Java virtual machine, or JVM) upon which any Java application can run.
How to program in Java
Java is an object-oriented, strongly typed language, and it's popular in nearly all industries—from financial to publishing to IT. Because it is natively cross-platform, its audience is vast. The basic programming courses at many universities start with Java because it enforces best practices (such as scoping and variable typing) that other languages, such as Python or Go, permit the programmer to mostly ignore. Java is popular and old enough that it has libraries for nearly any task, so even a beginner programmer has access to a rich set of ready-to-use methods.
If you're developing in Java, you must install a Java development kit (JDK). There are several to choose from, including OpenJDK and Zulu (a JDK includes a JRE, so you can run the applications you develop).
There are many entry points into getting to know Java. If you prefer a fun introduction, you can try Greenfoot, an interactive development environment (IDE) designed for Java education. Greenfoot helps a new coder create games and fun applications with an easy graphical interface.
A step up from Greenfoot is BlueJ, a Java IDE designed by King's College in London as a verbose and helpful IDE that highlights important elements of code as the user programs.
In the real world, Eclipse is one of the most popular and capable Java programming environments. It helps manage libraries, resolves mistakes and conflicts in your code, assists in debugging and packaging, and much more. For development teams, Eclipse Che provides a shared cloud-based workspace, ensuring that everyone on a project is using the same environment.
The future of Java
Java was originally developed and supported by Sun Microsystems and is now supported by Oracle. However, Java is open source and has a worldwide community invested in guiding its continued development and growth. The use cases for Java may change over the years, but its focus and mantra have persisted: write once, run anywhere.
Where can I learn more?
In addition to following the Java tag here on Opensource.com, here are some resources you might want to check out.