Module 1: Start Coding in Java
Install Java 25 and Verify the Right JDK
Install a complete Java 25 JDK, verify the runtime and compiler, detect conflicting Java versions, and choose an editor without confusing the editor with Java itself.
Author
Java Learner
Java version
Java 25 LTS
Learning goals
- Choose and install a trusted Java 25 JDK distribution
- Verify the `java` runtime and `javac` compiler separately
- Identify the executable paths used by the current terminal
- Recognize common PATH and multiple-version problems
- Distinguish the JDK from an editor or IDE
Before you start
- You can run and repair a complete program in the browser compiler
- You can open a terminal or PowerShell window
- You have permission to install software on your computer
Install a full JDK. This course needs both the Java runtime and the Java compiler. A Java Development Kit includes both. Avoid downloading an old standalone JRE package because it may let programs run without providing the javac compiler needed to build them.
Choose one trusted Java 25 distribution. Oracle JDK and Eclipse Temurin are common choices. They implement the same Java language and standard platform. For a beginner course, the important requirement is that both java and javac report major version 25.
Download the build for your operating system and processor. Most current Windows and Linux computers use an x64 build. Apple Silicon Macs use an arm64 or AArch64 build. When uncertain, check the system information before downloading instead of guessing.
Windows installation path. Run the JDK installer, keep the default installation folder unless you have a reason to change it, and enable options that add Java to PATH or configure JAVA_HOME when the installer offers them. Close existing terminals and open a new PowerShell or terminal window after installation.
macOS installation path. A signed .pkg installer is the simplest route for most beginners. Complete the installer and open a new terminal. If several JDKs are installed, /usr/libexec/java_home -V can list the detected versions.
Linux installation path. Prefer the full JDK package supplied by your distribution when Java 25 is available. Package names and commands differ between distributions. Confirm that you installed the development kit rather than only a runtime package. A vendor archive is another option, but it requires manual PATH configuration.
Verify the runtime and compiler separately. Run java -version and javac -version in a newly opened terminal. The exact wording varies by vendor, but both commands should report major version 25.
Check which executable the terminal found. On Windows, use where.exe java and where.exe javac. On macOS or Linux, use command -v java and command -v javac. Different locations can explain why the runtime and compiler report different versions.
A mismatch means the setup needs attention. If java reports 25 but javac reports 21, your terminal is mixing tools from different installations. If java works but javac is missing, the full JDK may not be installed or its bin directory may not be on PATH.
Restart the terminal after changing PATH. Existing terminal processes usually keep their old environment. Opening a new terminal is often enough to make newly installed commands visible.
An IDE does not replace the JDK. IntelliJ IDEA Community Edition and VS Code with Java extensions can edit, run, and debug code, but they still need a JDK. An IDE may also use a different configured JDK from the one selected by your terminal.
Choose one editor for now. IntelliJ IDEA offers an integrated Java experience. VS Code is lighter but requires Java extensions. A plain text editor also works for this module. Do not spend the first day comparing every available tool.
Keep terminal commands out of Java source files. Commands such as java -version, javac -version, mkdir, and cd belong in a terminal. Java statements belong in .java files.
Runnable examples
Verify the installed runtime and compiler
Run in a terminaljava -version
javac -versionExpected output
The exact text depends on the distribution. Both results should identify major version 25.
Find the Java commands on Windows
Run in a terminalwhere.exe java
where.exe javacExpected output
PowerShell or Command Prompt prints the path or paths used to locate the Java runtime and compiler.
Find the Java commands on macOS or Linux
Run in a terminalcommand -v java
command -v javacExpected output
The shell prints the executable selected for each command. Both should belong to the intended JDK installation.
Practice the lesson
Predict first, make a change, repair a real problem, then write a small program independently.
Predict the result
`java -version` reports 25, but `javac -version` reports 21. Is the setup ready for this course, and what does the mismatch suggest?
Show answer
No. The terminal is finding a Java 25 runtime and a Java 21 compiler, probably from different installations or different PATH entries.
The source could be compiled with a different language level from the runtime used to start it. Configure the terminal so both commands come from the intended Java 25 JDK.
Change the program
Create a setup record containing the runtime version, compiler version, and executable locations selected by your terminal.
java -version
javac -version
# Windows:
where.exe java
where.exe javac
# macOS or Linux:
command -v java
command -v javacSuccess criteria
- • You run only the commands for your operating system.
- • Both version commands report major version 25.
- • You record the executable path for both `java` and `javac`.
- • The paths and versions are consistent with the JDK you intended to install.
- • You keep the record in a normal text file, not inside `Main.java`.
Diagnose conflicting Java versions
The runtime and compiler are both available, but they come from different major versions. Explain the likely cause and what must be true after the configuration is corrected.
> java -version
openjdk version "25.0.2"
> javac -version
javac 21.0.10What happens: The terminal is mixing Java tools from different installations. This commonly happens when PATH contains more than one JDK `bin` directory or an older entry appears first.
Show the correction
java -version
javac -versionIndependent challenge
Prepare a clean local workspace and produce enough evidence to diagnose the setup later without reinstalling Java immediately.
- • Create a folder named `java-course` and enter it from the terminal.
- • Confirm the folder location using the terminal command available on your operating system.
- • Run both Java version commands.
- • Find the executable selected for both Java commands.
- • Save the results in a text file named `setup-check.txt`.
- • Open the folder in one editor or IDE.
Show one complete solution
mkdir java-course
cd java-course
java -version
javac -versionExpected output
A `java-course` workspace plus a setup record showing a Java 25 runtime, Java 25 compiler, and their executable locations.
Common mistakes
Checking `java -version` but never checking `javac -version`
Verify both commands. The runtime can be available even when the compiler is missing.
Running the checks in a terminal that was open before installation
Close it and open a new terminal so the process receives the updated PATH.
Assuming the newest installed JDK is automatically selected
Use the version and path commands to confirm which installation the current terminal actually found.
Installing several JDK distributions while troubleshooting
Start with one known Java 25 JDK. Multiple installations make PATH and IDE configuration harder to diagnose.
Believing that installing an editor also installs the required JDK
Treat the editor and JDK as separate tools and verify Java from a terminal.
Summary
- Install a full Java 25 JDK, not only a runtime.
- Verify `java` and `javac` separately in a newly opened terminal.
- Both commands should report major version 25.
- Executable-location commands help diagnose conflicting Java installations.
- The editor or IDE and the JDK are separate parts of the development setup.
- Terminal commands belong in the terminal, not in a Java source file.
Keep the reference close
Next step
With the Java 25 runtime and compiler verified, create `Main.java`, compile it into a class file, run it locally, and diagnose common errors.
Sources used