I recently came across an interesting problem in the Library Finder project. Currently, Library Finder works as IntelliJ IDEA plugin and also, as a command line tool. This project uses some of the Java 5 features like generics, auto-boxing and enhanced for-loops. The plugin version of this tool works fine because it’s running inside IntelliJ IDEA and IntelliJ adapted Java 5 very early from it’s 5.0 versions. I have used command line version of Library Finder so many times without any issues but, it was all on JDK 5 environments.
The client where I am working currently hasn’t upgraded to Java 5 yet and they are still in Java 1.4. While I was running Library Finder from the command line I was getting java.lang.UnsupportedClassVersionError. That immediately made me realise Library Finder is not backward compatible. I was looking for ways to make it backward compatible and there are no valid reasons to make this tool supported only from Java 5. After doing some research, I found out setting the compiler options “-source 1.5 -target jsr14″ will make Java 5 source code backward compatible to 1.4. I don’t want to go back beyond 1.4 because, Library Finder uses pattern matching support from java.util.regex.Pattern class, which is available only from Java 1.4.
Here is the screenshot showing the compiler options in IntelliJ IDEA v6.0.4. You should be able to set this compiler options in any of your other favorite Java IDE’s or in command line.

Recent Comments