Install Java
You want to run the file from the last page. When that file runs, the screen shows mint. The computer cannot run it yet, because the two commands that do the work are not on the computer. This page puts those commands on the computer, then runs the file. Finished looks the same on Windows and on macOS: java -version writes a version line, javac -version writes a version line, javac Mint.java writes no line, and java Mint writes mint. The steps you click before those commands are not the same on the two systems. Windows gets its own section. macOS gets its own section. Do the section that matches the computer in front of you, then come back to the shared part and run the file.
What you are installing
The download is a JDK. JDK is the short name for the kit that contains the Java commands. Two of those commands matter on this page. javac reads the file Mint.java and prepares it. java runs that prepared file and is the command that writes mint. A computer with only one of them is not finished. If javac is missing, the file cannot be prepared. If java is missing, the prepared file cannot be run, and the screen never shows mint. You do not type the letters JDK into the terminal. You install the kit, and the kit adds javac and java.
Get the kit from adoptium.net. The kit on that site is called Eclipse Temurin. On the download page, choose a current long-term release. For this course that means version 21 or newer. In 2026 the current long-term release includes 25, and a later year may show a higher long-term number. Take 21 or whatever higher long-term number the page is offering. Do not take Java 8. Java 8 is too old for the pages ahead, and a version line that only contains 8 means you downloaded the wrong kit. The small numbers after the dot are the patch. One computer might show 21.0.5 and another might show 21.0.6, or one might show 25 where another shows 21. Both are fine. This page never asks you to match a patch number. It asks you to see 21 or a higher number on the version line.
Windows
On Windows you download an installer whose name ends in .msi. On adoptium.net, choose Windows, choose the JDK, and choose the .msi rather than a zip archive. Save the file, then open it. Windows may ask you to allow the installer to make changes. Allow it. The window that opens is the Temurin setup. Click through until you reach the screen that lists what the installer will set up. You are not done when the file has only been downloaded. The .msi has to run to the end.
On that setup screen, one option reads: Add the installation to the PATH environment variable. PATH is the list of folders Windows searches when you type a command. If the Temurin folder is not on that list, the terminal will not find java or javac even though the files are on the disk. The option is already on when the installer opens. Leave it on. Do not clear the check mark. A second option reads: Updating the JAVA_HOME environment variable. You may turn that one on, and you may leave it off. This page does not use JAVA_HOME. The file Mint.java runs without it. Finish the installer and wait until it says the setup is complete. The usual folder is C:\Program Files\Eclipse Adoptium. You do not need to open that folder by hand. The PATH option is what makes the commands visible.
A terminal that was already open cannot see a PATH change. Close every Command Prompt window and every PowerShell window you had open before the installer finished, including any window you used to look around before the install. Then open a new window. In that new window type java -version and press Enter. The screen writes a version line. Somewhere in that line is 21, or a higher number such as 25. The rest of the line can mention Temurin and a patch number. You are checking the number, not copying the whole line. Then type javac -version and press Enter. That command writes its own version line, and that line also contains 21 or a higher number. Two version lines mean both commands are really there. One version line is not enough, because a computer can have java without javac.
If the new window says it cannot find java, or it says the command is not recognized, stop and look at two causes. The first cause is that this window was opened before the installer finished. Close it and open another one. The second cause is that the PATH option was turned off during setup. Run the .msi again, leave Add the installation to the PATH environment variable turned on, finish the installer, and open a new window. Type java -version again, then javac -version. Do not continue to Mint.java while either command is missing. A version line that contains only 8 means the kit is Java 8. Remove that choice from the work of this page and install Temurin 21 or newer.
macOS
macOS does not use the Windows .msi, and it does not show the PATH checkbox. On adoptium.net choose macOS, then choose the chip in the computer. A Mac with Apple silicon, the machines sold as M1 and later, uses the aarch64 download. An older Mac with an Intel chip uses the x64 download. The file you want ends in .pkg. Download that file and open it. The installer starts with a short introduction that names the folder it will use. Click Continue. Read the license, click Continue, and agree. Then click Install and let the installer finish. You can leave the folder it offers. The kit lands under /Library/Java/JavaVirtualMachines/. You do not type that path on this page. You do not edit a shell file on this page. The .pkg is the whole macOS install.
When the installer says it succeeded, quit Terminal if it was already open and open Terminal again. The old window was started before the kit existed, so it can still say the command is missing. In the new window type java -version. The screen writes a version line containing 21 or a higher number, the same check as on Windows. Then type javac -version. That writes a version line too. There is no PATH checkbox to go back and tick, because the macOS installer does not have that Windows option. If the new Terminal still cannot find java, the .pkg did not finish. Open the .pkg again and click Install, then open Terminal once more and type the two version commands. A dialog that offers to install Java for you from somewhere else is not this kit. Close that dialog and use the Temurin .pkg from adoptium.net.
Linux
Linux is a third install, not a copy of the Mac steps. On adoptium.net choose Linux and choose the package kind your system installs: a .deb package, an .rpm package, or an .apk package. Install that package the way you install other packages of the same kind. When the package install finishes, open a new terminal. An old terminal window will not see the new commands. Type java -version, then javac -version. Each writes a version line containing 21 or a higher number. If the terminal cannot find java, the package install did not finish or the window is old. Finish the package, open a new window, and type the two commands again. The rest of this page, the file and the two run commands, is the same as on Windows and on macOS.
Save Mint.java and run it
The version lines do not write mint. They only prove the kit is installed. mint comes from the file. Make a folder you can open in the terminal, and save the file there with the name Mint.java. The first line inside the file is public class Mint, so the file name has to be Mint.java, with that capital M, and the extension has to be .java. A file named mint.java, or Mint.txt, is a different file, and javac will not treat it as this program. This is the file to save.
public class Mint {
public static void main(String[] args) {
System.out.println("mint");
}
}
Move the terminal into the folder that contains Mint.java. On Windows you can open the terminal from that folder, or use cd with the folder's path. On macOS and Linux, cd to that folder in the new terminal. Type javac Mint.java and press Enter. When the file is fine, this command writes no line at all. A quiet terminal here is success, not a freeze. Then type java Mint and press Enter. Do not type .java after java. The screen shows mint. The word mint is not in the command java Mint. The file writes it, from the word between the quotes. The screen has one line. There is no second line. The capital M in the file name is not the word on the screen.
📊 What each command writes
| What you type | Screen |
|---|---|
| java -version | a version line, 21 or higher |
| javac -version | a version line |
| javac Mint.java | no line |
| java Mint | mint |
If javac says it cannot find Mint.java, look at the version lines before you reinstall anything. When java -version still writes a version line, Java is already installed and the terminal is simply in another folder. The file is somewhere else on the disk. Go to the folder that actually contains Mint.java and type javac Mint.java again. When that command writes no line, type java Mint. The second command writes mint. Reinstalling the kit does not fix a wrong folder.
The install is finished only when all four rows of that table have happened in the same new terminal, in the folder that contains the file. Both version commands have written a line. javac Mint.java has written nothing. java Mint has written mint. If you stop after the version lines, the kit is installed and the program has not been run. The next page opens this same file and reads the lines inside it, one at a time, to show which line writes mint and which lines do not.
The screen after install
java -version writes a version line that contains 21 or a higher number. javac -version writes a version line. javac Mint.java writes no line. java Mint writes mint, one line, with no quotes and no second line. Windows reached that screen through the .msi with PATH left on. macOS reached it through the .pkg. The screen at the end is the same.
🧠 Test Your Knowledge
Test Your Knowledge
Challenge yourself with this interactive quiz and see how well you understand the topic
📝 Instructions
- Read each question carefully
- Select the best answer for each question
- You can retake the quiz as many times as you want
- Your progress will be shown at the top