Table of contents
check if java is arm64
cat `which java` | file -
output
/dev/stdin: Mach-O 64-bit executable arm64
- or
/dev/stdin: Mach-O 64-bit executable x86_64
On Mac OS X 10.5 or later, we can use:
to return the location of the default JDK :
/usr/libexec/java_home
to return the location of the default JDK :
/Library/Java/JavaVirtualMachines/jdk-16.jdk/Contents/Home
find all installed JDKs.
/usr/libexec/java_home -V
Matching Java Virtual Machines (4):
16 (x86_64) "Oracle Corporation" - "OpenJDK 16-ea" /Library/Java/JavaVirtualMachines/jdk-16.jdk/Contents/Home
15.0.1 (x86_64) "UNDEFINED" - "OpenJDK 15.0.1" /usr/local/Cellar/openjdk/15.0.1/libexec/openjdk.jdk/Contents/Home
14.0.2 (x86_64) "AdoptOpenJDK" - "AdoptOpenJDK 14" /Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home
1.8.0_275 (x86_64) "UNDEFINED" - "OpenJDK 8" /usr/local/Cellar/openjdk@8/1.8.0+275/libexec/openjdk.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk-16.jdk/Contents/Home
run a specified JDK command.
/usr/libexec/java_home -v1.8
/usr/local/Cellar/openjdk@8/1.8.0+275/libexec/openjdk.jdk/Contents/Home
set the JAVA_HOME environment variable
- On macOS 10.15 Catalina and later, the zsh is the default Terminal shell, and we can in either
~/.zshenv
or~/.zshrc
- Confirm you have JDK by typing
which java
output ->
/usr/bin/java
- Check you have the needed version of Java, by typing
java -version
JAVA_HOME
is essentially the full path of the directory that contains a sub-directory namedbin
which in turn contains the java.
For Mac OSX it is/Library/Java/Home
- Set JAVA_HOME
` export JAVA_HOME=/Library/Java/Home` echo $JAVA_HOME
on Terminal to confirm the path
- Note that this sets JAVA_HOME only for this session. If you want it to persist, you will have to add the command to your
~/.profile file
vim .profile
- add this to the end of the .profile file:
JAVA_HOME=/Library/Java/Home
export JAVA_HOME;
nano ~/.zshenv
- Add the following content
export JAVA_HOME=$(/usr/libexec/java_home)
- Source the file and print the $JAVA_HOME
source ~/.zshenv
echo $JAVA_HOME
output ->/Library/Java/JavaVirtualMachines/jdk-16.jdk/Contents/Home
Slow Java app
you need to find the hostname of your Mac.
You do this from System Preferences.
Click the Sharing icon in System Preferences.You will see a box that shows the Computer Name, under that will be the hostname ending in
.local
That’s what you will need, so take note of it.
In my case it wasEnzyme.local
The next step is to update your
/etc/hosts
file. This must be done as root, so at the Terminal, type insudo vi /etc/hosts
This will ask for your password…
Add the hostname you noted from earlier at the end of lines that start with127.0.0.1
and::1
.In the end this is what my
/etc/hosts
file looked like:127.0.0.1 TPLNK-BPAXTON3.local 255.255.255.255 broadcasthost ::1 TPLNK-BPAXTON3.local`