Configure Eclipse 3.5 for Notes 8.5.2

As for previous versions I maintain a document outlining how to configure a vanilla Eclipse install to work with Lotus Notes for Java extension development (with install_id and rcp.base). I have made the first version for Notes 8.5.2 as of code drop 5 so please see Configure Eclipse 3.5 for Notes 8.5.2 if this is of use to you.

Please Lotus that Notes 8.5.2 is in beta and there are no guarantees that the features described here will be in the final product that IBM ships.

BAT-files (yup – you heard right!) to sign an entire update site

Digitally signing an Eclipse update after the fact (i.e. it’s not part of the build) can be tedious and time consuming. To make the process easier I wrote two small BAT-files that does the recursive signing of all plugin and feature JAR-files for you. Just stick the two BAT-files (signall.bat and dosign.bat) in the root Eclipse update site directory (together with site.xml) and invoke signall.bat.

Syntax
signall.bat <keystore path> <keystore password> <certificate alias from keystore>

Example
signall.bat mykeystore changeit signer_key

signall.bat

@echo off
set jdkhome=%JAVA_HOME%
for /f %%a IN ('dir /b /s *.jar') do call dosign.bat %1 %2 %3 %%a
set jdkhome=

dosign.bat

@echo off
echo Signing: %4
%jdkhome%binjarsigner.exe -keystore %1 -storepass %2 %4 %3

Java class line numbers for plugin developers

If you’ve been tasked with developing and/or debugging Java extensions for the Notes 8 client you know that line numbers has been missing from the stacktraces produced by Notes. This can be a real problem when trying to debug stuff in a production client. There has been some discussion among the ones of us developing these extensions on how to enable these line numbers. The other day this information was provided by Srinivas Rao of IBM and I wanted to publish it here for all to read.

Line numbers are removed from the classes added to the shared class cache to reduce the memory needed for the memory mapped classes. To re-enable the line numbers, one needs to edit the <notes>frameworkrcpdeployjvm.properties file and add comment out the ignorelinenumbers vm argument. However, if the classes have already been added to the JVM shared class cache, then they will have been added without line numbers. Either comment out the shared class cache (which will dramatically affect performance at startup) for temporary work, or shutdown notes and remove the shared class cache so that it can be repopulated with classes with line numbers. Of course, this will also affect the startup performance, but not so much as not having a cache

These are two of the key lines … to comment them out, add a # to the front of the line

vmarg.Xnolinenumbers=-Xnolinenumbers
vmarg.Dshare=-Xshareclasses:name=xpdplat_.jvm, **line cont**
   controlDir=${prop.jvm.shareclasses.loc}, **line cont**
   groupAccess,keep,singleJVM,nonfatal
jvm.shareclasses.loc=${rcp.data}/.config/org.eclipse.osgi

The shared class cache is typically located in the data/workspace/.config/org.eclipse.osgi

Ribbon IDE for Lotus Notes?

As you know Lotus Notes is built on Eclipse so following Eclipse plugins and projects makes a lot of sense from a platform point of view. Surfing the other day I stumbled over an Eclipse project that provides a Ribbon IDE for the Eclipse platform. It makes your mind wander to Microsoft centric but it might make sense for other applications incl. Lotus Notes.

For more info see “Eclipse plug-in sightseeing: Ribbon IDE / Eclipse”. There’s also a PDF showing it off.

Know your (Eclipse) Target Platform

When developing plugins for Lotus Notes you need to know about Target Platforms in Eclipse. The Target Platform is what describes the functionality that’s available to your plugin in the, you guessed it, target platform. You can use this to simulate your plugin running in a number of different scenarios or products (such as Sametime, Notes etc.).

The other day I found this nice blog series about Target Platforms and thought I would share.

Blog Series around PDE and Target Platform

How to get started with plugin development

I get a lot of questions (via e-mail and IM) on how to get started with plugin development for the Lotus Notes platform. Instead of answering them all individually I thought I would (finally) write a general purpose blog post to try and answer these questions in general terms.

First of I’m sorry to say that the current state of affairs for someone who want to get started doing plugin development for the Lotus Notes platform is grim. There is as you might have experienced very little material available for programmers new to the Eclipse world to build stuff for Lotus Notes 8+ clients. To make things worse the material that is available often cut corners or simply start out too advanced. That being said I am hearing muffled voices mention some material being developed and that IBM Lotus is focusing on this matter but it will be yet some time before it’s out. Until that time and until we can upload information directly into the brain like martial arts skills are given to Nemo in The Matrix I suggest the following.

My suggestions for someone getting started would be to start by realizing that programming for Eclipse and hence in SWT for the Lotus Notes 8 client has nothing, what so ever, to do with traditional Notes programming. It sounds obvious but once you have accepted this it gets easier. Maybe not easier technically but easier to accept that this is a completely new field you’re venturing into. If nothing else you stop looking to IBM Lotus for help and instead turn to the Eclipse side of the internet.

Before you start to whine I think this is just fine and how it should be. Really. Initially most of the stuff you need to know to get started has nothing to do with IBM Lotus but is general purpose Eclipse development information. It’s like blaming Toyota for not telling you how to repair their cars. Toyota can be expected to tell you and document what’s so special about their cars. They can’t be expected to teach you the basics – you go to a car repair classes for that.

It’s the same with Eclipse development. Learn the basics and specialize from there. You could say that we could expect information about the various ways to extend the client to readily available and better documented. I’ll give you that… πŸ™‚

Once you’re past that and before you embark on your journey first realize this. In Eclipse and SWT we build everything our selves and we’re left to the mercy of the client and the differences that exist across the different platforms (Notes 8.0.x vs. Notes 8.5 across Mac / Linux / Windows XP / Windows Vista / Windows 7). We’re close to the metal with all the benefits, worries and problems that entail.

So if I had to come up with an action plan for learning about Eclipse / Expeditor / Notes 8+ development it would be something like the following:

  • Learn Java! Become proficient in Java! It sounds obvious but it’s one of the pillars for being successful in this area. Pay special attention to the following areas as they are used heavily when developing for Eclipse:
    • Event publishing/subscription using listeners
    • Anonymous inner classes
    • Interfaces
    • Multithreading
  • Learn about GUI development in general. Resources for developing in Java SWING are just as good as those for SWT as many, if not all, of the concepts apply to both. UI development includes:
    • Widgets
    • Layout managers
    • Threading and the concept on an UI thread. What should and shouldn’t you do on the UI thread!?
  • Learn about Eclipse and the Eclipse platform for building RCP (Rich Client Platform) programs.
  • Buy a book about it such as “Java Developer’s Guide to Eclipse, The (2nd Edition)“. It has been a good help to me.
  • Stop by http://www.eclipse.org/articles and take a look at the articles there.
  • Follow this blog πŸ™‚

As you can see it’s no small adventure you’re starting into. The learning curve may be steep but it’s also rewarding to be able to extend the client beyond belief. If only you’d started learning Java earlier…

Complete guide to manually uninstalling “plugins” from Lotus Notes

As you probably know installing and uninstalling Java extensions (“plugins”) into the Lotus Notes client is easy using either File >> Application >> Install, File >> Application >> Application Management or the widget catalog. Sometimes however this doesn’t work and you’ll have to resort to a manual uninstall. This blog post outlines the way to perform a manual uninstall.

We have to start with some basics though. A Java extension in Lotus Notes (also known as a “plugin”) consists of two things:

  1. Eclipse plugin(s)
    The plugin is where the actual code and functionality is stored together with additional resources such as images, string translation etc.
  2. Eclipse feature
    The feature is what’s actually installed from a Lotus Notes perspective. The feature points to the Eclipse plugins that provides the actual functionality. It’s almso important to note that a single feature may reference multiple plugins.

Both an Eclipse plugin and an Eclipse feature are represented in the file system as JAR-files (files with an extension of “JAR”) and both of them are kept in the file system. A JAR-file is just a fancy ZIP-file with a predefined folder structure. Eclipse Features and plugins are stored in two directories beneath your Notes data directory (<Notes data dir.>/workspace/applications/eclipse/features for the features and <Notes data dir.>/workspace/applications/eclipse/plugins for the plugins).

From the above it may seem obvious that simply deleting these files will uninstall a Java extension – unfortunately there’s a final piece to the puzzle. Lotus Notes also keeps a record of what’s installed in a file called platform.xml (stored in <Notes data dir>workspace.configorg.eclipse.update). Simply deleting the feature(s) and plugin(s) may seem to work but will misbehave for instance when activating the File >> Application >> Application Management interface. The solution is to edit this file as well.

The complete steps to manually uninstalling a Java extension is therefore as follows:

  1. Close Lotus Notes
  2. Open the “features”-directory (<Notes data dir>workspaceapplicationseclipsefeatures)
  3. Locate the Eclipse features to uninstall.
  4. For each Eclipse feature you need to open it and edit the feature.xml file. Locate the <plugin>-tags and fine the names of the referenced plugins. Note that there might be more than one. Combining the plugin id and the plugin version will give the full filename of the plugin (<plugin id>_<plugin version>.jar).
  5. Delete the Eclipse features you’re uninstalling.
  6. Open the “plugins”-directory (<Notes data dir>workspaceapplicationseclipseplugins).
  7. Delete the plugin JAR-file(s) you recorded in the step above.
  8. Open the directory containing the platform.xml file (<Notes data dir>workspace.configorg.eclipse.update).
  9. Edit platform.xml and go to the end of the file.
  10. Remove each entry you see for the features you deleted in the step above.
  11. Save and close the file.
  12. Since Lotus Notes also keeps a record of which Java extensions to load it’s best to start Notes with some parameters to make it recompute the Java extension registry: notes.exe -RPARAMS -clean

Let me know if the above doesn’t work for you.

Please note: Manually uninstalling a Java extension installed via a widget descriptor via a widget catalog/policy will probably just make it reinstall once uninstalled.

Doing Java plugins? Then you need to checkout this OpenNTF.org project

Props goes out to the Java UI Team (Ryan Baxter, Adam Geheb, Stanton Sievers) for publishing the Java UI API Exerciser plugin showing how to use the Java UI API for the Notes client. If you’re doing Java plugins for the Notes client you definitely want to check it out. Installation is also very easy because it’s signed and as such also serves as a showcase on how plugin deployment works when it’s fully transparent.

More info can be found on the catalog entry.

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();
    }
  }
}