Java is a class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. It is intended to let application developers Write Once and Run Anywhere (WORA), meaning that compiled Java code can run on all platforms that support Java without the need for recompilation. Java was developed by James Gosling at Sun Microsystems Inc. in May 1995 and later acquired by Oracle Corporation and is widely used for developing applications for desktop, web, and mobile devices.
<aside> 💡
Compiler and Interpreter
Java uses both compiler and interpreter. Java source code is converted into bytecode at compilation time. The interpreter executes this bytecode at runtime and produces output. Java is interpreted that is why it is platform-independent.
</aside>
public class GFG
{
public static void main(String args[])
{
System.out.println("Hello World");
}
}
Java is considered a platform-independent language because of its ability to run on any operating system or hardware environment that supports the Java Virtual Machine (JVM). This is achieved through the generation of bytecode during the compilation process.
Bytecode is an intermediate, machine-independent representation of the source code, created after the Java compiler processes the program. Unlike traditional compiled languages, which generate machine-specific code, Java's bytecode is designed to be interpreted and executed by the JVM.
.java
files and compiled by the Java compiler (javac
)..class
file containing bytecode..class
file to run on any device with a compatible JVM.Understanding the difference between JDK, JRE, and JVM plays a very important role in understanding how Java works and how each component contributes to the development and execution of Java applications. The main difference between JDK, JRE, and JVM is:
Packages in Java are essential for organizing code, managing dependencies, and maintaining scalability in projects. Here are the key reasons for using packages:
Avoiding Name Conflicts.
java.util.List
java.awt.List