mirror of https://github.com/jenv/jenv.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.0 KiB
34 lines
1.0 KiB
#!/usr/bin/env bash |
|
# |
|
# Summary: Configures JAVA_HOME for GUI applications. |
|
# |
|
# Usage: jenv macos-javahome |
|
# |
|
# Installs a file located at ~/Library/LaunchAgents/jenv-environment.plist . It sets JAVA_HOME for GUI |
|
# applications on startup for the **currently active version of Java**. |
|
# |
|
# This **must be updated** whenever the version of Java changes. It does not update dynamically. |
|
# |
|
# |
|
cat << EOT > ${HOME}/Library/LaunchAgents/jenv-environment.plist |
|
<?xml version="1.0" encoding="UTF-8"?> |
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
|
<plist version="1.0"> |
|
<dict> |
|
<key>Label</key> |
|
<string>my.startup</string> |
|
<key>ProgramArguments</key> |
|
<array> |
|
<string>sh</string> |
|
<string>-c</string> |
|
<string> |
|
launchctl setenv JAVA_HOME $(jenv javahome) ; |
|
</string> |
|
</array> |
|
<key>RunAtLoad</key> |
|
<true/> |
|
</dict> |
|
</plist> |
|
EOT |
|
launchctl unload ${HOME}/Library/LaunchAgents/jenv-environment.plist || true |
|
launchctl load ${HOME}/Library/LaunchAgents/jenv-environment.plist
|
|
|