A step-by-step guide on how to access and edit the bash profile on a Mac.

Project goal

Learn how to edit a bash profile and document the process as a tutorial, as tutorials on this topic do not appear to be very plentiful.

Steps 1 to 2 relate to identifying the available Java versions. Updating the bash profile starts at step 3.

Lessons learnt

  • How to access and edit a bash profile
  • How to update the default path for Java

Step 1: Identify Current Default Java Version

java -version

Step 2: Identify All Available Versions of Java

/usr/libexec/java_home -V

Step 3: Access Bash Profile

touch .bash_profile
open -a TextEdit.app .bash_profile

The above will open the bash profile with the Mac TextEdit app.

Step 4: Editing Bash Profile

In the opened text document, add the required export path for Java as follows.

export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_05`

Step 5: Confirm the Updates

java -version

The above should return the version of Java from the newly assigned Java home path.