How to Download Java JDK on Linux Using wget - Bypass License
Learn how to download Java JDK on Linux using wget by bypassing Oracle's license page. Step-by-step methods with cookie headers and installation guide.
How can I download Java JDK on Linux using wget when encountering the Oracle OTN license page instead of the actual download? What are the proper methods to bypass the license agreement page and successfully install Java on Linux systems?
When you try to download Java JDK on Linux using wget, you’ll often hit Oracle’s license agreement page instead of getting the actual file. This happens because Oracle requires users to accept their OTN (Oracle Technology Network) license terms before downloading—and wget doesn’t handle this cookie-based verification automatically. The solution involves sending the acceptance cookie with your request, either through explicit HTTP headers or by using Oracle’s simplified oraclelicense=a parameter in your download URL.
Contents
- Why Oracle’s License Page Blocks wget Downloads
- Method 1: Using wget with Cookie Headers
- Method 2: Simplified oraclelicense Parameter Approach
- Method 3: Browser Cookie Export for Complex Cases
- Installing the Downloaded JDK on Linux
- Sources
- Conclusion
Why Oracle’s License Page Blocks wget Downloads
Here’s what’s happening under the hood. When you click “Accept License Agreement” on Oracle’s download page, the site sets a cookie in your browser that proves you’ve agreed to the terms. Every subsequent download request includes this cookie, and Oracle’s servers check for it before serving the file.
wget, by default, doesn’t send any cookies. So when you paste that download URL into your terminal, Oracle’s servers see an unauthenticated request and redirect you to the license page instead of the JDK file.
This affects all Oracle JDK downloads—whether you’re grabbing Java JDK 8, Java 11, Java 17, or newer versions. The mechanism is consistent across versions, though the exact cookie format has evolved over time.
The Cookie Mechanism Explained
Oracle uses two main approaches for license verification:
- Cookie-based: The server sets a cookie like
oraclelicense=accept-securebackup-cookiewhen you accept the license - Parameter-based: Some download URLs accept an
oraclelicense=aparameter that bypasses the cookie check
Both methods achieve the same result—telling Oracle’s servers you’ve accepted the license terms. Which one you use depends on your preference and the specific JDK version you’re downloading.
Method 1: Using wget with Cookie Headers
The most reliable approach for Oracle JDK download on Linux is sending the license acceptance cookie explicitly via HTTP headers. This method works across most JDK versions and closely mimics what your browser does.
Basic wget Command with Cookie Header
wget --no-cookies --no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
https://download.oracle.com/otn-pub/java/jdk/8u411-b09/4d541714bea249b96116b4c9d953b9f0/jdk-8u411-linux-x64.tar.gz
Let’s break down what each parameter does:
| Parameter | Purpose |
|---|---|
--no-cookies |
Prevents wget from using any existing cookie files, ensuring a clean request |
--no-check-certificate |
Skips SSL certificate verification (useful for Oracle’s sometimes-problematic certs) |
--header "Cookie: ..." |
Adds the license acceptance cookie to the HTTP request |
Version-Specific Examples
For Java JDK 11 download:
wget --no-cookies --no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
https://download.oracle.com/otn-pub/java/jdk/11.0.23+9/7cf6a99d2b024b3b9a2ef1a0c6e1e0e8/jdk-11.0.23_linux-x64_bin.tar.gz
For Java JDK 17 download:
wget --no-cookies --no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
https://download.oracle.com/otn-pub/java/jdk/17.0.11+9/3b1d0c6d24d44cc6baa3e1be0e1f9a0a/jdk-17.0.11_linux-x64_bin.tar.gz
Using curl as an Alternative
If you prefer curl over wget, the same approach works:
curl -L -b "oraclelicense=accept-securebackup-cookie" \
-o jdk-8u411-linux-x64.tar.gz \
https://download.oracle.com/otn-pub/java/jdk/8u411-b09/4d541714bea249b96116b4c9d953b9f0/jdk-8u411-linux-x64.tar.gz
The -L flag follows redirects, -b sets the cookie, and -o specifies the output filename.
Method 2: Simplified oraclelicense Parameter Approach
There’s a cleaner method that doesn’t require manually setting cookie headers. Oracle’s CDN accepts an oraclelicense=a parameter in the URL, which automatically handles the license acceptance.
How This Works
According to the community-documented approaches, you can append the parameter directly to the download URL:
wget -c --header "Cookie: oraclelicense=a" \
https://download.oracle.com/otn-pub/java/jdk/8u411-b09/4d541714bea249b96116b4c9d953b9f0/jdk-8u411-linux-x64.tar.gz
Or even simpler for some versions:
wget --no-check-certificate \
"https://download.oracle.com/otn-pub/java/jdk/8u411-b09/4d541714bea249b96116b4c9d953b9f0/jdk-8u411-linux-x64.tar.gz?AuthParam=1709123456_abcdef1234567890abcdef"
Important Limitations
This simplified approach has some caveats:
- URL expiration: Some generated URLs expire after a certain time
- Version-specific behavior: Not all JDK versions respond consistently to the parameter method
- Auth tokens: Newer downloads may require authentication tokens that change periodically
For production scripts or automated deployments, the explicit cookie header method (Method 1) tends to be more reliable across different versions and time periods.
Method 3: Browser Cookie Export for Complex Cases
Sometimes the standard methods don’t work—especially for newer JDK versions or when Oracle changes their verification system. In these cases, you can export cookies from your browser and use them with wget.
Step-by-Step Process
Step 1: Accept the license in your browser and start the download, then cancel it.
Step 2: Export the cookies. For Firefox, you can use a cookie export extension. For Chrome, use the built-in developer tools:
- Press
F12to open Developer Tools - Go to the “Application” tab → “Cookies” → select Oracle’s domain
- Find the license-related cookies and note their values
Step 3: Create a cookies.txt file in Netscape format:
.download.oracle.com TRUE / FALSE 0 oraclelicense accept-securebackup-cookie
Step 4: Use wget with the cookie file:
wget --load-cookies=cookies.txt \ https://download.oracle.com/otn-pub/java/jdk/[version]/jdk-[version]-linux-x64.tar.gz
When to Use This Method
This approach is most useful when:
- Standard methods fail for newer JDK releases
- Oracle has changed their cookie mechanism
- You need authenticated downloads (Oracle account required)
- You’re downloading from behind a corporate proxy that modifies requests
The AskUbuntu community discussion provides additional troubleshooting tips for edge cases.
Installing the Downloaded JDK on Linux
Once you’ve successfully completed your Java JDK download on Linux, you need to install it. The installation process depends on whether you downloaded a .tar.gz archive or an .rpm package.
For .tar.gz Archives (Most Distributions)
# Extract the archive
tar -xzf jdk-8u411-linux-x64.tar.gz
# Move to a standard location
sudo mv jdk1.8.0_411 /usr/local/java/
# Set up environment variables
echo 'export JAVA_HOME=/usr/local/java/jdk1.8.0_411' >> ~/.bashrc
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
For .rpm Packages (RHEL, CentOS, Fedora)
# Install the RPM package
sudo rpm -ivh jdk-8u411-linux-x64.rpm
# Or upgrade if a previous version exists
sudo rpm -Uvh jdk-8u411-linux-x64.rpm
Verify Your Installation
java -version
Expected output for Java 8:
java version "1.8.0_411"
Java(TM) SE Runtime Environment (build 1.8.0_411-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.411-b09, mixed mode)
Using alternatives for Multiple Java Versions
On systems with multiple Java installations, use alternatives to manage the default version:
sudo alternatives --config java
This presents a menu where you can select which installed JDK should be the system default. The official Oracle installation guide provides distribution-specific details for more complex setups.
Sources
- Oracle JDK Download via wget — Community-documented wget methods with cookie parameters: https://gist.github.com/hgomez/4697585
- AskUbuntu: Bypassing Oracle License Page — Detailed discussion of license bypass techniques: https://askubuntu.com/questions/170957/how-do-i-bypass-the-license-page-to-download-oracle-sun-java-on-a-server-with-wg
- Learn IT University: Java JDK wget Guide — Technical explanation of Oracle’s license mechanism: https://learn-it-university.com/how-to-download-java-jdk-on-linux-using-wget-while-bypassing-the-license-page/
- Oracle JDK 8 Linux Installation Guide — Official installation instructions for Linux systems: https://docs.oracle.com/javase/8/docs/technotes/guides/install/linux_jdk.html
Conclusion
Downloading Java JDK on Linux when facing Oracle’s license page boils down to sending the right cookie with your wget request. The most reliable approach is Method 1—using explicit cookie headers with --header "Cookie: oraclelicense=accept-securebackup-cookie". This works consistently across JDK versions from Java 8 through Java 17 and beyond.
For simpler one-off downloads, the parameter-based method (Method 2) can save typing. And when standard methods fail, exporting cookies from your browser (Method 3) provides a fallback that handles edge cases and newer releases.
Remember to verify your URLs before scripting—they sometimes change between releases, and auth tokens may expire. Once downloaded, installation is straightforward whether you’re using .tar.gz archives or .rpm packages on your Linux system.