# My macOS Cheat Sheet

## How to set JAVA_HOME on macOS Monterey?
1. First check which shell you are using (either bash or zsh).
For ```zsh``` shell, we can put the environment variables at ```~/.zshenv``` or ```~/.zshrc```.
```bash
echo $SHELL
/bin/zsh
```
2. On Mac OS X 10.5 or later, we can use ```/usr/libexec/java_home``` to return the location of the default JDK.
```bash
/usr/libexec/java_home
/Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/Home
```

2. Or list all installed java versions with `-V`
```bash
% /usr/libexec/java_home -V
Matching Java Virtual Machines (3):
    17.0.9 (x86_64) "Oracle Corporation" - "Java SE 17.0.9" /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
    17.0.9 (x86_64) "Oracle Corporation" - "Oracle GraalVM 17.0.9+11.1" /Library/Java/JavaVirtualMachines/graalvm-jdk-17.0.9+11.1/Contents/Home
    11.0.13 (x86_64) "Amazon.com Inc." - "Amazon Corretto 11" /Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/Home
```

3. Open the ```~/.zshenv```
```bash
nano ~/.zshenv
```
4. Add the following content
```bash
export JAVA_HOME=$(/usr/libexec/java_home)
```
5. Source the file and print the $JAVA_HOME, done.
```bash
source ~/.zshenv
echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/Home
```

## Install node on macOS
Download the package at the official [Node Website](https://nodejs.org/en/download). The installation paths are as follows:<br>
**Node.js**
```bash
/usr/local/bin/node
```
**npm**
```bash
/usr/local/bin/npm
```
Make sure that `/usr/local/bin` is in your **$PATH**.

