MacOSXEnvForApp

Revision as of 13:15, 5 November 2009 by Admin (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)

How to define environment variables so that Mac OS X applications can see them.

Installed Mac OS X applications do not see unix environment variables defined in ~/.cshrc or any other of the standard unix configuration files. But installed NetBeans on Mac OS X may use of environment variables. To get them visible, you should define your environment variables in the file ~/.MacOSX/environment.plist. You will almost certainly have to create the directory and the file yourself. The format is as per this example:

<?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>SCALA_HOME</key>
	<string>full/path/of/your/scala/home</string>
	<key>PATH</key>
	<string>/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/full/path/of/your/scala/home/bin</string>
</dict>
</plist>

Warnings:

  • Whenever you modify environment.plist, you must log out and then log back in again to see the changes.
  • Use absolute paths and spell them out. The home directory shortcut ~ is not expanded.
  • Be careful if you define an environment variable both in environment.plist and in .cshrc (or any other config file that is read when Terminal starts up). The definition in .cshrc will override (i.e. supersede, shadow, replace) the definition in environment.plist when using the Terminal. This often bites people defining PATH.
  • It may be necessary for the file to have unix line endings. I haven't tried anything else.

Notes:

If you have Apple's developer tools installed then you can create and edit this file using /Developer/Applications/PropertyListEditor.app. For the official word on this file, see Apple's Technical Q&A QA1067.

There is a good thread with some additional information on setting up Java on Mac OS at http://lists.apple.com/archives/java-dev/2008/Aug/msg00176.html
\



\ For more documentation about using NetBeans on Mac OS X, see NetBeansMacOSX

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo