{"id":164551,"date":"2026-03-25T19:35:14","date_gmt":"2026-03-25T16:35:14","guid":{"rendered":"https:\/\/computingforgeeks.com\/install-java-jdk-ubuntu\/"},"modified":"2026-03-25T19:35:14","modified_gmt":"2026-03-25T16:35:14","slug":"install-java-jdk-ubuntu","status":"publish","type":"post","link":"https:\/\/computingforgeeks.com\/install-java-jdk-ubuntu\/","title":{"rendered":"Install Java 25 (JDK 25) on Ubuntu 24.04 \/ 22.04"},"content":{"rendered":"\n<p>JDK 25 landed as the next long-term support release with eight years of patches ahead of it (through September 2033). Both Ubuntu 24.04 and 22.04 carry <code>openjdk-25-jdk<\/code> in their repositories, so getting the latest LTS Java on Ubuntu is a one-liner. If you need Oracle&#8217;s build or Adoptium&#8217;s Temurin instead, those are covered here too.<\/p>\n\n\n\n<p>This guide walks through installing JDK 25 via OpenJDK packages, Oracle&#8217;s .deb installer, and the Eclipse Temurin repo. It covers setting <code>JAVA_HOME<\/code>, managing multiple Java versions side by side, testing JDK 25 features like compact source files and module imports, configuring garbage collectors, and production tuning. Every command and output block comes from real Ubuntu systems.<\/p>\n\n\n\n<p><em>Verified working: <strong>March 2026<\/strong> on Ubuntu 24.04.2 LTS (Noble Numbat) and Ubuntu 22.04 LTS (Jammy Jellyfish), OpenJDK 25.0.2+10, Oracle JDK 25.0.2+10-LTS, Temurin 25.0.2+10<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">JDK 25 at a Glance<\/h2>\n\n\n\n<p>Released September 16, 2025, JDK 25 is the fourth LTS release (after 8, 11, 17, and 21). The latest patch is 25.0.2, released January 20, 2026. Here are the headline features that shipped as final (not preview):<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>JEP<\/th><th>Feature<\/th><th>What It Does<\/th><\/tr><\/thead><tbody><tr><td>512<\/td><td>Compact Source Files<\/td><td>Write <code>void main() {}<\/code> without a class declaration. Run .java files directly<\/td><\/tr><tr><td>513<\/td><td>Flexible Constructor Bodies<\/td><td>Execute validation code before <code>super()<\/code> calls<\/td><\/tr><tr><td>506<\/td><td>Scoped Values<\/td><td>Immutable, thread-safe context sharing (replaces ThreadLocal for virtual threads)<\/td><\/tr><tr><td>519<\/td><td>Compact Object Headers<\/td><td>Cuts object headers from 128 to 64 bits, reducing memory overhead<\/td><\/tr><tr><td>521<\/td><td>Generational Shenandoah<\/td><td>Low-pause GC with young\/old generation separation<\/td><\/tr><tr><td>510<\/td><td>Key Derivation Function API<\/td><td>New crypto API for deriving keys from existing secrets<\/td><\/tr><tr><td>514<\/td><td>AOT Ergonomics<\/td><td>Simplified ahead-of-time compilation for faster startup<\/td><\/tr><tr><td>518<\/td><td>JFR Cooperative Sampling<\/td><td>Lower overhead profiling in Java Flight Recorder<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Full details at the <a href=\"https:\/\/openjdk.org\/projects\/jdk\/25\/\" target=\"_blank\" rel=\"noreferrer noopener\">OpenJDK 25 project page<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install OpenJDK 25 on Ubuntu 24.04<\/h2>\n\n\n\n<p>Ubuntu 24.04 ships OpenJDK 25 in its default repositories. No PPAs or third-party repos needed.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install -y openjdk-25-jdk<\/code><\/pre>\n\n\n\n<p>Verify the installation:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java -version<\/code><\/pre>\n\n\n\n<p>Ubuntu&#8217;s build includes the distribution name in the version string:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>openjdk version \"25.0.2\" 2026-01-20\nOpenJDK Runtime Environment (build 25.0.2+10-Ubuntu-124.04)\nOpenJDK 64-Bit Server VM (build 25.0.2+10-Ubuntu-124.04, mixed mode, sharing)<\/code><\/pre>\n\n\n\n<p>The compiler is included:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>javac -version<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>javac 25.0.2<\/code><\/pre>\n\n\n\n<p>If you only need the runtime (for running Java apps, not compiling), install the lighter JRE package:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install -y openjdk-25-jre<\/code><\/pre>\n\n\n\n<p>The JDK installs to <code>\/usr\/lib\/jvm\/java-25-openjdk-amd64<\/code> and provides 30 tools including <code>javac<\/code>, <code>jshell<\/code>, <code>jlink<\/code>, <code>jpackage<\/code>, and <code>jwebserver<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install OpenJDK 25 on Ubuntu 22.04<\/h2>\n\n\n\n<p>Ubuntu 22.04&#8217;s default JDK is OpenJDK 11, but the universe repository includes OpenJDK 25 backported from newer releases. The install command is identical:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install -y openjdk-25-jdk<\/code><\/pre>\n\n\n\n<p>Verify it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java -version<\/code><\/pre>\n\n\n\n<p>The build tag shows 22.04:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>openjdk version \"25.0.2\" 2026-01-20\nOpenJDK Runtime Environment (build 25.0.2+10-Ubuntu-122.04)\nOpenJDK 64-Bit Server VM (build 25.0.2+10-Ubuntu-122.04, mixed mode, sharing)<\/code><\/pre>\n\n\n\n<p>Same JDK 25.0.2, same features, just compiled against Ubuntu 22.04&#8217;s libraries. If the package isn&#8217;t found, enable the universe repository first: <code>sudo add-apt-repository universe && sudo apt update<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install Oracle JDK 25<\/h2>\n\n\n\n<p>Oracle provides a .deb package that handles alternative registration automatically. The codebase is identical to OpenJDK, but the license differs (Oracle NFTC, free for production use until September 2028).<\/p>\n\n\n\n<p>Download the package directly from Oracle:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget https:\/\/download.oracle.com\/java\/25\/latest\/jdk-25_linux-x64_bin.deb -O \/tmp\/jdk-25.deb<\/code><\/pre>\n\n\n\n<p>Install it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dpkg -i \/tmp\/jdk-25.deb<\/code><\/pre>\n\n\n\n<p>Oracle&#8217;s build uses the HotSpot branding:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java -version<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>java version \"25.0.2\" 2026-01-20 LTS\nJava(TM) SE Runtime Environment (build 25.0.2+10-LTS-69)\nJava HotSpot(TM) 64-Bit Server VM (build 25.0.2+10-LTS-69, mixed mode, sharing)<\/code><\/pre>\n\n\n\n<p>Oracle JDK installs to <code>\/usr\/lib\/jvm\/jdk-25.0.2-oracle-x64<\/code>. Clean up the downloaded package when done:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rm \/tmp\/jdk-25.deb<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Install Eclipse Temurin 25 (Adoptium)<\/h2>\n\n\n\n<p>Temurin is Adoptium&#8217;s OpenJDK distribution. It uses the same source as OpenJDK but provides its own builds with independent testing and an apt repository that makes updates automatic.<\/p>\n\n\n\n<p>Add the Adoptium GPG key and repository:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install -y wget apt-transport-https gpg\nwget -qO - https:\/\/packages.adoptium.net\/artifactory\/api\/gpg\/key\/public | gpg --dearmor | sudo tee \/usr\/share\/keyrings\/adoptium.gpg > \/dev\/null<\/code><\/pre>\n\n\n\n<p>Add the repository for your Ubuntu version. Replace <code>noble<\/code> with <code>jammy<\/code> on Ubuntu 22.04:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"deb [signed-by=\/usr\/share\/keyrings\/adoptium.gpg] https:\/\/packages.adoptium.net\/artifactory\/deb $(lsb_release -cs) main\" | sudo tee \/etc\/apt\/sources.list.d\/adoptium.list<\/code><\/pre>\n\n\n\n<p>Install Temurin 25:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install -y temurin-25-jdk<\/code><\/pre>\n\n\n\n<p>Temurin identifies itself in the version output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java -version<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>openjdk version \"25.0.2\" 2026-01-20 LTS\nOpenJDK Runtime Environment Temurin-25.0.2+10 (build 25.0.2+10-LTS)\nOpenJDK 64-Bit Server VM Temurin-25.0.2+10 (build 25.0.2+10-LTS, mixed mode, sharing)<\/code><\/pre>\n\n\n\n<p>Temurin installs to <code>\/usr\/lib\/jvm\/temurin-25-jdk-amd64<\/code>. The Adoptium repository also carries Temurin 21, 17, 11, and 8 for older LTS needs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Set JAVA_HOME<\/h2>\n\n\n\n<p>Build tools like Maven, Gradle, and Ant, along with application servers like Tomcat and WildFly, need <code>JAVA_HOME<\/code> pointing to the JDK root. Set it system-wide with a dynamic resolution that follows whichever Java version is currently the default:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo 'export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))' | sudo tee \/etc\/profile.d\/java.sh\nsource \/etc\/profile.d\/java.sh\necho $JAVA_HOME<\/code><\/pre>\n\n\n\n<p>Output on Ubuntu 24.04 with OpenJDK 25:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/usr\/lib\/jvm\/java-25-openjdk-amd64<\/code><\/pre>\n\n\n\n<p>This path updates automatically when you switch versions with <code>update-alternatives<\/code>. For systemd service files or CI pipelines where you need a fixed path, use the explicit directory:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>JDK Build<\/th><th>JAVA_HOME Path<\/th><\/tr><\/thead><tbody><tr><td>OpenJDK 25<\/td><td><code>\/usr\/lib\/jvm\/java-25-openjdk-amd64<\/code><\/td><\/tr><tr><td>Oracle JDK 25<\/td><td><code>\/usr\/lib\/jvm\/jdk-25.0.2-oracle-x64<\/code><\/td><\/tr><tr><td>Temurin 25<\/td><td><code>\/usr\/lib\/jvm\/temurin-25-jdk-amd64<\/code><\/td><\/tr><tr><td>OpenJDK 21<\/td><td><code>\/usr\/lib\/jvm\/java-21-openjdk-amd64<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Manage Multiple Java Versions<\/h2>\n\n\n\n<p>Ubuntu&#8217;s <code>update-alternatives<\/code> system handles multiple JDK installations cleanly. You can have OpenJDK 21, OpenJDK 25, Oracle JDK, and Temurin all installed simultaneously and switch between them instantly.<\/p>\n\n\n\n<p>List all registered Java installations:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo update-alternatives --list java<\/code><\/pre>\n\n\n\n<p>With four JDKs installed, you&#8217;ll see all four paths:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/usr\/lib\/jvm\/java-21-openjdk-amd64\/bin\/java\n\/usr\/lib\/jvm\/java-25-openjdk-amd64\/bin\/java\n\/usr\/lib\/jvm\/jdk-25.0.2-oracle-x64\/bin\/java\n\/usr\/lib\/jvm\/temurin-25-jdk-amd64\/bin\/java<\/code><\/pre>\n\n\n\n<p>Switch to a specific version by setting both <code>java<\/code> and <code>javac<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo update-alternatives --set java \/usr\/lib\/jvm\/java-21-openjdk-amd64\/bin\/java\nsudo update-alternatives --set javac \/usr\/lib\/jvm\/java-21-openjdk-amd64\/bin\/javac<\/code><\/pre>\n\n\n\n<p>Confirm the switch took effect:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java -version<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>openjdk version \"21.0.10\" 2026-01-20\nOpenJDK Runtime Environment (build 21.0.10+7-Ubuntu-124.04)\nOpenJDK 64-Bit Server VM (build 21.0.10+7-Ubuntu-124.04, mixed mode, sharing)<\/code><\/pre>\n\n\n\n<p>Switch back to JDK 25:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo update-alternatives --set java \/usr\/lib\/jvm\/java-25-openjdk-amd64\/bin\/java\nsudo update-alternatives --set javac \/usr\/lib\/jvm\/java-25-openjdk-amd64\/bin\/javac<\/code><\/pre>\n\n\n\n<p>For an interactive picker that shows all versions with priority numbers:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo update-alternatives --config java<\/code><\/pre>\n\n\n\n<p>Always switch both <code>java<\/code> and <code>javac<\/code> together. A version mismatch between compiler and runtime causes subtle bytecode compatibility issues that are painful to debug.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Test JDK 25 Features<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Compact Source Files (JEP 512)<\/h3>\n\n\n\n<p>One of the most visible changes in JDK 25. You can now write a Java source file with just a <code>main()<\/code> method, no class wrapper, and run it directly without compiling:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat > \/tmp\/Greet.java << 'EOF'\nvoid main() {\n    System.out.println(\"Running on Java \" + System.getProperty(\"java.version\"));\n    System.out.println(\"OS: \" + System.getProperty(\"os.name\") + \" \" + System.getProperty(\"os.version\"));\n}\nEOF\njava \/tmp\/Greet.java<\/code><\/pre>\n\n\n\n<p>Output from Ubuntu 24.04:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Running on Java 25.0.2\nOS: Linux 6.8.0-35-generic<\/code><\/pre>\n\n\n\n<p>This is a final feature, not a preview. It works without any flags. Great for quick scripts, prototyping, and teaching.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Module Import Declarations (JEP 511, Preview)<\/h3>\n\n\n\n<p>Instead of importing classes one by one, import all public types from a module with a single line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat > \/tmp\/ModTest.java << 'EOF'\nimport module java.base;\n\nvoid main() {\n    var map = Map.of(\"JDK\", \"25\", \"Type\", \"LTS\", \"Vendor\", \"Ubuntu\");\n    map.forEach((k, v) -> System.out.println(k + \": \" + v));\n}\nEOF\njava --enable-preview \/tmp\/ModTest.java<\/code><\/pre>\n\n\n\n<p>The <code>import module java.base<\/code> line replaces what would normally be <code>import java.util.Map<\/code> plus any other <code>java.base<\/code> imports. Since this is still a preview feature, the <code>--enable-preview<\/code> flag is required:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>JDK: 25\nType: LTS\nVendor: Ubuntu<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">JShell REPL<\/h3>\n\n\n\n<p><code>jshell<\/code> provides an interactive environment for testing Java expressions without creating files:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo 'System.out.println(\"JShell on \" + Runtime.version());' | jshell -q<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>jshell> JShell on 25.0.2+10-Ubuntu-124.04<\/code><\/pre>\n\n\n\n<p>Run <code>jshell<\/code> without arguments for an interactive session where you can test classes, methods, and expressions on the fly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Built-in Web Server<\/h3>\n\n\n\n<p>JDK 25 includes <code>jwebserver<\/code> for quick file serving during development. It serves the current directory over HTTP:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>jwebserver -p 8080 -b 0.0.0.0<\/code><\/pre>\n\n\n\n<p>Access it at <code>http:\/\/your-server:8080\/<\/code>. Strictly for development and testing, not production use. Press <code>Ctrl+C<\/code> to stop.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Traditional Compile and Run<\/h3>\n\n\n\n<p>The standard workflow still works for structured projects:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat > \/tmp\/Hello.java << 'EOF'\npublic class Hello {\n    public static void main(String[] args) {\n        System.out.println(\"Hello from \" + System.getProperty(\"java.vendor\") + \" JDK \" + System.getProperty(\"java.version\"));\n        Runtime rt = Runtime.getRuntime();\n        System.out.println(\"Available processors: \" + rt.availableProcessors());\n        System.out.println(\"Max memory: \" + (rt.maxMemory() \/ 1024 \/ 1024) + \" MB\");\n    }\n}\nEOF\njavac \/tmp\/Hello.java -d \/tmp\njava -cp \/tmp Hello<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Hello from Ubuntu JDK 25.0.2\nAvailable processors: 2\nMax memory: 980 MB<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Garbage Collector Selection<\/h2>\n\n\n\n<p>JDK 25 ships three production garbage collectors. G1 is the default and works well for most workloads. ZGC and Shenandoah target specialized scenarios.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Collector<\/th><th>JVM Flag<\/th><th>Best For<\/th><\/tr><\/thead><tbody><tr><td>G1 (default)<\/td><td><code>-XX:+UseG1GC<\/code><\/td><td>General purpose with balanced throughput and latency<\/td><\/tr><tr><td>ZGC<\/td><td><code>-XX:+UseZGC<\/code><\/td><td>Sub-millisecond pauses, large heaps up to multi-terabytes<\/td><\/tr><tr><td>Shenandoah<\/td><td><code>-XX:+UseShenandoahGC<\/code><\/td><td>Low-pause with generational mode (new in JDK 25 via JEP 521)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Check which GC is active:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java -XX:+PrintFlagsFinal -version 2>&1 | grep \"Use.*GC \" | grep true<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>     bool UseG1GC                                  = true                                      {product} {ergonomic}<\/code><\/pre>\n\n\n\n<p>Switch to ZGC for a latency-sensitive application:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java -XX:+UseZGC -jar your-app.jar<\/code><\/pre>\n\n\n\n<p>Enable GC logging to compare collectors under your workload:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java -Xlog:gc*:file=\/var\/log\/app-gc.log:time,uptime,level,tags -jar your-app.jar<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">OpenJDK vs Oracle JDK vs Temurin<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Aspect<\/th><th>OpenJDK (Ubuntu)<\/th><th>Oracle JDK<\/th><th>Temurin (Adoptium)<\/th><\/tr><\/thead><tbody><tr><td>Source<\/td><td>OpenJDK upstream<\/td><td>Same source<\/td><td>Same source<\/td><\/tr><tr><td>License<\/td><td>GPLv2 + Classpath Exception<\/td><td>Oracle NFTC (free until Sep 2028)<\/td><td>GPLv2 + Classpath Exception<\/td><\/tr><tr><td>Vendor<\/td><td>Ubuntu<\/td><td>Oracle Corporation<\/td><td>Eclipse Adoptium<\/td><\/tr><tr><td>VM<\/td><td>OpenJDK 64-Bit Server VM<\/td><td>Java HotSpot(TM) 64-Bit Server VM<\/td><td>OpenJDK 64-Bit Server VM<\/td><\/tr><tr><td>Install path<\/td><td><code>java-25-openjdk-amd64<\/code><\/td><td><code>jdk-25.0.2-oracle-x64<\/code><\/td><td><code>temurin-25-jdk-amd64<\/code><\/td><\/tr><tr><td>Updates via apt<\/td><td>Yes (Ubuntu repos)<\/td><td>No (manual .deb download)<\/td><td>Yes (Adoptium repo)<\/td><\/tr><tr><td>Ubuntu 24.04<\/td><td>Default repos<\/td><td>Manual .deb<\/td><td>Adoptium repo<\/td><\/tr><tr><td>Ubuntu 22.04<\/td><td>Universe repo<\/td><td>Manual .deb<\/td><td>Adoptium repo<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Performance is identical across all three builds since they share the same codebase. Choose based on your update and licensing preferences. OpenJDK from Ubuntu repos is the simplest. Temurin gives you an independent update channel. Oracle JDK requires manual upgrades but includes commercial support options.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Production Configuration<\/h2>\n\n\n\n<p><strong>Pin the JDK in service files.<\/strong> Use the absolute path in your systemd unit files to prevent version drift when system updates install a newer JDK:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Environment=\"JAVA_HOME=\/usr\/lib\/jvm\/java-25-openjdk-amd64\"\nExecStart=\/usr\/lib\/jvm\/java-25-openjdk-amd64\/bin\/java -jar \/opt\/myapp\/app.jar<\/code><\/pre>\n\n\n\n<p><strong>Set explicit heap limits.<\/strong> JDK 25 allocates 25% of system RAM by default. In containers, set bounds to match the container's memory limit:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java -Xms512m -Xmx2g -jar app.jar<\/code><\/pre>\n\n\n\n<p><strong>Use AOT caching for faster startup (JEP 514).<\/strong> Create a training run that captures compilation data, then reuse it for instant startup:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java -XX:AOTCacheOutput=app.aot -jar app.jar\njava -XX:AOTCache=app.aot -jar app.jar<\/code><\/pre>\n\n\n\n<p><strong>Keep the JDK updated.<\/strong> Security patches for LTS releases come quarterly (January, April, July, October). With OpenJDK from Ubuntu repos or Temurin from Adoptium, a regular <code>sudo apt upgrade<\/code> keeps you current.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Uninstall<\/h2>\n\n\n\n<p>Remove OpenJDK 25:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt remove --purge openjdk-25-jdk openjdk-25-jre<\/code><\/pre>\n\n\n\n<p>Remove Oracle JDK 25:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dpkg --purge jdk-25<\/code><\/pre>\n\n\n\n<p>Remove Temurin 25:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt remove --purge temurin-25-jdk<\/code><\/pre>\n\n\n\n<p>After removal, verify the default Java version updated correctly: <code>java -version<\/code>. If another version is installed, it becomes the new default automatically.<\/p>\n\n\n\n<p>For installing Java on other Linux distributions, see our guides for <a href=\"https:\/\/computingforgeeks.com\/install-java-jdk-debian\/\" target=\"_blank\" rel=\"noreferrer noopener\">JDK 25 on Debian 13\/12<\/a>, <a href=\"https:\/\/computingforgeeks.com\/install-java-openjdk-rocky-almalinux\/\" target=\"_blank\" rel=\"noreferrer noopener\">Java on Rocky Linux\/AlmaLinux<\/a>, or <a href=\"https:\/\/computingforgeeks.com\/install-java-rhel-rocky-almalinux\/\" target=\"_blank\" rel=\"noreferrer noopener\">Java on RHEL\/Rocky\/AlmaLinux<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>JDK 25 landed as the next long-term support release with eight years of patches ahead of it (through September 2033). Both Ubuntu 24.04 and 22.04 carry openjdk-25-jdk in their repositories, so getting the latest LTS Java on Ubuntu is a one-liner. If you need Oracle&#8217;s build or Adoptium&#8217;s Temurin instead, those are covered here too. &#8230; <a title=\"Install Java 25 (JDK 25) on Ubuntu 24.04 \/ 22.04\" class=\"read-more\" href=\"https:\/\/computingforgeeks.com\/install-java-jdk-ubuntu\/\" aria-label=\"Read more about Install Java 25 (JDK 25) on Ubuntu 24.04 \/ 22.04\">Read more<\/a><\/p>\n","protected":false},"author":21,"featured_media":164552,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[81,690,299,50],"tags":[],"class_list":["post-164551","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu","category-dev","category-how-to","category-linux-tutorials"],"_links":{"self":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/164551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/comments?post=164551"}],"version-history":[{"count":0,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/164551\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media\/164552"}],"wp:attachment":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media?parent=164551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/categories?post=164551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/tags?post=164551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}