When I try to compile a java program with javac
, I get an error:
The program \'javac\' can be found in the following packages:
* default-jdk
* ecj
In my case, I had the JDK installed, but I'd installed it manually so it wasn't added to the path. Once I added these lines to my .zshrc file (I'm using zsh; if you're using bash, add them to .bash_profile) and relaunched the terminal, it worked:
# Java environment variables
export JAVA_HOME='/opt/jdk/jdk1.8.0_241' #change accordingly; this needs to match your JDK's location!
export PATH=$PATH:$JAVA_HOME/bin