Java Learning Notes — Telusko Core Java | Video 03
After installing the JDK and setting up VS Code, I finally reached the part I was waiting for:
Writing my first Java code.
At this point, I thought the process would be very simple:
Open VS Code → write
System.out.println()→ run it.
But while going through the lesson, I realized that there are a few things I need to understand before a Java program actually runs.
For example:
- What exactly is a
.javafile? - What is
javac? - What is the difference between
javaandjavac? - What is JShell?
- Why can I write something directly in JShell but need more structure in a Java source file?
- What exactly happens between writing the code and seeing the output?
These questions became much clearer once I understood the basic write → compile → run workflow.
This article contains what I learned from the lesson, along with additional explanations and examples that helped me understand the concepts better.
What This Article Covers
In this article, I will answer five questions from Video 03:
- What does
.javamean? - What is
javac? - What is JShell used for?
- Why are double quotes needed around text?
- What is the basic Java write → compile → run workflow?
I will also explain:
- The basic VS Code workspace
- The difference between
javaandjavac - JShell vs Java source files
- How Java source code becomes executable
- Common beginner mistakes
1. What does .java mean?
What I understood first
When I created my first Java file, I noticed that the file name ended with:
.java
For example:
Hello.java
I initially thought the extension was simply a naming convention.
But it actually tells us something important:
The
.javaextension identifies a Java source-code file.
A Java source file contains the Java code that I write as a developer.
What is a source file?
The code I write is called source code.
For example:
System.out.println("Hello World");
This is Java source code.
When I save it in a file such as:
Hello.java
I have created a Java source file.
Later, the Java compiler can process this source file.
The simplified flow is:
Hello.java
↓
Java source code
↓
javac
↓
Bytecode
Why does the extension matter?
The extension helps tools and development environments understand what type of file they are dealing with.
For example:
| Language | Common source-file extension |
|---|---|
| C | .c |
| C++ | .cpp |
| JavaScript | .js |
| Java | .java |
So:
Hello.java
tells me:
This is a Java source file.
.java vs .class
This distinction is also useful.
Before compilation:
Hello.java
contains Java source code.
After compilation, the compiler can produce:
Hello.class
which contains Java bytecode.
So:
.java
↓
Source code
.class
↓
Compiled bytecode
This distinction helped me understand why Java has a compilation step before execution.
🧠 Easy to Remember
.java= Java source-code file
And:
.class= compiled Java bytecode
🎯 Short Interview Answer
The
.javaextension is used for Java source files containing Java source code. These files can be compiled by the Java compiler into bytecode, typically stored in.classfiles.
2. What is javac?
What I understood first
This was one of the commands I had already seen during Java setup:
javac --version
But knowing that javac exists is different from understanding what it actually does.
javac is the Java compiler.
The name comes from:
Java Compiler
What does a compiler do?
A compiler translates source code into another form that can be executed by a runtime environment or machine.
For Java, the simplified process is:
Java Source Code
↓
javac
↓
Bytecode
↓
JVM
↓
Execution
For example, suppose I have:
Hello.java
I can compile it using:
javac Hello.java
If the compilation succeeds, a .class file can be generated:
Hello.class
That .class file contains Java bytecode.
What happens if there is an error?
Suppose I accidentally write:
System.out.println("Hello World"
and forget something required by the syntax.
When I run:
javac Hello.java
the compiler checks the source code and can report compilation errors.
So javac doesn't just "run" my Java program.
It compiles the source code.
java vs javac
This distinction is extremely important.
I like to remember it this way:
javac
↓
compile
java
↓
run
For example:
javac Hello.java
means:
Compile the Java source file.
Then:
java Hello
means:
Run the compiled Java class named
Hello.
Notice that we normally don't write:
java Hello.java
when following the traditional compile-then-run workflow being introduced here.
🧠 Easy to Remember
javac→ compile
java→ run
This is probably one of the most important command-line distinctions from this lesson.
🎯 Short Interview Answer
javacis the Java compiler. It compiles Java source files into bytecode, which can then be executed by the JVM.
3. What is JShell used for?
What I understood first
JShell was a new concept for me when I came across it.
JShell stands for:
Java Shell
It is an interactive environment for experimenting with Java code.
Instead of creating a complete Java source file, writing the required structure, compiling it, and then running it, I can use JShell to try small pieces of Java code interactively.
A simple example
I can start JShell from the terminal:
jshell
Then I can type:
2 + 3
and get:
5
I can also try:
System.out.println("Hello World");
and immediately see:
Hello World
This makes JShell useful for quick experimentation.
Why is JShell useful for beginners?
Suppose I am learning an expression or trying to understand how something works.
I may not want to create a complete Java application just to test one small idea.
Instead:
Open JShell
↓
Try something
↓
See the result
↓
Modify it
↓
Try again
This gives me a quick feedback loop.
Is JShell used to build normal applications?
Not usually.
JShell is mainly useful for:
- Quick experiments
- Learning
- Testing expressions
- Trying APIs
- Exploring Java behavior
For a proper application, I would normally create Java source files and organize the code into a structured project.
So I think of JShell as:
A playground for Java.
JShell vs Java source file
| Aspect | JShell | Java source file |
|---|---|---|
| Main purpose | Quick experiments | Structured programs |
| Interaction | Interactive | File-based |
| Structure | Minimal | More structured |
| Compile/run workflow | Mostly hidden from me | Explicit workflow |
| Best for | Learning and testing ideas | Applications and projects |
This distinction made JShell much easier for me to understand.
🧠 Easy to Remember
JShell = Java playground
Use it when I want to quickly:
Try → Test → Learn
🎯 Short Interview Answer
JShell is an interactive Java shell that allows developers to quickly experiment with Java expressions, statements, and APIs without creating a complete Java source file.
4. Why are double quotes needed around text?
What I understood first
When I saw:
System.out.println("Hello World");
I noticed that "Hello World" is surrounded by double quotes.
I initially thought:
"Are the quotes just there because that's how Java writes text?"
There is actually a reason.
The double quotes tell Java that:
This is a string literal.
What is a string?
A String represents a sequence of characters.
For example:
"Hello"
is a string.
So are:
"Hello World"
and:
"Java is fun"
The quotation marks tell Java where the text begins and ends.
For example:
System.out.println("Hello World");
Here:
"Hello World"
is the string that we want to print.
What happens if I remove the quotes?
Suppose I write:
System.out.println(Hello World);
Java cannot interpret Hello World as a string literal.
It will produce a compilation error.
The correct version is:
System.out.println("Hello World");
What about numbers?
Numbers can be written without quotes when we want them treated as numeric values.
For example:
System.out.println(10);
Here 10 is a number.
But:
System.out.println("10");
contains the text "10" as a string.
They may look similar when printed, but Java treats them differently.
This becomes important later when learning:
- Data types
- Variables
- Strings
- Arithmetic
- Type conversion
What about single quotes?
Java uses double quotes for strings:
"Hello"
Single quotes are generally used for a character literal:
'A'
So:
"Hello"
↓
String
'A'
↓
char
I don't need to go deeply into String vs char at this stage, but remembering this distinction is useful.
🧠 Easy to Remember
Double quotes
" "→ String/textSingle quotes
' '→ Character
🎯 Short Interview Answer
Double quotes are used to represent string literals in Java. They tell the compiler that the enclosed characters should be treated as text rather than as identifiers or other expressions.
5. What is the basic Java write → compile → run workflow?
What I understood first
This is probably the biggest concept I took away from this lesson.
Before this, I was thinking:
Write code → press Run → get output.
But Java has an important process behind that.
The traditional workflow introduced in this lesson is:
Write
↓
Compile
↓
Run
Let's understand each step.
Step 1: Write the Java source code
I create a file such as:
Hello.java
and write Java code inside it.
For example:
class Hello {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
At this point, I have source code.
Step 2: Compile the source code
I use:
javac Hello.java
The Java compiler processes the source code.
If the code is valid, it can produce:
Hello.class
which contains Java bytecode.
So:
Hello.java
↓
javac
↓
Hello.class
Step 3: Run the compiled program
Now I can run the class:
java Hello
The JVM loads the compiled class and executes the bytecode.
The result is:
Hello World
So the complete picture is:
Hello.java
↓
javac
↓
Hello.class
↓
JVM
↓
Hello World
Why don't I write .class with the java command?
This is another small detail that confused me initially.
When I compile:
javac Hello.java
the source file has the .java extension.
When I run:
java Hello
I normally provide the class name, not:
java Hello.class
The Java launcher uses the class name to locate and load the class.
So the traditional workflow is:
javac Hello.java
java Hello
Where does VS Code fit into this?
VS Code gives me a convenient environment to perform these activities.
I can:
- Create the file
- Write the code
- Open the terminal
- Run
javac - Run
java - View the output
The terminal inside VS Code is especially useful because I don't have to leave the editor to execute the commands.
Conceptually:
VS Code
│
├── Explorer → Manage files
├── Editor → Write code
├── Extensions → Java support
└── Terminal → Compile and run
🧠 Easy to Remember
The most important sequence from this lesson is:
Write
↓
Compile
↓
Run
Or:
.java
↓
javac
↓
.class
↓
java
↓
Output
🎯 Short Interview Answer
The basic Java workflow is to write source code in a
.javafile, compile it usingjavacto produce bytecode, and then run the compiled class using thejavacommand, which uses the JVM to execute it.
🖥️ Understanding the VS Code Workspace
Before writing the program, I also needed to become familiar with the basic VS Code workspace.
Some useful areas are:
| Area | Purpose |
|---|---|
| Explorer | View folders and source files |
| Search | Find text and files |
| Extensions | Add language support and tools |
| Run & Debug | Run and debug programs |
| Terminal | Execute commands inside VS Code |
I don't need to memorize every VS Code feature immediately.
For Java, the important ones at this stage are:
Explorer → create/find files
Editor → write code
Terminal → compile and run
📁 Creating a Simple Java Workspace
For a first Java program, I can create a folder such as:
JavaPractice
Then open that folder in VS Code.
Inside it, I can create:
JavaPractice
└── Hello.java
This keeps the source file organized and gives me a working directory from which I can run the Java commands.
🔍 Checking Java Before Writing Code
Before starting, I can quickly check:
java --version
javac --version
If both commands work, I know that the Java runtime command and compiler are available.
This connects directly to what I learned in Video 02.
⚠️ Common Beginner Mistakes
Forgetting .java
Incorrect:
Hello
Correct:
Hello.java
Confusing java and javac
Remember:
javac → compile
java → run
Forgetting the semicolon
For example:
System.out.println("Hello World")
needs:
System.out.println("Hello World");
Forgetting double quotes
Incorrect:
System.out.println(Hello World);
Correct:
System.out.println("Hello World");
Running commands from the wrong directory
If my terminal is not currently inside the directory containing Hello.java, this may fail:
javac Hello.java
So I need to make sure I am working in the correct folder.
Expecting JShell and Java source files to behave identically
JShell is designed for interactive experimentation.
A regular Java application uses source files and a more structured program.
So:
JShell
→ quick experiments
.java file
→ structured Java program
🧠 One-Minute Revision Sheet
If I need to revise this lesson quickly, I want to remember:
.java
↓
Java source file
javac
↓
Java compiler
java
↓
Runs compiled Java class
JShell
↓
Interactive Java experimentation
"Hello"
↓
String literal
;
↓
Statement terminator
Basic workflow
↓
Write → Compile → Run
Example:
javac Hello.java
java Hello
🎯 5 Interview Questions — Super Short Answers
What does .java mean?
.javais the file extension used for Java source-code files.
What is javac?
javacis the Java compiler that converts Java source code into bytecode.
What is JShell used for?
JShell is an interactive Java environment used for quickly experimenting with Java code.
Why are double quotes needed around text?
Double quotes identify a string literal in Java.
What is the basic Java write → compile → run workflow?
Write code in a
.javafile, compile it usingjavac, and run the resulting class usingjava.
What I Learned From This Lesson
This lesson was where Java started feeling more practical to me.
In the previous lesson, I was mainly preparing the environment:
JDK
VS Code
PATH
Now I could finally start interacting with Java itself.
The most important mental model I got from this lesson is:
Java Source Code
↓
.java file
↓
javac
↓
Bytecode
↓
JVM
↓
Output
And when I want to experiment quickly:
JShell
↓
Try something
↓
See the result
That distinction helped me understand why JShell is useful for learning while .java files are used for building structured applications.
A Note for Other Beginners
If you're writing your first Java program, don't worry if the process initially seems like too many steps.
Just remember these three commands/concepts:
java --version
javac --version
and:
Write → Compile → Run
Then remember:
javaccompiles.
javaruns.JShell lets me experiment quickly.
Once these become familiar, the next lessons become much easier because I can focus on the actual Java language instead of wondering how the program is being executed.
📚 Related Java Learning Resources
This article is part of my Java Learning Notes — Telusko Core Java series.
If you are following the series from the beginning:
👉 Video 01 — Java Introduction: 8 Questions I Had as a Beginner and Their Easy Answers
👉 Video 02 — Setting Up Java: 6 Questions I Had About JDK, VS Code, LTS and PATH
I also wrote a separate article while researching the history behind Java:
👉 Java Introduction: What Is Java, Who Created It, and How Sun Microsystems Became Oracle?
🔗 My Java Learning Notes
I am maintaining the complete structured notes and resources in my GitHub repository.
👉 Java Learning Notes — Telusko Core Java
The GitHub repository contains my concise learning notes and resources, while these DEV.to articles go deeper into the questions and concepts that I found confusing during my learning.
Final Takeaway
For me, this lesson connected the setup from Video 02 with actual Java programming.
The basic idea I want to carry forward is:
Create .java file
↓
Write Java code
↓
Compile using javac
↓
Generate bytecode
↓
Run using java
↓
JVM executes it
↓
See the output
And when I simply want to test a small idea:
JShell
↓
Experiment
↓
Learn
Now that I understand the basic workflow, I'm ready to learn the part that initially looked mysterious:
What actually needs to be inside a Java application for the code to run?
That's what the next lesson starts exploring.
Top comments (0)