«

»

Feb
05

MAC Java Environment Variable

I was trying to set up Fedora Object Repository for my assignment which need some environment variable to be set especially Java. I posted blog on how to choose Java VM in Ubuntu. Location of Java in Mac OS is different from linux or ubuntu.

Java home path in Mac is:

/System/Library/Frameworks/JavaVM.framework/Home

To set the environment variable is:

export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home

Bear in mind that issuing ‘export’ command from the terminal is only meant for that terminal only. The environment variable is not being set globally. So in order to define the environment variable so whole Mac application is able to see them.

  1. Create a folder in the user root directory called .MacOSX
  2. Create a file called environment.plist in the directory, so when you issue pwd command you will see /Users/lindaoctalina/.MacOSX/environment.plist
  3. In environment.plist, create an xml document with the following format:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>SOME_OTHER_ENV</key>
        <string>/full/path/use/semicolon/to/separate:/if/you/have/more/than/one/path:</string>
        <key>JAVA_HOME</key>
        <string>/System/Library/Frameworks/JavaVM.framework/Home:</string>
    </dict>
    </plist>

    Note: you must use full path instead of ~ for home directory

  4. Log out and log back in whenever you modify environment.plist to see the changes

Useful Link:

Permanent link to this article: http://lindaocta.com/?p=38

1 comment

  1. Alex says:

    Thanks for this post, it was really helpful.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>