Setting Up Environment Variables in Mac OS and Linux
In IntelliJ, open the GetEnvironmentVariables
class. The first few lines should look like:
// Fill in the path to your fa20-s*** folder between the quotes
public static String REPO_DIR = "";
// Fill in the path to your snaps-fa20-s*** folder between the quotes
public static String SNAPS_DIR = "";
REPO_DIR
In your terminal, navigate to your fa20-s***
folder. For example, if your repo number is 123, and you put it on your desktop, you would type:
cd ~/Desktop/fa20-s123/
Now enter pwd
. This command outputs the “present working directory” (so, it tells you where you are in your machine). Copy the output, and paste it in your getEnvironmentVariables
between the empty quotes here REPO_DIR = "";
. For the example above, pwd
will output something like:
Users/<your name>/Desktop/fa20-123
And when pasted in GetEnvironmentVariables
:
public static String REPO_DIR = "Users/<your name>/Desktop/fa20-123";
SNAPS_DIR
In your terminal, navigate to your snaps-fa20-s***
folder. For example, if your repo number is 123, and you followed the instructions from the spec, you would type:
cd ~/snaps-fa20-s123/
Now enter pwd
. Copy the output, and paste it in your getEnvironmentVariables
between the empty quotes here SNAPS_DIR = "";
. For the example above, pwd
will output something like:
Users/<your name>/snaps-fa20-123
And when pasted in GetEnvironmentVariables
:
public static String SNAPS_DIR = "Users/<your name>/snaps-fa20-123";
Wrapping Up
UPDATE 09/02, 4:00 PM: If you got the skeleton code for the lab before this time, please run git pull skeleton master
in your lab2setup
directory again.
Great job! Now it’s time to introduce these environment variables to your machine.
Run the code in GetEnvironmentVariables
. You can do so, by clicking the little play button near line 9, and then choosing Run 'GetEnvironmentVariables.main()''
.
For the examples above, you would get an output that looks like:
Keep reading the spec to know what to do with this output
----------------------------------------------------------
echo 'export REPO_DIR=Users/<your name>/Desktop/fa20-123' >> ~/.bash_profile
echo 'export SNAPS_DIR=Users/<your name>/snaps-fa20-123' >> ~/.bash_profile
source ~/.bash_profile
bash_profile
may be replaced by some other file name, depending on your operating system and its version.
Copy and paste these lines in your terminal one by one. After you paste each line, hit enter. There should be no output. When you are done, close your terminal, and open it again.
Launching IntelliJ from the Terminal
In intelliJ, go to the top bar menu and choose “Tools” → “Create Command-Line Launcher…”.
In the pop-up window, click “OK”. You should now be able to launch intelliJ from your terminal. Open a new terminal window and run
idea
Verify that intelliJ launches.
You may now return back to the lab 2 setup page.