diff --git a/README.md b/README.md index 9c7c019..978cecc 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,14 @@ jvm local 7 On OSX, `jvm` will use the `java_home` tool to find the available versions. For Ubuntu, right now `jvm` has `/usr/lib/jvm/java-${version}-oracle/` hard coded. -This might change soon. +This might change soon. If you need custom versions, like `6-openjdk`, for +example, you can run `jvm config` and add a line like this: + +``` +6-openjdk=/path/to/openjdk/6 +``` + +And `jvm` will automagically works. ### `jvm` commands @@ -46,6 +53,8 @@ Right now, `jvm` has the following commands: version; - `global VERSION`: creates a `.java-version` in your `$HOME` dir with the given version; +- `jvm config`: opens the `~/.jvmconfig` file in your default `$EDITOR`. Useful +for defining custom version and/or paths; - `version`: shows current version; - `help`: shows the help. diff --git a/jvm.sh b/jvm.sh index 39a1497..d2dbcb6 100755 --- a/jvm.sh +++ b/jvm.sh @@ -2,7 +2,9 @@ _jvm_set-java-path() { local version="$1" local previous_java_home="$JAVA_HOME" - if [ -d "/usr/lib/jvm/java-${version}-oracle/" ]; then + if [ -f ~/.jvmconfig ]; then + local new_java_home="$(grep "${version}"= ~/.jvmconfig | cut -f2 -d'=')" + elif [ -d "/usr/lib/jvm/java-${version}-oracle/" ]; then local new_java_home="/usr/lib/jvm/java-${version}-oracle/" elif [ -e /usr/libexec/java_home ]; then local new_java_home="$(/usr/libexec/java_home -v 1."$version")" @@ -36,6 +38,16 @@ _jvm-discover-and-set-version() { [ ! -z "$version" ] && _jvm_set-java-path "$version" } +_jvm-edit-config() { + if [ ! -f ~/.jvmconfig ]; then + cat > ~/.jvmconfig <" + echo "Usage: jvm (local|global|version|reload|config) " return 0 ;; esac