
A dependable Java setup has a known JDK, an editor configured to use it and a build that can run outside the editor. Verify those pieces with a small program before adding an application framework. This guide uses Java 25 as an explicit exercise baseline and shows where mismatched versions usually enter the workflow.
Select the JDK for the project
For an existing project, begin with its documented Java version and build instructions. For this exercise, use a JDK 25 distribution appropriate to your operating system and processor architecture. Obtain it from an official distributor, such as Eclipse Temurin or the Oracle Java downloads, and review its license and support terms for your use.
The JDK supplies both java, which launches applications, and javac, which compiles source. Choose an installation folder you can identify later. On Windows, a portable ZIP can be extracted into a dedicated tools folder; on macOS and Linux, follow the distributor's package or archive instructions. Use the distribution's checksum to verify an archive where provided.
A versioned exercise is easier to reproduce than instructions that silently change with “latest.” The examples here were checked with Eclipse Temurin 25.0.4.1+1 and Maven 3.9.9 on Windows. They use no preview features. Pinned sample dependencies describe that test baseline; review supported patches before using a configuration in production.
Make one terminal use the intended JDK
Run java --version and javac --version. Then identify which executable each command resolves to. PowerShell's Get-Command java,javac shows the selected paths; Unix shells provide command -v java and command -v javac. If several installations exist, the first matching entry on PATH normally wins.
For a temporary PowerShell setup, replace the example path with your extracted JDK root—the folder containing bin:
$env:JAVA_HOME = "C:\Tools\jdk-25"
$env:PATH = "$env:JAVA_HOME\bin;$env:PATH"
java --version
javac --versionFor a Unix shell, use the actual JDK root. On macOS, an archive installation's root may end in Contents/Home:
export JAVA_HOME="/path/to/jdk-25"
export PATH="$JAVA_HOME/bin:$PATH"
java --version
javac --versionThese commands affect the current shell and its child processes. After verifying the selection, use your operating system's supported configuration method if you want it to persist. The official Java setup instructions explain the JDK layout and environment selection.
Compile a small environment check
Download SetupCheck and a minimal Maven project (ZIP)
public class SetupCheck {
public static void main(String[] args) {
System.out.println("Runtime feature: " + Runtime.version().feature());
System.out.println("Vendor: " + System.getProperty("java.vendor"));
System.out.println("Java home: " + System.getProperty("java.home"));
System.out.println("Architecture: " + System.getProperty("os.arch"));
if (Runtime.version().feature() < 25)
throw new IllegalStateException("This exercise targets Java 25 or newer");
System.out.println("Setup check passed");
}
}javac SetupCheck.java
java SetupCheckThe output identifies the runtime's feature version, vendor, Java home and processor architecture, then prints Setup check passed. Paths and vendor strings depend on your installation. For this exercise, expect feature version 25; a deliberately chosen newer runtime also passes. The program rejects a feature version below 25.
The check exposes the runtime actually launching the program. It does not prove that a separate editor process or build daemon uses the same installation, so repeat the check through the editor and the build.
Align the editor and build tool
Choose an editor based on the project's needs and the team's existing workflow. IntelliJ IDEA, Eclipse and Visual Studio Code each have Java integration. Useful criteria include debugging, build import, test navigation, accessibility and the dependencies the project already uses. The Java learning hub links to setup instructions for these editors.
Configure the project SDK or Java runtime, language level and build-runner JDK. In some editors these are separate settings. Import the Maven project from its pom.xml and let the build file define dependencies. Run SetupCheck from the editor and compare its Java-home output with the terminal result.
Install Maven using the official installation instructions, then run mvn --version. That reports Maven's own Java runtime. In the extracted sample, the project folder contains this layout:
project/
pom.xml
src/main/java/SetupCheck.javacd project
mvn -q compile
java -cp target/classes SetupCheckThe POM pins the compiler plugin and sets maven.compiler.release to 25. This option checks language features and the target platform's documented APIs for that release, as explained in the Maven compiler release guide. It also needs a compiler capable of targeting that release. A POM setting cannot make an older installed compiler understand a newer Java version.
Make a build repeatable on another machine
Keep the POM, source and tests in version control. Pin dependency and plugin versions, state the intended JDK, and record the commands a fresh checkout needs. Maven's project introduction explains the standard directory structure and build lifecycle.
For a team project, a checked-in Maven Wrapper can select a Maven distribution; it still needs a compatible JDK. Maven toolchains can select a compiler explicitly when several JDKs coexist. Keep local credentials and machine-specific paths outside the shared project, and supply them through the approved local or CI configuration.
Verify in a fresh folder or CI job that compilation and tests work without an editor session. Compilation alone only checks that source can be built; run behavior checks too. The study-plan tutorial includes a small executable test and invalid-input cases.
Resolve the mismatch shown by the error
On a narrow screen, scroll the table horizontally. Keyboard users can focus the table and use the arrow keys.
| Symptom | Meaning to investigate | Corrective step |
|---|---|---|
| java works; javac is unavailable | Runtime-only installation or different PATH entries | Select the JDK bin directory and verify both paths. |
| release version 25 not supported | The build compiler is older than the target | Inspect mvn --version, editor build JDK and any toolchain selection. |
| UnsupportedClassVersionError | Runtime is older than compiled bytecode | Use the intended runtime or compile for the supported deployment release. |
| Works in editor, fails in terminal | Different classpath, working folder or JDK | Compare SetupCheck output and run the documented build command. |
| Dependency cannot be downloaded | Repository, proxy, certificate or version issue | Inspect the repository response and approved network configuration. |
Fix the identified layer before reinstalling everything. If a build tool prints a deprecation warning but completes successfully, record which dependency emitted it and follow the tool's upgrade guidance. Preserve certificate verification when resolving repository access. Once both terminal and editor produce the expected result, the setup is ready for the next small program.