Skip to content

Enabling Java in macOS

September 18, 2020

If you want to use a Java-based app on your Mac, you would think the path forward is obvious: Download and install Java, then run your app.

Well…no. Even now in late 2020, it’s not that easy. Oracle’s Java installer inexplicably doesn’t add the path to Java or set the JAVA_HOME environment variable, so you’ll get an error that you need to install the latest JDK, even though you just did.

So how do you fix it? Googling will yield frustration. There are lots of sites telling you how to fix it, but few of the answers actually work.

The irony is that the fix only takes 2 minutes and is easy. The problem is that it’s hidden at the bottom of the twelfth Stackoverflow discussion you’ll find. Here it is right at the top of this post so you can do it yourself quickly.

Things to know:

  1. You need to edit your ~/.bash_profile file.
  2. This file does not exist by default, even though most posts claim it does.
  3. You need to know the path to java home, and it does not include the version number.


Ok, let’s get down to it. Here are your steps:

  1. Open Terminal.
  2. Enter this command: vi ~/.bash_profile
  3. Press the “i” key to enable insertion mode.
  4. Cut & paste in this line: export JAVA_HOME="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"
  5. Press the esc key to leave insertion mode.
  6. Press Z Z to save the file and leave vi.
  7. Enter this command: source .bash_profile
  8. Enter this command to ensure the changes took effect: echo $JAVA_HOME

Your Java apps should now function. Further, because you didn’t change your path and/or use a specific Java version, you should be able to install Java updates and not lose functionality. Also, this should work across all versions of macOS.

Enjoy!

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: