Developing Java plugins and applications for Notes on 64 bit

I just upgraded my Thinkpad from Windows Vista 32 bit to Windows 7 64 bit and besides being amazed at the speed improvements (thanks to moving of Windows Vista) I needed to think about how I develop Java for Notes in general. When moving to 64 bits there are some things you need to consider if, and only if, you install the 64 bit version of the Java Development Kit (JDK) as I did. You need to consider stuff for two reasons which I’ll address in turn.

Please note: This blog post will focus on 64 bits Windows 7 as that’s what I’m running now but I suspect it will apply to other Notes platforms such as Windows Vista, Linux and Mac as well. I’m not using Lotus Expeditor Toolkit so I can’t confirm the following is but a wise man told me that XPD Toolkit doesn’t support 64 bit JDK’s so in that case you need this as well as my “Configure Eclipse 3.4 for Notes 8.5.1”-guide as well.

Notes is a 32 bit application

Say you install a 64 bit JDK and try to run an application that access Notes using local address (NRPC; a client or server installed on the same machine) such as the following:

import lotus.domino.Session;
import lotus.domino.Database;
import lotus.domino.DocumentCollection;
import lotus.domino.NotesFactory;
import lotus.domino.NotesThread;

public class Main {
  public static void main(String[] args) {
      NotesThread.sinitThread();
      Session s = NotesFactory.createSession();
      System.out.println("Name: " + s.getUserName());
      Database db = s.getDatabase("server1/Example", "names.nsf");
      DocumentCollection dc = db.getAllDocuments();
      System.out.println("Docs: " + dc.getCount());

    } catch (Throwable t) {
      t.printStackTrace();
    } finally {
      NotesThread.stermThread();
    }
  }
}

The code will compile fine but when you run it you’ll see a message like the following (plus a stacktrace):

java.lang.UnsatisfiedLinkError: C:Notes8nlsxbe.dll:
   Can't load IA 32-bit .dll on a AMD 64-bit platform

The problem is, as the message explains, that you cannot load a 32 bit DLL (remember Notes is a 32 bit application) into a 64 bit Java Virtual Machine (JVM). The solution is to install a 32 bit JDK instead and run the application using this JDK. Remember that it is perfectly valid and possible to install multiple JDK’s on a single machine and it fact that’s what I’m doing.

Developing plugins for Notes 8+

Developing plugins for Notes 8+ on 64 bit Windows is also somewhat different from doing it on a 32 bit Windows system. Of course you need Eclipse but here’s the first difference – you need to use a 64 bit version of Eclipse if you’re using a 64 bit JDK. The reason is that Eclipse uses SWT (Standard Widget Toolkit) for the user interface widgets. The reason SWT looks so nice on any supported platform is because it wraps the native, C-code, platform widgets. So remember that and grab a 64 bit Eclipse. Once that’s installed and working with your 64 bit JDK configure Eclipse as you normally would but with a small difference that will cause your code not to compile (my Eclipse complained about not be able to resolve org.eclipse.swt.widgets.Shell).

As you may know, you specify the bundles you depend on when developing your plugin and in turn you also specify which environment you run in. This is how Eclipse knows which versions to the bundles to put on the class path but since you’re running 64 bit Windows and Notes is 32 bits it will be a problem. The fix is however very easy to implement and only means tweaking the target platform setup to explicitly set the architecture you’re running on to “x86” and not “x86_64” which is the default if you’re on a 64 bit JVM. Where to set this differs a little between Eclipse 3.4 and Eclipse 3.5 but the concept is the same.

  1. Open the target platform setup
  2. Edit the “Environment” settings
  3. Set the architecture to “x86”

Once this is done the workspace will be rebuilt and everything should work just fine. Mine did anyway… 🙂

Back to our standalone Java application

If you need to run a Java application that accesses Notes locally from within an Eclipse instance (lets face it – who writes Java code without an IDE these days?) you also need to use a 32 bit JVM although you very well may be running 64 bit Eclipse in a 64 bit JVM. The JVM used to execute an application from within Eclipse is the JVM you setup in the build path. To set it simply right-click the project, choose Build Path -< Configure Build Path… and replace/edit the JVM library used.

