java -XX:ActiveProcessorCount=2 -jar myapp.jar For large heaps (>8GB), tell the JVM to use Linux's THP:
Java 17 is a Long-Term Support (LTS) release, meaning it will receive security updates and performance patches for years to come. For Linux users, running Java 17 efficiently isn't just about typing apt install ; it’s about choosing the right distribution (OpenJDK vs. Oracle), managing environment variables, and tuning the JVM for the Linux kernel. java 17 linux
[Install] WantedBy=multi-user.target
For the most up-to-date builds:
wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo apt-key add - echo "deb https://packages.adoptium.net/artifactory/deb $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/adoptium.list sudo apt update sudo apt install temurin-17-jdk # Fedora / RHEL 9+ with dnf sudo dnf install java-17-openjdk-devel Older RHEL/CentOS 7 with yum sudo yum install java-17-openjdk-devel Amazon Linux 2023 (Corretto) sudo dnf install java-17-amazon-corretto-devel Arch Linux (pacman) sudo pacman -S jdk17-openjdk # Manage multiple Java versions sudo archlinux-java set java-17-openjdk Alpine Linux (For Containers) FROM alpine:3.19 RUN apk add openjdk17 --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community Step 3: Managing Multiple Java Versions (The Linux Way) Most Linux servers run multiple JVMs. Use update-alternatives (Debian/Ubuntu) or manual symlinks (RHEL). java -XX:ActiveProcessorCount=2 -jar myapp
| Distribution | Best For | Package Manager Availability | | :--- | :--- | :--- | | | General purpose, cloud-native, CI/CD | apt , yum , dnf (via Adoptium repo) | | Oracle OpenJDK | Oracle Linux & strict Oracle support contracts | yum (Oracle Linux) | | Amazon Corretto 17 | AWS environments, long-term free patches | yum , apt , dnf | | Azul Zulu 17 | Legacy hardware or embedded Linux | apt , yum , tgz | Recommendation: For 95% of users, use Eclipse Adoptium (Temurin) or Amazon Corretto . Both offer free, long-term support without licensing headaches. Step 2: Installing Java 17 on Major Linux Distributions Ubuntu / Debian (apt) # Update package list sudo apt update Install the default Java 17 JDK (OpenJDK) sudo apt install openjdk-17-jdk -y Verify installation java -version [Install] WantedBy=multi-user