Java is a widely used programming language originally developed by Sun Microsystems (now owned by Oracle Corporation) in 1995. It is designed to be platform-independent, meaning that Java programs can run on any device or operating system that has a Java Virtual Machine (JVM) installed. This characteristic is achieved through the concept of "write once, run anywhere" (WORA), making Java highly portable.
Java can be considered both a compiled and an interpreted language because its source code is first compiled into a binary byte-code. This byte-code runs on the Java Virtual Machine (JVM), which is usually a software-based interpreter. The use of compiled byte-code allows the interpreter (the virtual machine) to be small and efficient (and nearly as fast as the CPU running native, compiled code). In addition, this byte-code gives Java its portability: it will run on any JVM that is correctly implemented, regardless of computer hardware or software configuration.
Running a java program:
- create a file with extension .java ( Main.java )
- write a program instructions.
- compile the program using java compiler (
javac
)
javac Main.java
- it will create a Byte Code (
.class
) file (Main.class
) - Execute it by running
java Main