Conclusion

I hope the above is clear – if not let me know using the comment system. I’ll soon be blogging about using Eclipse 3.5 for your Eclipse development instead of the current version 3.4. Stay tuned.

Eclipse Demo Camp Copenhagen – it is on Thursday!

So the Eclipse Demo Camp Copenhagen will take place on Thursday in the IBM offices in Copenhagen. Checkout the wiki page for more information. The lineup looks quite promising.

Tonny Madsen, RCP Kompagniet
What exactly is the new e4

Jesper Steen Møller, NineConsult A/S
XPath2, XML Catalog and XSLT tooling

Bent Agervold Jensen, ReportSoft,
BIRT

Mikkel Heisterberg, Intravision
Signed plugins and how these works end-to-end in Lotus Notes

Jakob Lyng Petersen, Maconomy
Building a Generic Client for Business Professionals
using Eclipse RCP

Ekkart Kindler, DTU
Model-based Software Engineering with the Eclipse
Modeling Framework

Steen Brahe, Danske Bank, Use of the Graphical Modeling
Framework in Danske Bank

Jan Schoubo, LEJLN platformen
Linux-Eclipse-Java-LEGO NXT - For absolute beginners

Looking forward to seeing you there.

Eclipse Demo Camp in Copenhagen

Eclipse.dk (Danish website) is now arranging an Eclipse Demo Camp in Copenhagen on 10 December 2009. How cool is that?! I’m also happy to say that I’ll be presenting a technical session at the event. If you’re into Eclipse development or interested in it from a Lotus Notes point of view please mark your calendar already today.

For more information see Eclipse Demo Camp Copenhagen

Configure Eclipse 3.4 for Notes 8.5.1

With the eminent release of Notes 8.5.1 it will become important for all you plugin guys and gals to update your configuration to work with Notes 8.5.1. This post will address this.

One of the really nice things about this new release is how Lotus strive to minimize the disk footprint of the install package. Part of this involves how jar-files are stored in the installed package but also how many Java VM’s ship with Notes. Previously there were 2 JVM’s – now there’s only one. There’s no longer a JRE stored in the plugin directory way down in the directory structure. Now you simply use the JVM in <Notes install dir>/jvm – simple right?!

This is nice but it means that your Eclipse configuration needs to be a little different JVM wise. I have therefore updated my Eclipse configuration guidelines to work with Notes 8.5.1.

Happy coding…

Please note: Once Notes 8.5.1 is final and released I’ll update the guidelines with the correct install id etc.

Notes / Eclipse / Lotus Expeditor mapping

Developing plug-ins for Lotus Notes or Expeditor can be complicated enough but you also have to look out for platform differences and the difference in capabilities between different Notes/Expeditor/Eclipse versions. To make this easier for myself I’ve started compiling a Notes version to Eclipse version to Expeditor version mapping table (Notes / Eclipse / Lotus Expeditor mapping).

If you know one of the missing versions please let me know so the table may be complete and be a good reference for us all.

Custom plug-in builds in Eclipse

Just had an interesting issue where I needed to make sure my Eclipse plug-in had the latest version of a jar-file I build in another Java project. Normally including a jar-file in a plug-in project is easy enough but when doing that you’re normally using a static jar-file that doesn’t change. I needed my plug-in to use the latest jar from the other Java project whenever the plug-in was built. Hmmm….

After some searching around and some hints via Twitter I found the solution and it was very easy as Eclipse already include the plumbing for this (from Eclipse 3.2). The solution was to contribute custom build steps to the build.xml that the PDE in Eclipse auto-generates. It’s way easier than it sounds.

The only changes I needed to make to my plug-in project was to:

  • Add “customBuildCallbacks=customBuildCallbacks.xml” to the build.properties
  • Add a customBuildCallbacks.xml Ant file to my plug-in project (the one that needed the newest jar) with a single target called “pre.gather.bin.parts”
  • Write “code” for the target that replaces the jar-file in my plug-in project with the one from my Java project
  • Build the plug-in via my update site

For full details refer to Plug-in Development Environment Guide/Tasks/PDE Build Advanced Topics/Feature and Plug-in custom build steps in the online help.