Monday, 12 August 2024

java 17 install

 Since your Podman container does not have internet access, you'll need to download Java 17 on your host machine and manually copy it into the container. Here’s how you can do it:

Step 1: Download Java 17 on Your Local Machine

  1. Go to the official OpenJDK site:
    https://jdk.java.net/17/
    OR Download from Oracle (requires login):
    https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html

  2. Choose the Linux x64 .tar.gz version.

  3. Transfer the file to your air-gapped Linux machine using scp or a USB drive.


Step 2: Copy Java 17 to Your Podman Container

  1. Create a directory on your host to store Java:

    bash
    mkdir -p /opt/java
    mv jdk-17_linux-x64_bin.tar.gz /opt/java/
    1. Find the container ID or name:

      bash
      podman ps
    2. Copy the file into the container:

      bash
      podman cp /opt/java/jdk-17_linux-x64_bin.tar.gz <container_id>:/opt/

    Step 3: Install Java 17 in the Container

    1. Access the container shell:

      bash
      podman exec -it <container_id> /bin/bash
    2. Extract Java inside the container:

      bash
      cd /opt tar -xvzf jdk-17_linux-x64_bin.tar.gz mv jdk-17 /opt/java17
    3. Set Java 17 as the default version:

      bash
      export JAVA_HOME=/opt/java17 export PATH=$JAVA_HOME/bin:$PATH
      1. Verify Java Version:

        bash
        java -version

      Step 4: Make Java 17 Permanent

      Modify the container’s profile file (/etc/profile or /root/.bashrc):

      bash
      echo "export JAVA_HOME=/opt/java17" >> /etc/profile echo "export PATH=\$JAVA_HOME/bin:\$PATH" >> /etc/profile

      Apply the changes:

      bash
      source /etc/profile

      Now, Java 17 is installed and configured inside your Podman container! 🚀


No comments:

Post a Comment