Usage

Then, just cd to a java project folder. jvm will look for a .java-version and use whatever version is inside it. If the file don’t exist, but a pom.xml do, jvm will try to extract the version from the pom.xml file using a regular expression. If no pom.xml is found, it will look for the build.gradle file and do the same strategy to extract the java version.

jvm can also recursively search for .java-version , pom.xml and build.gradle files, so, cd -ing to project’s subfolder should maintain its version set.

You can always change the current folder java version by doing:

$ 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. 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

or even:

6=/path/to/openjdk/6

And jvm will automagically works.

And, yes, this strategy (based on jvm config ) can make jvm work on Windows with any bash terminal too. Or any other operating system with a POSIX shell really.

You can also read theself-document tests to find out more usages.

Antigen/Antibody

For those using Antigen, Antibody or whatever, just bundle caarlos0/jvm , as in: