LS2J rules!

I know it has limitations and that it has issues but today it worked like a charm. I was asked to write a library in LotusScript to resolve groups and nested groups from Active Directory into an array of users. It had to be cross platform which ruled out COM and ActiveX controls even if I had been able to find any.

The solution was of cause to write the code in Java using JNDI (Java Naming and Directory Interface) and then write a thin wrapper class in LotusScript using LS2J (LotusScript to Java bridge supplied with Notes out-of-the-box). Now I have a cross-platform solution that has no external dependencies. Beautiful!

So learn Java already! 🙂

6 thoughts on “LS2J rules!”

  1. Yes, it is good.

    I have used LS2J for several years now (since version 6.5) and it has proved to be very solid and stable. And performance is not an issue!

    I started using it to call a webservice that we needed to call from the server (iSeries) as well as the client (Windows). This was the only solution that would not require writing the same code twice in two different tools. And since it proved to be solid and stable, I have been doing that since then.

    A couple of things to look out for.

    1. Error handling of Java Errors
    2. Interface declarations

    I normally create a LotusScript wapper class that will handle all this and then all the other LotusScript programmers get a very simple well-known interface to some cool code. If I have problems with the interfaces to the Java classes I just write a small Java helper class (as a wrapper for the real Java class I want to call) and add simple functionality to create say a more complex datastructure. One example is sending an array into a Java function. This may be rather difficult to do. But if you create a small helper class with a method to add values and implement the array and the final call with the array as an argument from Java, then it is still simple and maintainable…

    I have used for all sorts of things where we want some interaction with the UI-document. Examples are: reading a web page (very easy in Java) and calling relational data through JDBC.



  2. Yes, LS2J is cool. I recently created an Unzipper with it, wrapped in a Lotusscript class with progress listener, e.g. showing the unzipping progress with a Lotusscript progress bar (some code snippet that calls the Notes C API to show the bar).

    Unfortunately, the startup time of the JVM is quite high, when you include a script library that uses LS2J. I did some tests with it and it looked like you can prevent that by calling a "dummy" Notes Agent that uses LS2J and use the "run in background" agent option. Run that agent on database open and the JVM should be up and running when the user clicks a button that also uses LS2J code.


  3. Hi Mike
    Iam using LS2J in one of my scheduled agents, I would like to know how do we ensure we handle memory properly.
    The Lotus wrapper classes for JavaSession, JavaError doesnt contain a recycle.


  4. If I had a Java library I needed to access using LS2J I would build the API which may be fine grained. Then I would write a wrapper, Facade like API, and then write a bridge for the "Facade" in LotusScript using LS2J. This means you can do memory management etc. in the "Facade" API and make using the API easier. It will also be faster since you don’t have to context switch and marchal data in and out of the two languages.


Comments are closed.