Installing Java on Your Machine
Note: this page has been created with the use of AI. Please take caution, and note that the content of this page does not necessarily reflect the opinion of Cratecode.
Before you can start creating awesome Java applications, you need to have Java installed on your machine. You're in luck, because in this article we've got you covered on how to install Java on Windows, Mac, and Linux.
Java Installation for Windows
-
Download the Java installer: To start, head over to the official Java website and download the appropriate installer for your version of Windows (64-bit or 32-bit).
-
Run the installer: Locate the downloaded file (usually in the "Downloads" folder) and double-click it to launch the Java installer.
-
Follow the installation steps: Follow the instructions in the installer, such as accepting the license agreement and specifying the installation directory. The default settings usually work fine.
-
Verify Java installation: Open a command prompt by pressing
Win + R
, typingcmd
, and pressing Enter. Type the commandjava -version
and hit Enter. If the installation was successful, you should see the installed Java version displayed.
Java Installation for Mac
-
Download the Java installer: Visit the official Java website and download the macOS installer.
-
Run the installer: Locate the downloaded
.dmg
file and double-click it to mount the installer. Then, double-click the installer icon to start the installation process. -
Follow the installation steps: Follow the on-screen instructions to complete the installation process.
-
Verify Java installation: Open the Terminal app and type the command
java -version
. Press Enter, and you should see the installed Java version displayed.
Java Installation for Linux
-
Download the Java installer: Navigate to the official Java website and download the Linux tarball for your system architecture (x64 or ARM).
-
Extract the tarball: Open a terminal window and navigate to the directory where the tarball was downloaded. Extract the tarball using the following command, replacing
jdk-xx_linux-x64_bin.tar.gz
with the name of the file you downloaded:tar -xvf jdk-xx_linux-x64_bin.tar.gz
-
Move the extracted folder: Move the extracted folder to the
/usr/lib/jvm
directory with the following command, replacingjdk-xx
with the extracted folder name:sudo mv jdk-xx /usr/lib/jvm/
-
Update the alternatives: Run the following command to update the alternatives for Java:
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-xx/bin/java 1
-
Verify Java installation: Type the command
java -version
in the terminal and press Enter. The installed Java version should be displayed.
Now that you've installed Java on your machine, you're ready to start programming! Happy coding!
Hey there! Want to learn more? Cratecode is an online learning platform that lets you forge your own path. Click here to check out a lesson: Rust - A Language You'll Love (psst, it's free!).