While I have some experience in Python and JavaScript, I am new to Java and am trying it out for the first time. To get started, I went to http://www.java.com, downloaded the dmg there, and then used the package it gave me to install Java. After doing so, I received confirmation that Java had been installed successfully and I closed and trashed the dmg and package. Afterwards, I hopped on my terminal (I am using a Mac running on MacOS Monterey) and tried to use javac
on a script I wrote. I received the following error message:
The operation couldn’t be completed. Unable to locate a Java Runtime that supports javac.
Please visit http://www.java.com for information on installing Java.
I went online and did some typical troubleshooting searches. First, I found a site suggesting that I create an environment variable $JAVA_HOME
and set it equal to $(/usr/libexec/java_home)
in .zshenv
(yes, I use zsh not bash). I followed this instruction and when I run echo $JAVA_HOME
I get /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
. However, running javac
still did not work.
Once more, I went online and this time, I found the suggestion of adding javac
to $PATH
. So I went into .zshenv
and added usr/bin/javac
to $PATH
(the $PATH
export line now looks like this: export PATH="/Users/[redacted]/Library/Python/3.8/bin:/usr/bin/javac:$PATH"
). This alteration was confirmed when I exited an reentered terminal and ran echo $PATH
. However, once again, running javac
yielded the same error.
I feel as if I am facing what must be a pretty common and easily fixable issue, but yet, I haven't yet been able to find a solution that works despite perusal of several other StackOverflow posts and tech articles. Still, I know I'm probably missing something simple, and if this is a duplicate of another question, please link that question in a comment, and I'll take this one down.
Thanks!
enjoy tap-dancing on the bleeding edgeneed them. – Stephen C Jan 03 '23 at 02:45