The javac executable is not part of the openjdk-*-jdk packages. To install it, you need to install the openjdk-17-jdk-headless package:
sudo apt install openjdk-17-jdk-headless
To manage the active version, don't forget about the update-alternatives command:
sudo update-alternatives --config java
sudo update-alternatives --config javac
Answer from DynamicBits on askubuntu.comNeed help with installing java17
Ubuntu Java 17 openjdk java docs don't appear in IntelliJ - Stack Overflow
ubuntu - Where is 'javac' in java-17-openjdk-amd64? - Stack Overflow
Getting Java error trying to run Server 1.17 on Ubuntu 20.04
-
Looking for instant support instead? Have a urgent question or just want to talk to the community without waiting? Join the r/minecraftserver Official Discord server https://discord.gg/bcbUzMYbsh
-
Get our most popular Ryzen 3000 and 5000 powered Minecraft Hosting plan packed with 8GB of RAM for only $15 a month! Find out more at https://mcserverhosting.net/
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
More on reddit.comVideos
For the last two days I've been cracking my head on attempting to install java17 on my ubuntu20.10 machine.
I need java17 to run the latest version of a minecraft server. The problem I'm encountering is the following:
I can add the ppa:linuxuprising/java repository succesfully. (this is the most common method of installing this version of java). The sudo apt update command succeeds as well.
However when I try to install java17 through this repository it keeps stating that the package can't be found, which is strange because in the web viewer of the same repository the packages are there.
I'm not very well versed in the linuxverse so any help would be welcome.
Finally I managed to install sources using
$ sudo apt install openjdk-17-doc openjdk-17-source
Then add them manually into intellij in
Project Structure/Platform settings/SDKs
from /usr/lib/jvm/openjdk-17/src.zip

Figured this out, thanks Ubuntu devs I guess for shipping stripped version of JDK by default, I keep telling that for workstation distros this fashion of headless just results in wasted time - include completely or don't include at all, it would be faster for myself to install adoptopenjdk correctly myself from scratch. Docker images or anything that goes on a server or in a cloud can be stripped - fine but not on Linux user distros, PLEASE
Solution:
Uninstall whatever openjdk-17 was installed including JRE and use the one with sources:
:~$ sudo apt install openjdk-17-source
instead of:
:~$ sudo apt install openjdk-17-jdk
as I've done at the question sample originally.
After this IntelliJ populates "Sourcepath" similarly as it does for internal Corretto and JavaDoc works.
RHEL/RockyLinux/CentOs/AlmaLinux etc: javac is in "devel" package
dnf -y install java-17-openjdk
dnf -y install java-17-openjdk-devel
Then set default versions
alternatives --config java
alternatives --config javac
I'm unsure which directions I used to install Open JDK before, but I followed the following instructions to remove and re-install: https://www.linuxcapable.com/how-to-install-openjdk-17-on-ubuntu-20-04/
I now have 'javac' in java-17-openjdk-amd64/bin.
Whew.