Java
Overview
Java is a high-level, object-oriented programming language developed by Sun Microsystems, with its first public release in 1995. The project was initiated in 1991 by James Gosling, Mike Sheridan, and Patrick Naughton as part of the "Green Project," aiming to create technology for interactive television. However, the language found greater success in web development due to its platform independence.
Contents
History
Originally named Oak, after an oak tree outside Gosling's office, it was later renamed Java, inspired by Java coffee. Designed with the principle "write once, run anywhere" (WORA), Java's architecture-neutral nature allowed code to run on any device with a Java Virtual Machine (JVM).
Java's initial release focused on applets for web browsers, but it quickly expanded into enterprise applications, mobile devices (notably Android), scientific computing, and large-scale systems. Over the years, Java has undergone significant evolution, with major versions introducing features like generics, lambda expressions, and modules.
Oracle Corporation acquired Sun Microsystems in 2010, taking over Java's development. Despite changes in leadership and the tech landscape, Java remains one of the most widely used programming languages globally, known for its robustness, security, and versatility.
Starting with Java
Every Java file must correspond to a class. Java files end in .java and their classes end in .class. Java has an interesting syntax: every file must start have the following code:
public class FileNameHere { // your code here }
"FileNameHere" is actually the name of the Java file! So you would put that code in a file called "FileNameHere.java". You could also replace "FileNameHere" with "Main" and create a file called "Main.java". Generally, convention states that the name of every Java file is capitalized.
Downloading Java
MacOS
Java can come pre-installed on your MacBook. It can show up as an application in your Applications folder. Alternatively, you could download it from the Java website.
Other
As stated, you can download Java JDK from Oracle.
Creating your first program
In any text editor, create a new file called "HelloWorld.java". Then, input the following code into it:
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }
Running the program
The program can be run from the terminal in two steps:
Step 1: In your Linux terminal, run the command "javac HelloWorld.java". This should create a new file called HelloWorld.class in your files.
Step 2: Next, type in "java HelloWorld". You should see "Hello, World!" appear in your terminal.
Learning more
Java has many online tutorials to help you navigate your way through this incredible programming language.