Java an object oriented computing language introduced by Sun Microsystems, and later acquired by Oracle Corporation. A program can run on any computer, with Java installed on it, irrespective of the operating system. Source code after compilation is converted into byte code, which Java Virtual Machine (JVM) can run.
Java Program Structure
Java follows Object Oriented Software approach. Class act as a template to create instance of one or more objects. Java is case sensitive, and naming of classes and methods follows, defined conventions. A typical Java program consist of set of libraries from Java Application Interface (API), main method, associated classes, objects and methods. The program execution starts from the main method.
Use of Java Application Interface (API) helps in decreasing the lines of source code for a program. It provides the set of predefined and prewritten packages, classes, and interfaces with their respective methods, fields and constructors, and how to use them.
Java Development Environment
JDK (Java Development Kit) provides the development environment for developing java applications. To download the latest release, go to the oracle download page Java SE 8 Archive Downloads. Set the JAVA_HOME environment variable to the directory into which JDK is installed.
Java Code Execution
Java code can be executed by using console (for windows), Unix/Linux terminal or a suitable IDE (Integrated Development Environment), such as:
- Eclipse: It can be downloaded from Eclipse Downloads.
- Intelliji: It can be downloaded from Intelliji Downloads.
- Netbeans: It can be downloaded from Netbean Downloads.
To run a Java program on Windows without using an IDE, first ensure that the Java path is set. Write the Java source code and save it using the file name FileName.java. Compile the file by running javac FileName.java, which generates a corresponding .class file. Execute the compiled program by running java FileName to display the output.
On Linux or Unix systems, after installing Java and setting the classpath, edit the source code with a suitable text editor and save it as FileName.java. Compilation and execution follow the same steps using the javac and java commands.
Java Applications
Java is used in a variety of places, such as:
- Desktop applications — such as media players, IDEs, games, and financial software.
- Web applications — server-side programs that generate dynamic pages, including e-commerce platforms, content management systems, healthcare solutions, and travel services.
- Mobile applications — historically the primary language for Android (before 2018) and still used alongside the current primary language, Kotlin.
- Enterprise applications — large-scale systems supporting business needs across departments, such as banking software.
Useful Links
- Oracle Java Tutorial.
- Book By David J. Eck: Introduction to Programming using Java.
- MIT OCW Course: Introduction to Programming in Java.
- Creating Java Project using Eclipse.