How to Install Java on Ubuntu and set JAVA_HOME (2025 UPDATE) #JDK #Ubuntu #Java21 #JRE #JVM #Linux
Cameron McKenzie
@cameronmcnzAbout
Welcome to The Cameron McKenzie Developer's Channel – your all-in-one hub for mastering Java, Spring Boot, and Git! Whether you're a beginner or an advanced developer, our channel is packed with detailed tutorials, expert tips, and practical advice on building modern, scalable applications using the powerful Spring Boot framework. We cover everything you need to know about Spring Boot, from the fundamentals to advanced concepts, with in-depth tutorials on the most important Spring Boot starters: Spring Boot Starter Web Spring Boot Starter Security Spring Boot Starter Data JPA Spring Boot Starter Actuator Spring Boot Starter OAuth2 In addition to Spring Boot, we place a strong emphasis on Git, the version control system every developer should know. We cover key Git concepts and commands to help you collaborate effectively and manage your codebase. Want to learn Spring, Java, Git and even Python and Mojo? You're in the right place!
Latest Posts
Video Description
This quick Java on Ubuntu tutorial will show you how to install the JDK on Ubuntu 24, set JAVA_HOME and validate the installation. To install the JDK on Ubuntu and set the JAVA_HOME environment variable, follow these steps: 1. Install the JDK Open a terminal on your Ubuntu system. Update your package list to ensure you have access to the latest repository data. Install the OpenJDK package. The most commonly used version is OpenJDK 17, which is widely supported and stable. If you need a different version, specify it (e.g., openjdk-11-jdk). The installation will include all necessary components to compile and run Java applications. 2. Verify the Installation After the installation is complete, verify it by checking the installed Java version: This confirms that the JDK is installed and available in your system. 3. Find the JDK Path To set the JAVA_HOME environment variable, locate the JDK installation path. For OpenJDK, it is typically installed under /usr/lib/jvm/. List the contents of the directory to find the exact path for your installed JDK version (e.g., java-17-openjdk-amd64). 4. Set the JAVA_HOME Environment Variable Open your terminal and edit the shell configuration file for your shell. If you’re using bash, this file is usually ~/.bashrc or ~/.profile. Add the following lines at the end of the file: Replace /path/to/jdk with the actual path to your JDK installation directory (e.g., /usr/lib/jvm/java-17-openjdk-amd64). Save the file and reload the shell configuration to apply the changes: Alternatively, you can log out and log back in to apply the changes. 5. Verify JAVA_HOME Confirm that the JAVA_HOME environment variable is set correctly: This should print the path you specified, confirming that JAVA_HOME is configured. 6. Add JDK’s Bin Directory to PATH (Optional) To make Java commands globally accessible, append the JDK’s bin directory to the PATH variable. Add the following to your shell configuration file: Save and reload the file as described earlier. 7. Test the Configuration Test the configuration by running Java commands from the terminal: This ensures that the JAVA_HOME and PATH variables are correctly set. By following these steps, you’ll have the JDK installed and properly configured on your Ubuntu system, ready for Java development!
Java Development Must-Haves
AI-recommended products based on this video

Hydrocolloid Bandages for Wound Care, Extra Large Medical-Grade Hydrocolloid Roll with Self-Adhesive, Ultra Absorbent, Flexible & Waterproof, DIY Size & Shape First Aid Kit Essential (2in*4.8ft)

Rain-X 600001 Windshield Repair Kit - Quick and Easy Durable Resin Based Windshield Repair Kit for Chips and Cracks, Good for Round Damage Below 1" in Diameter and Cracks Smaller Than 12" in Length


















