Installationeasy0-2 years
`java -version` reports 21. `javac -version` reports 17. The build fails with errors about syntax that is definitely valid Java 17 and definitely legal in 21. What's actually going on, and why are `PATH` and `JAVA_HOME` both part of the answer?
Two JDKs are installed, and java and javac are resolving to different ones. PATH is an ordered list of directories the shell searches for a bare command name, and it uses the first match — so if a Java 21 install's bin/ comes before a Java 17 install's bin/ in PATH, but something else (an IDE setting, an older shell alias, a build tool reading JAVA_HOME) still points javac at the Java 17 install, the two commands quietly disagree. It looks like a language problem — the error messages complain about syntax — and is actually a directory-order problem: fix it by setting JAVA_HOME to the JDK you actually want and putting $JAVA_HOME/bin first in PATH, so both java and javac come from the same installation.
PreviousA colleague wants to switch a production service from Temurin to Corretto to save on a support contract, and says "it doesn't matter, they're both just OpenJDK." What part of that claim is solid, and what still needs to be checked before shipping the switch?Next A tutorial written for Java 8 in 2015 still compiles and runs correctly today. Why does that backward compatibility hold across a decade, and why doesn't "a new Java version every six months" mean constant forced upgrades for a production team?