Installing a JDK
You need a JDK, not a JRE, and it matters less which one than people suggest.
To compile and run Java you need a JDK — a development kit. A JRE is a runtime only; it will run a program someone else compiled and will not compile yours. Most confusion at this stage comes from having installed the wrong one.
Which version
Pick the most recent LTS release unless something forces your hand. LTS releases get years of updates, and every book, course and Stack Overflow answer you meet will work against one.
Reasons your hand might be forced:
- A course or employer specifies a version. Use theirs.
- A library you depend on has not been tested above a certain release.
- You are reading older material. Most of it still applies — the language has been unusually careful about backward compatibility — but the syntax has gained a fair amount since Java 8.
Which distribution
Java is a specification with several implementations built from the same OpenJDK source. For learning, they are interchangeable. Any of the mainstream builds — Adoptium’s Temurin, Amazon Corretto, Azul Zulu, Microsoft’s build, or your Linux distribution’s openjdk package — will behave identically for everything in these notes.
Two practical notes. Oracle’s own JDK has had licence terms that changed more than once, so if you are installing on a work machine, check what your employer allows. And on Linux, installing through the package manager keeps updates automatic, which is worth more than a marginally newer build.
Checking it worked
Open a terminal and run both:
java -version
javac -version
Both must respond, and they must report the same version. If java works and javac does not, you have a JRE, or a JDK that is not on your PATH. If they report different versions, you have more than one Java installed and the PATH is finding pieces of each — the usual cause of “my code compiles but won’t run”.
Then what
You do not need an IDE to start. A text editor and those two commands are enough to work through most of these notes, and doing it that way once makes it much clearer what an IDE is doing for you later. See choosing an editor.