Lab 1 Setup: Mac OS

A. Setup

  1. Install Homebrew, a very easy to use package manager. To install, go to your Terminal and enter the following:
     /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    

    Note: During the process, you may be prompted to enter a password. When you enter your password, nothing will display on the terminal, but the computer is actually recording your password. This is a security measure. Just type your password and hit enter.

    You may be prompted to hit enter again to start the installation after entering your password.

  2. Then, check to make sure brew is working properly on your system by typing:
     brew doctor
    

    You may encounter warnings like this, but you should be fine. Proceed to the next step.

    Homebrew Warnings

  3. If you encounter a warning asking you to download Command Line Tools, you will need to do this. Please follow the StackOverflow post here.

  4. Install the Java JDK and git. You can do this by typing:
     brew install --cask java
     brew install git
    

    If you’re getting an error for the Java install, try simply:

     brew install java
    
  5. Verify your git installation by typing:
     git --version
    

    You have successfully installed git if this command returns a valid version number and does not fail.

    Similarly, you can verify your Java installation by typing:

     java -version
     javac -version
    

    Both of these commands should succeed and show version 15. If both installations are good, woohoo! Skip the rest of this guide and return to the lab.

B. Java Install Issues

If you are still having Java install issues with Homebrew after having retried the steps and/or conferring with your TA, it might be time for a manual install. To install Java manually, follow the steps below. If at any point, you believe one of the steps you have done did not work, please get in touch with your TA before proceeding.

  1. Download jdk-15.0.1_osx-x64_bin.dmg from this link and run the installer with the default options
  2. Verify that the download succeeded by typing:
     ls /Library/Java/JavaVirtualMachines
    

    Your output should include JDK 15 (jdk-15.0.1.jdk)

  3. The Java installation should have included a script that outputs the file location of the most recent JDK installed. Run the following command:
     /usr/libexec/java_home
    

    The output you get should look similar to the following, which is the output on my personal computer. In particular, you should see JDK 15 in the output:

     /Library/Java/JavaVirtualMachines/jdk-15.0.1.jdk/Contents/Home
    
  4. Now, all that remains to do is tell the system where our install folder is. First, run echo $0 to determine if you are running zsh or bash. The next command you have to run will be slightly different depending on whether you are running zsh or bash.

    If you are running zsh, type the following command:

     echo 'export JAVA_HOME=$(/usr/libexec/java_home)' >> ~/.zprofile
    

    If you are running bash, type the following command:

     echo 'export JAVA_HOME=$(/usr/libexec/java_home)' >> ~/.bash_profile
    
  5. This step is important. Completely close out of your terminal window, by typing Cmd + Q. If you have worked with this type of stuff before, you may be tempted to source your zprofile or bash_profile. Do NOT be tempted; simply close out of your terminal with Cmd + Q.

  6. Restart your terminal, and verify that your environment variables have been setup correctly by running:
     echo $JAVA_HOME
    

    The output of this command should be non-empty and include the path to your JDK 15 installation

  7. Java should properly be installed! As mentioned above, you can test this with the commands:
     java -version
     javac -version
    

C. Git Install Issues

If you had installation issues with Git using Homebrew, try the instructions “Installing on macOS” at this link. Contact your TA if you are still having issues.