Tuesday, July 2, 2013

JSelect: switch between different JDK versions

Do you often switch between different JDK version? Do you build JavaFX projects with early preview builds? Then JSelect is for you!
On many platforms it’s a bad habbit to install every JDK (even preview builds) at a global place such as C:\Program Files. Users add global JAVA_HOME environment variables to the system. On windows it is quite common to use the system preferences to change the PATH variable andJAVA_HOME to match the Java version that shall be used. The UI for adding or changing environment variables on Windows is horrible!
If you often switch between different versions then this is very time consuming. What if you’d like to use different JDK versions at once? What if the JDK you’d like to use is not installed to a global place such as C:\Program Files?
To solve the issues I had with Java and environment variables, I wrote a small tool that allows to easily switch between different JDK versions. After choosing the JDK it opens a command-line window (cmd.exe on Windows and xterm on Linux/OS X). Just specify a JDK and click Open CMDto open a command-line window that uses local JAVA_HOME and PATH variables that match the selected JDK. JSelect can also save/load configurations.
This is how it looks like (JDK 6 and JDK 8 in different cmd windows):

That’s great if you want to trigger Gradle builds from the command-line.
Download JSelect-0.3. You can also find it on GitHub


No comments: