Updating an OSGI Based Software System from Java 6 to Java 7

In this article, I want to describe how we managed to switch from Java 6 to Java 7 and get rid of some issues we found along the way. We use Eclipse 4.2.2 and had to change to Java 1.7.0u21. Our system consists of more than 30 eclipse projects that are managed by OSGI.

First, we installed Java 1.7.0u21 and added the JRE to eclipse. Because we cannot be sure that all of our users have a 64 bit system, we use the jre1.7.0_21-windows-i586:

Updating OSGI Based Software System 1

Then we switched the compiler to 1.7:

Updating OSGI Based Software System 2

After that, we changed the setting of our projects. We used the eclipse interface to change the settings of one project and after that copy the changes to all other projects. For one project, the execution environment in the MANIFEST.MF had to be changed to JavaSE-1.7:

Updating OSGI Based Software System 3

The classpath had to be updated via “Update the classpath settings”. Via File Search > Replace I copied the following changes to all other projects:


Bundle-RequiredExecutionEnvironment: JavaSE-1.6

Changed to

Bundle-RequiredExecutionEnvironment: JavaSE-1.7


<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">

Changed to

<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">

After a refresh to all projects and a rebuild, every project uses JavaSE-1.7. Next, we encountered several

java.lang.UnsupportedClassVersionError: : Unsupported major.minor version 51.0

Following this discussion at sourceforge, this could be fixed by making sure Eclipse uses the right virtual machine. This can be done by pointing to the virtual machine with the following eclipse start parameter:

-vm "D:\jre1.7.0_21-windows-i586\bin\javaw.exe"

Now, our system runs with Java 7.