MAC Java Environment Variable

2:18 am Mac OS

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:

[html]
/System/Library/Frameworks/JavaVM.framework/Home

To set the environment variable is:

[html]
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:
    [html]
    <?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:

One Response
  1. Alex :

    Date: May 19, 2010 @ 10:14 am

    Thanks for this post, it was really helpful.

Leave a Comment

Your comment

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

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.