Java is a widely used object-oriented programming language and software platform that runs on billions of devices, including notebook computers, mobile devices, gaming consoles, medical devices and many others. The rules and syntax of Java are based on the C and C++ languages.
For Install Java via brew, we need to install brew, Run the below commands
- xcode-select –install
- /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”
Now you can check brew on your system
brew
For Java install
brew update
brew tap homebrew/cask-versions
brew install java11
java –version
echo ‘export PATH=”/usr/local/opt/openjdk@11/bin:$PATH”‘ >> ~/.zshrc
java –v
output->
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
If below issue occur then add symlink it:
sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk \
/Library/Java/JavaVirtualMachines/openjdk.jdk