Turning Learners Into Developers
Codekilla
CODEKILLA
back to course
Lesson 02 / 803%· free preview
Getting Started2/4

Java Get Started

Install JDK + IntelliJ/VS Code, compile your first program, and understand `javac` vs `java`.

What is Java?

To start writing Java, you need exactly two things:

  1. A JDK (Java Development Kit) — gives you javac (compiler) + java (runtime).
  2. A text editor or IDE — IntelliJ IDEA, VS Code, Eclipse, or even Notepad.
Choose a JDK
OSRecommended JDKInstall
WindowsEclipse Temurin 21 LTSadoptium.net installer
macOSEclipse Temurin or OpenJDKbrew install --cask temurin
LinuxOpenJDK 21sudo apt install openjdk-21-jdk

Verify your install:

bash
javac --version
java --version

You should see something like:

javac 21.0.2
openjdk 21.0.2 2024-01-16
Hello World — End to End

Step 1. Create a file HelloWorld.java:

java
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, Codekilla!");
    }
}

Step 2. Compile (produces bytecode):

bash
javac HelloWorld.java

This creates HelloWorld.class in the same folder.

Step 3. Run (note: no .class extension):

bash
java HelloWorld
Hello, Codekilla!
What Just Happened?
  • javac read HelloWorld.java.
  • It translated the source into platform-independent bytecode (HelloWorld.class).
  • java launched the JVM, loaded the class, and called main.
  • The JIT (Just-In-Time) compiler converted hot bytecode into native machine code on the fly.
javac vs java
ToolJobInputOutput
javacCompiler.java source.class bytecode
javaJVM launcherclass name (no .class)runs the program

Two tools, two jobs.

Useful Flags
FlagPurpose
javac -d outPut .class files in out/ folder
javac -Xlint:allShow all warnings
java -cp lib/*Add JARs to classpath
java -Xmx512mLimit heap to 512 MB
java -eaEnable assert statements
IntelliJ IDEA — Recommended IDE
  1. Download IntelliJ IDEA Community (free) from jetbrains.com.
  2. Open it, click New Project → Java.
  3. Pick your JDK → name the project → finish.
  4. Right-click srcNew → Java Class → type HelloWorld.
  5. Paste the snippet above → click the green ▶ button.
VS Code Setup (lightweight alternative)
  1. Install VS Code.
  2. Add the Extension Pack for Java by Microsoft.
  3. Open your folder, create HelloWorld.java, hit ▶.
Online Compiler — Skip Setup

Don't want to install? Use Codekilla's online Java compiler — write code in the browser, click Run, see output.

Build Tools — Maven & Gradle

Real Java projects use Maven or Gradle — they fetch dependencies, compile, test, and package one-command:

bash
mvn package          # Maven
gradle build         # Gradle

You'll meet them later. For now, plain javac/java is fine.

Common Mistakes
  • Running java HelloWorld.class — drop the .class. Use java HelloWorld.
  • Filename mismatchpublic class HelloWorld requires HelloWorld.java (case-sensitive).
  • javac: command not found — JDK not on PATH. Restart terminal or add the JDK's bin/ to PATH.
  • Mixing JDK versions — multiple JDKs installed → java --version may differ from javac --version. Use JAVA_HOME to pin one.
  • Skipping -Xlint:all — you'll miss warnings the compiler could catch for free.
Interview Questions

Practice Exercises
  1. Install + compile — Set up JDK 21 on your machine and compile HelloWorld.java. Confirm java HelloWorld works. Hint: check java --version.
  2. Different folder — Compile with javac -d out HelloWorld.java. Run with java -cp out HelloWorld. Hint: out/HelloWorld.class.
  3. Read input — Modify the program to read your name with Scanner and greet you. Hint: import java.util.Scanner; new Scanner(System.in).nextLine();.
  4. JAR it — Run jar cfe app.jar HelloWorld HelloWorld.class, then java -jar app.jar. Hint: cfe = create-file-entry-point.

💡 Think Like a Programmer: Master your toolchain first. Spending 30 minutes on javac, java, and IntelliJ saves you days of confusing build bugs later.

AI-powered recap

Quick recap quiz?

We'll generate 5 MCQs from this lesson and check your understanding instantly. Takes ~30 seconds.

# program

Program

Java
public class Main {
    public static void main(String[] args) {
        System.out.println("Welcome to Java on Codekilla");
    }
}
Ready to move on?
// example library
Want more hands-on snippets in Java?
Browse 100 runnable examples · across 10 chapters · short, copy-paste-friendly · grouped by topic
Explore examples
// deep-dive
Go deeper — hand-picked articles
Long-form guides, shortcuts, and mental models that won't fit in a single lesson.
Open Blog
// feedback.matters()
Did this lesson help you?
100% found this helpful · 1 vote