Javac not found

I’ve followed instructions for installing the openJDK into Fedora from https://docs.fedoraproject.org/en-US/quick-docs/installing-java/ using the command

sudo dnf install java-latest-openjdk

After doing so the javac command is not in the path. I then ran the command to select java11.

sudo alternatives --config java

But the path still does not contain javac. I also closed and reopened the terminal to see if the path would update to no avail. Is there a document describing how to install and select the javac command? The command “java -version” does return version 11. However commands “javac -version” and “which javac” return command not found.

I did find javac in /usr/share/bash-completions/completions/javac by changing to the root directory and using the command:

sudo . -name javac -print

I’m assuming I need to add alternatives for javac?

1 Like

Hi @ksanger . Welcome to the community. Please take a minute to go through the posts in the #start-here category if you have not had a chance to do yet.

So.
javac is the Java compiler, right?
Maybe it is not included in the java-latest-openjdk package, because it is a development tool.
Indeed if you install java-latest-openjdk-devel, you can find javac.

In addition, are you sure that installing java-latest-openjdk it install openjdk version 11?

3 Likes

Thanks; I had assumed that openjdk was a java developement kit ie java development kit. I’ll install java-latest-openjdk-devel next. I would have named openjdk openjre. Then the name would mean it was a java runtime environment and not a java development kit. Which it is. Must be missing something as openjdk without a javac command makes no sense to me.

1 Like

openJDK is simply the name of the upstream project, and so that is what all the related packages in Fedora are named.

http://openjdk.java.net/


The -devel package you were going to install next includes any bits that are required for development.

Fedora packages must be designed with a logical separation of files. Specifically, -devel packages must be used to contain files which are intended solely for development or needed only at build-time. This is done to minimize the install footprint for users.

openjdk follows the same scheme

2 Likes

As of 6/13/2019 latest installed version 12. Two days ago latest installed 11. I had to specify version 11 to get what we needed using:

sudo dnf install java-11-openjdk-devel

Then used alternatives --config to select the javac that we wanted to use.

sudo alternatives --config javac

And verify by invoking the compiler with the -version switch.

javac -version

Thanks everyone for all your help.

1 Like

I guess many people will run into this snag, including myself on Fedora32 btw.

javac 11.0.6
fyi that is

I found this thread while Googling about this problem, ran into same issue today

IMO the description text when you do “dnf search openjdk” should include “Does not include javac” if there’s no compiler

Yes. In over 20 years I cannot remember ever seeing an implementation of JDK (which does indeed stand for Java Development Kit) that did not have a compiler.

Based on this and several other threads, it seems like there must be a well-known secret around the unspoken argument: “There should always be basic developer tools in the Java (D)evelopment Kit” versus “There should always be a -devel in the package name of a development package.”

And those of us who used it many other places just have not been let in on it…