By WebNest Studio Engineering Team
Java - Core Tutorial
History and Features of Java
Java was created by James Gosling and his team at Sun Microsystems, and it was released publicly in 1995. It started as a project called "Oak", aimed at programming consumer electronics, before being rebuilt for the internet age and renamed Java. Sun Microsystems was later acquired by Oracle Corporation in 2010, and Oracle has maintained Java ever since.
Java became popular because of one core promise: "Write Once, Run Anywhere" (WORA). Unlike C or C++, which compile directly to machine code for a specific operating system, Java compiles to an intermediate form called bytecode. That bytecode runs on the Java Virtual Machine (JVM), and because a JVM exists for Windows, Linux, macOS, and many other platforms, the same compiled Java program runs unmodified everywhere a JVM is installed.
Why it matters
Most of Java's rules that feel strict at first — no pointer arithmetic, checked exceptions, everything inside a class — come straight from its original goals of safety and portability. Knowing those goals turns the rules from things to memorise into things you can predict, and it is one of the first topics interviewers use to check whether you understand the platform rather than just the syntax.
Key Features of Java
Java's design goals shaped a specific set of features that still matter today, even in modern versions of the language.
- Simple — Java removed complex C++ features like explicit pointers and multiple inheritance of classes, making it easier to learn and safer to write.
- Object-Oriented — Almost everything in Java is modeled as an object with state and behavior, which supports large, maintainable codebases.
- Platform Independent — Java source code compiles to bytecode, which any JVM can execute regardless of the underlying operating system or hardware.
- Secure — No explicit pointers, automatic memory management, and a security manager reduce common vulnerabilities like buffer overflows.
- Robust — Strong compile-time type checking, automatic garbage collection, and mandatory exception handling reduce runtime crashes.
- Multithreaded — Java has built-in support for concurrent programming through the Thread class and related APIs.
- High Performance — The Just-In-Time (JIT) compiler converts frequently used bytecode into native machine code at runtime, closing much of the performance gap with compiled languages.
- Distributed — Java has strong networking libraries and was designed with internet-based applications in mind.
- Dynamic — Java can load classes at runtime and adapt to a changing environment, which supports plugins and modular applications.
Watch: How Java Runs Anywhere
A quick video on how Java bytecode and the JVM let the same program run on any platform.
Why This History Matters
Understanding why Java was designed this way explains many things you will see later: why Java has no pointer arithmetic, why every class ultimately extends Object, why exceptions are checked at compile time, and why the JVM is central to everything Java does. Java was built for reliability in large teams and long-lived systems, not just for quick scripts — and that philosophy still drives its standard library and language evolution today.
Example
A minimal Java program showing the platform-independent structure
public class HelloJava {
public static void main(String[] args) {
System.out.println("Java: Write Once, Run Anywhere");
}
}
Java: Write Once, Run Anywhere
Common Mistakes
- Assuming Java is "slow" because it is not compiled directly to machine code — the JIT compiler makes long-running Java programs highly competitive in performance.
- Confusing Java (the language and platform) with JavaScript (an unrelated scripting language) just because the names look similar.
- Thinking "Write Once, Run Anywhere" means zero configuration — you still need a compatible JVM version installed on the target machine.
Exercise
Prove "Write Once, Run Anywhere" to yourself. Complete the program so it prints the Java version and the operating system it is running on. The same compiled class prints different values on Windows, Linux and macOS without being recompiled.
The output depends on your machine, for example Java 21.0.2 on Windows 11.
public class WhereAmI {
public static void main(String[] args) {
// TODO: read the "java.version" and "os.name" system properties
// and print them as: Java <version> on <os>
}
}
Show hints
System.getProperty("java.version")returns the running Java version as a String.- The operating system name is stored under the key
"os.name".
Show solution
public class WhereAmI {
public static void main(String[] args) {
String version = System.getProperty("java.version");
String os = System.getProperty("os.name");
System.out.println("Java " + version + " on " + os);
}
}
Quick quiz
1. Who led the team that created Java, and at which company?
- A. James Gosling at Sun Microsystems
- B. Bjarne Stroustrup at Bell Labs
- C. Guido van Rossum at Google
- D. Dennis Ritchie at Oracle
Show answer
A. James Gosling and his team created Java at Sun Microsystems; it was released in 1995. Oracle acquired Sun in 2010.
2. What does the Java compiler (javac) produce from a .java file?
- A. Native machine code for the current operating system
- B. Bytecode in a .class file
- C. An .exe file
- D. A shell script
Show answer
B. javac produces platform-neutral bytecode in .class files. The JVM on each platform then executes that bytecode.
3. What makes "Write Once, Run Anywhere" possible?
- A. Java programs are interpreted from source code
- B. Every operating system uses the same machine code
- C. Each platform has its own JVM that runs the same bytecode
- D. Java avoids using the operating system
Show answer
C. The bytecode format is the same everywhere. Each platform provides its own JVM implementation that knows how to run it.
Interview questions
Is Java platform independent? Is the JVM platform independent?
Show answer
Java bytecode is platform independent: the same .class file runs on any system with a compatible JVM. The JVM itself is platform dependent — there is a separate JVM build for each operating system and processor architecture, and that is exactly what hides the platform differences from your program.
Why does Java not support multiple inheritance of classes?
Show answer
To avoid ambiguity. If a class could extend two classes that both define the same method, the compiler would not know which implementation to inherit (the "diamond problem"). Java allows a class to extend only one class but implement many interfaces, which gives most of the flexibility without inheriting conflicting state.
Key Points to Remember
- Java was created by James Gosling at Sun Microsystems and released in 1995; Oracle now maintains it.
- Java code compiles to bytecode, which runs on the JVM — this is the basis of platform independence.
- Core features: simple, object-oriented, platform independent, secure, robust, multithreaded, high performance, distributed, and dynamic.
Practice in the playground
Write and run your own code for this topic, or start from the exercise or an example. Runs plain Java 17. Frameworks such as Spring, and databases, are not available here. Your code for each topic is kept in this browser.
Run the examples
Change an input, predict the result, then compare it with the output. Explain why the result changes.
Written by
WebNest Studio Engineering Team
Practical lessons from developers working with Java, Python, React, databases and production systems.
Led by Vansh Duggal, Founder, WebNest Studio · Full-stack & software engineering