Java Fundamentals Tutorial
Introduction
Java Fundamentals are the foundation of Java programming. Before learning Object-Oriented Programming, Collections, Multithreading, or advanced Java development, you should understand how Java works, how a Java program is structured, how to write and execute code, and how the Java Virtual Machine runs your program.
In this Step 1 Java Programming Tutorial, you will learn the essential fundamentals of Java from the beginning. No previous Java programming experience is required.
What You Will Learn
After completing this lesson, you will understand:
- What Java is
- History of Java
- Why Java is popular
- Features of Java
- How Java works
- JDK, JRE, and JVM
- Java source code and bytecode
- Installing Java
- Java development environments
- Structure of a Java program
- The
main()method - Comments in Java
- Case sensitivity
- Java naming conventions
- How to compile Java programs
- How to run Java programs
- Your first Java program
- Common beginner mistakes
- Java practice exercises
What Is Java?
Java is a high-level, general-purpose programming language designed to create applications that can run on different platforms.
Java follows the principle:
Write Once, Run Anywhere
Java source code is compiled into bytecode, which can be executed by a Java Virtual Machine (JVM) available for the target platform.
Java is commonly used for:
- Backend development
- Enterprise applications
- Web applications
- Desktop software
- Android-related development
- Cloud applications
- Distributed systems
- Financial applications
- Server-side applications
History of Java
Java was developed at Sun Microsystems in the 1990s. The project was initially known as Oak and was later renamed Java.
Java became popular because developers could compile Java programs into bytecode and run that bytecode on different systems using a JVM.
Today, Java continues to be widely used for professional software development.
Why Should You Learn Java?
Java is an excellent language for learning programming concepts because it provides a structured programming environment and strongly supports Object-Oriented Programming.
Major advantages of Java
1. Platform Independent
Java bytecode can run on different operating systems through compatible JVM implementations.
2. Object-Oriented
Java supports important OOP concepts such as:
- Classes
- Objects
- Inheritance
- Polymorphism
- Encapsulation
- Abstraction
3. Secure
Java was designed with several features intended to support secure application execution and controlled runtime behavior.
4. Robust
Java provides strong type checking, exception handling, and automatic memory management.
5. Multithreaded
Java provides built-in support for creating and managing concurrent tasks.
6. Large Ecosystem
Java has a large collection of libraries, frameworks, development tools, and community resources.
Features of Java
Some important features of Java include:
- Simple and structured syntax
- Object-oriented programming
- Platform independence
- Portability
- Security
- Robustness
- Automatic memory management
- Multithreading
- Exception handling
- Rich standard library
- High performance through runtime optimization
- Networking support
How Does Java Work?
A basic Java program follows this process:
Java Source Code
↓
Java Compiler
↓
Java Bytecode
↓
JVM
↓
Operating System / Hardware
For example, suppose you create:
public class Main {
public static void main(String[] args) {
System.out.println("Hello Java");
}
}The source file is normally saved as:
Main.javaThe Java compiler converts the source code into bytecode.
The resulting file is commonly:
Main.classThe JVM then loads and executes the bytecode.
JDK, JRE, and JVM
Understanding JDK, JRE, and JVM is one of the most important Java fundamentals.
JVM – Java Virtual Machine
The JVM is the runtime environment that executes Java bytecode.
Its major responsibilities include:
Loading classes
Verifying bytecode
Executing bytecode
Managing runtime memory
Supporting garbage collection
JRE – Java Runtime Environment
The JRE traditionally refers to the components required to run Java applications, including the JVM and runtime libraries.
For modern Java distributions, a separate standalone JRE is generally not distributed in the same way as older Java releases.
JDK – Java Development Kit
The JDK provides the tools required to develop Java applications.
It includes tools such as:
- Java compiler
- Java launcher
- Documentation tools
- Debugging and development utilities
- Runtime components
For Java development, you normally install a JDK.
Simple Relationship
JDK
├── Development Tools
└── Runtime Components
└── JVM
Installing Java
To start Java programming, install a suitable JDK distribution for your operating system.
Popular development environments include:
- Windows
- macOS
- Linux
After installing the JDK, open your terminal or command prompt and check the Java version.
java -versionYou can also check the Java compiler:
javac -versionIf Java is installed correctly, these commands should display the installed Java version.
Java Development Tools
You can write Java programs using a simple text editor or a Java IDE.
Popular options include:
- IntelliJ IDEA
- Eclipse
- Apache NetBeans
- Visual Studio Code
For beginners, an IDE can make development easier because it provides features such as:
- Code completion
- Syntax highlighting
- Error detection
- Debugging
- Project management
- Refactoring tools
However, learning basic command-line compilation is also useful because it helps you understand what happens behind the IDE.
Your First Java Program
Let's create your first Java program.
public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}Output
Hello, World!Congratulations! You have written your first Java program.
Understanding the Java Program
Let's break the program into individual parts.
Class Declaration
public class MainThis defines a class named Main.
If the class is declared public, the source file name normally needs to match the class name:
Main.javaMain Method
public static void main(String[] args)The main() method is the conventional entry point used by the Java launcher to start a standalone Java application.
Let's examine it:
public
The method is accessible to the Java launcher.
static
The method belongs to the class rather than requiring an object to be created first.
void
The method does not return a value.
main
This is the method name recognized as the application entry point.
String[] args
This parameter can receive command-line arguments.
Printing Output in Java
Java provides several commonly used output methods.
System.out.println()
Prints text and moves to a new line.
System.out.println("Hello");
System.out.println("Java");Output:
Hello
JavaSystem.out.print()
Prints text without automatically moving to the next line.
System.out.print("Hello ");
System.out.print("Java");Output:
Hello JavaSystem.out.printf()
Provides formatted output.
String name = "Jitu";
int age = 20;
System.out.printf("Name: %s, Age: %d%n", name, age);
Comments in Java
Comments are notes written inside source code. They are ignored by the compiler.
Java supports three common comment forms.
Single-Line Comment
// This is a comment
System.out.println("Java");Multi-Line Comment
/*
This is a
multi-line comment.
*/
System.out.println("Java");Documentation Comment
/**
* Displays a welcome message.
*/
public static void welcome() {
System.out.println("Welcome!");
}Documentation comments can be used with Java's documentation tools.
Java Is Case-Sensitive
Java is a case-sensitive language.
For example:
int number = 10;is different from:
int Number = 10;Similarly:
System.out.println();must not be written as:
system.out.println();Correct capitalization is essential when writing Java code.
Java Statements
A statement is an instruction that performs an operation.
For example:
System.out.println("Hello Java");Most Java statements end with a semicolon:
;Example:
int age = 20;
System.out.println(age);Forgetting the semicolon can cause a compilation error.
Java Blocks
A block is a group of statements surrounded by curly braces:
{
...
}Example:
public class Main {
public static void main(String[] args) {
System.out.println("Hello");
System.out.println("Welcome to Java");
}
}The class body and method body are examples of blocks.
Java Identifiers
Identifiers are names used for programming elements such as:
- Classes
- Methods
- Variables
- Interfaces
Examples:
Student
calculateTotal
firstName
totalMarksBasic identifier rules
An identifier:
- Can contain letters
- Can contain digits
- Can contain
_ - Can contain
$ - Cannot normally begin with a digit
- Cannot contain spaces
- Cannot be a Java keyword
For example:
int studentAge = 20;is valid.
But:
int student age = 20;is invalid because an identifier cannot contain a space.
Java Keywords
Java reserves certain words for specific language purposes.
Examples include:
class
public
private
static
void
int
if
else
for
while
return
new
extends
implements
final
try
catchYou cannot normally use a reserved keyword as a variable, class, or method name.
For example:
int class = 10;is invalid.
Java Naming Conventions
Following naming conventions makes Java programs easier to read.
Class Names
Use PascalCase:
Student
BankAccount
EmployeeManagerMethod Names
Use camelCase:
calculateTotal()
displayMessage()
getStudentName()Variable Names
Use camelCase:
studentName
totalMarks
accountBalanceConstants
Constants are commonly written using uppercase letters with underscores:
MAX_SIZE
DEFAULT_TIMEOUT
PI_VALUENaming conventions do not generally affect whether the compiler accepts your program, but they are important for readable and maintainable code.
Compiling a Java Program
Suppose your source code is saved as:
Main.javaOpen your terminal in the directory containing the file and run:
javac Main.javaIf compilation succeeds, a class file will normally be generated.
Main.class
Running a Java Program
After compiling the program, run it using:
java MainDo not normally include .class when using the Java launcher.
Example:
javac Main.java
java MainOutput:
Hello, World!
Java Program Structure
A basic Java program can look like this:
public class Main {
// Method
public static void main(String[] args) {
// Statement
System.out.println("Learning Java");
}
}The basic structure contains:
- Class declaration
- Class body
- Main method
- Statements
- Comments where appropriate
As you progress through the course, this simple structure will become much more powerful.
Java Escape Sequences
Escape sequences are special character combinations used inside strings.
New Line
System.out.println("Hello\nJava");Output:
Hello
JavaTab
System.out.println("Name:\tJitu");Double Quote
System.out.println("He said \"Hello\"");Common escape sequences include:
| Escape | Meaning |
|---|---|
\n | New line |
\t | Tab |
\" | Double quote |
\' | Single quote |
\\ | Backslash |
A Simple Java Example
Let's combine some fundamentals.
public class Main {
public static void main(String[] args) {
System.out.println("===== Java Fundamentals =====");
System.out.println("Name: Jitu Hasan");
System.out.println("Course: Java Programming");
System.out.println("Level: Beginner");
}
}Output:
===== Java Fundamentals =====
Name: Jitu Hasan
Course: Java Programming
Level: BeginnerThis example demonstrates:
- Class
- Main method
- Statements
- Strings
- Output
- Comments and formatting concepts
Common Beginner Mistakes
When starting Java, beginners commonly encounter the following problems.
Mistake 1: Wrong Class Name
If you have:
public class Mainthe file should normally be:
Main.javaMistake 2: Missing Semicolon
Incorrect:
System.out.println("Hello")Correct:
System.out.println("Hello");Mistake 3: Incorrect Capitalization
Incorrect:
system.out.println("Hello");Correct:
System.out.println("Hello");Mistake 4: Incorrect Compilation Command
Compile:
javac Main.javaRun:
java MainMistake 5: Forgetting Curly Braces
Incorrect program structure can cause syntax errors.
Always make sure that opening and closing braces match:
{
// code
}
Practice Exercises
Practice is essential for learning Java.
Exercise 1
Create a Java program that prints:
Welcome to Java ProgrammingExercise 2
Print your:
- Name
- Country
- Learning goal
Example:
Name: Your Name
Country: Bangladesh
Goal: Become a Java DeveloperExercise 3
Print the following using separate statements:
Java
Programming
Tutorial
2026Exercise 4
Create a program that prints a simple introduction card.
Example:
========================
STUDENT PROFILE
========================
Name: Rahim
Course: Java Programming
Level: Beginner
========================Exercise 5
Use escape sequences to produce:
Name: Rahim
Course: Java
Level: Beginner
Mini Project – Java Welcome Program
Let's create a small beginner project.
public class Main {
public static void main(String[] args) {
System.out.println("==============================");
System.out.println(" JAVA PROGRAMMING COURSE");
System.out.println("==============================");
System.out.println("Welcome to Java!");
System.out.println("Start learning from the basics.");
System.out.println("Practice every day.");
System.out.println("==============================");
}
}Expected Output
==============================
JAVA PROGRAMMING COURSE
==============================
Welcome to Java!
Start learning from the basics.
Practice every day.
==============================This simple project helps you practice Java class structure, the main() method, strings, output statements, and formatting.
Quick Revision
Let's review the most important concepts from Step 1.
| Topic | Key Point |
|---|---|
| Java | General-purpose programming language |
| JDK | Development kit used to develop Java applications |
| JVM | Executes Java bytecode |
| JRE | Runtime environment concept used with Java applications |
| Source Code | Human-readable Java program |
| Bytecode | Compiled representation executed by the JVM |
| Class | Blueprint containing Java members |
main() | Conventional entry point for a Java application |
println() | Prints output followed by a line break |
| Comments | Notes ignored by the compiler |
| Identifier | Name of a programming element |
| Keyword | Reserved word in Java |
| Compilation | Converting source code into bytecode |
| Execution | Running the compiled program |
What You Should Know Before Step 2
Before moving to the next lesson, make sure you can:
- Explain what Java is.
- Explain the basic Java execution process.
- Understand the difference between JDK and JVM.
- Explain the traditional role of JRE.
- Install and verify a JDK.
- Create a basic Java program.
- Understand the
main()method. - Print output using
System.out.println(). - Write comments.
- Explain Java's case sensitivity.
- Identify basic Java keywords.
- Follow common naming conventions.
- Compile a Java source file.
- Run a Java program.
- Solve the practice exercises.
Conclusion
Java Fundamentals are the first and most important step in your Java programming journey. Understanding the Java environment, JDK, JVM, source code, bytecode, program structure, classes, the main() method, statements, comments, identifiers, and compilation will make the upcoming lessons much easier.
Don't rush through the fundamentals. Write each example yourself, change the code, intentionally make small mistakes, and observe the results. Programming becomes easier when you actively practice rather than simply reading code.
In Step 2, we will learn Java Variables and Data Types, including primitive data types, variable declaration, initialization, type conversion, constants, and practical coding examples.
Next Lesson → Step 2: Java Variables and Data Types

Post a Comment
Thank You For Visit My Website.
I Will Contact As Soon As Possible.