Actually showing the password prompt when developing Java for Notes

If you’re developing console applications in Java that access Notes resources and you’re testing them in Eclipse you have experienced the following. You run your application to test it from Eclipse. It accesses a Notes resource and you haven’t granted 3rd party applications access in the Security settings so it causes Notes to ask you for the password – only the Console view doesn’t accept input… Bummer! πŸ™

Fortunately there’s a solution to this which I’ll show below.

Disclaimer: I can in no way take credit for this tip as I didn’t discover it. The credit goes to Karsten Lehmann who posted it in the Design Partner forum.

The solution is not to make the password prompt go to the Console view but pop up a password entry dialog instead. The way to do this is to initialize the Swing UI framework before running your application as I do below (see code in bold).

import javax.swing.SwingUtilities;
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) {
    try {
      SwingUtilities.invokeLater(new Runnable() {
        public void run() {}
      });

      NotesThread.sinitThread();
      s s = NotesFactory.creates();
      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();
    }
  }
}

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.

Three mugs

While installing Windows 7 on my main laptop today I cleaned out my office a little. Part of the stuff I found was these three mugs from times past. From left to right: yellow Lotus Notes mug, OS/2 mug from the OS/2 Warp days and of course my IBM e-business mug. Makes the mind wander… πŸ™‚

Lotusphere 2010: Lotus knows something about chainsaws

It’s probably no surprise that Lotusphere 2010 is all about what Lotus knows whether that be on badges, at sessions, on Twitter or on my room mirror. The Lotus knows message is really all over the conference and is becoming the meme that binds it all together. Lotus knows a lot. Maybe too much sometimes. The fact that Alistair Rennie is good with a chainsaw is probably one of those things…

(for the uninitiated there was a video at the OGS where people had to mention what they were good at and Alistair Rennie said he was good with a chainsaw)

I really like the message and was happy to hear that the campaign is coming to Europe. It will start in Germany in connection with Cebit (March) and will move on from there. Whether it reaches Denmark or even Scandinavia is too soon to tell.

Lotusphere 2010: Conference underway

So Lotusphere is finally underways – well sort of anyway. Officially it wont start until tomorrow morning but Business Development Day, JumpStarts and Bootcamp still feels like we’re of. And we’re of to a good start. The energy feels right and it feels like it’s going to be a good Lotusphere. As Alistair Rennie said this morning in the BDD OGS: “Lotus knows sleep is for February!” That has to be the quote of the day of not for the week. Oh and knowing that Alistair thinks himself handy with a chainsaw!! πŸ™‚

Besides that I was happy to hear that Lotus Notes and Lotus Domino will also go into controlled distribution in 2010 meaning that you have to be certified to sell it. I find that a very good, although bold move by IBM. This is a decision that will help us tremendously in our business. Having to be certified (both technically and sales wise) means that you cannot simply sell licenses without delivering value. That’s great and wise move that will benefit both the partner community and the customers.

Lotusphere 2010: Improvements to the web app

Based on the overwhelmingly positive reception of our web application for planning your Lotusphere 2010 attendance (see Lotusphere 2010: Check out this killer Lotusphere planning web app!!) I wanted to update you on the application and the suggestions to functionality you have made. Based on feedback from YOU we’ve added the ability to navigate between days in the “tracks”-view, made sure that all the BOF sessions are imported and that sessions with multiple speakers list all speakers and not just the first speaker. Since BOF sessions start at 7AM a small change to the timebar was also necessary but that should hardly be visible.

As shown below we’ve also added a menu item on the frontpage describing the different ways of reaching us while at Lotusphere. On this page you’ll see e-mail addresses, mobile phone numbers and of course Twitter handle for those of us on Twitter.

As always keep the suggestions coming.

Extending DDE – creating custom context menus

Part of my new LotusScript.doc release is of course finding ways to make it even easier to use and use the API that’s now supplied as part of LotusScript.doc. Central to all this is extending DDE to make LotusScript.doc accessible in a variety of ways. Today I’ll show you how to add context, i.e. right-click, menus to the DDE navigator on the left as you can see below.

Doing this is actually very easy and only comprises of an IViewActionDelegate (the code; implement org.eclipse.ui.IViewActionDelegate) and a entry in plugin.xml to indicate where to stick the action. In this case it’s an objectContribution to org.eclipse.ui.popupMenus:

<extension point="org.eclipse.ui.popupMenus">
   <objectContribution adaptable="true"
      id="com.lekkimworld.dde.navctxmenu.objectContribution"
      objectClass="org.eclipse.core.resources.IFile">
      <action
         class="com.lekkimworld.dde.navctxmenu.MyContextAction"
         enablesFor="2+"
         id="com.lekkimworld.dde.navctxmenu.action"
         label="DDE context stuff (select min. 2 design elements)"
         menubarPath="additions"
         style="push">
      </action>
   </objectContribution>
</extension>

The above should be pretty much self-explanatory.

The example code is available for download as an Eclipse project: com.lekkimworld.dde.navctxmenu.zip

Oh what a xmas card

Today I received a xmas card from Abeish Babu who is a regular reader of this blog and who I’ve helped a little during 2009 with some plugin development for the Notes 8 platform. It’s always very nice to receive these kinds of cards so Abeish, thank you very much.

What was also nice was the commotion in the office over the address label of the envelope (see below). Seems like I have been elevated to a saint like status. How nice is that! πŸ™‚



(click the picture for larger version)