Manage Learn to apply best practices and optimize your operations.

Brian Mahoney on Java vs. LotusScript

Brian Mahoney offers his advice on the advantages and disadvantages of writing a Java agent over an LS agent in the first installment of our developer tip series on Java vs. LS.

View member feedback to this tip.

Brian Mahoney member Teck Lung recently posted this question in our developer discussion forum: .mgn7axGcQYd.3@.ee7740b/16703!viewtype=threadDate&skip=&expand=>What are the advantages and disadvantages of writing a Java agent over a LotusScript agent? We asked some of our resident experts to give their thoughts about LotusScript vs. JavaScript.'s application development expert, Brian Mahoney, offers his advice in the first installment of our developer tip series on Java vs. LotusScript.

To Java or not to Java?

That is the question. We often get questions about when to use Java rather than LotusScript. Back when LotusScript was first introduced, the question was when to use LotusScript over the formula language. Now it seems almost second nature and usually self-evident to use LotusScript, so the question rarely comes up. (Although I do remember having a conversation last year with a longtime Notes developer who was still using formula when LotusScript may have been much more appropriate.)

Sometimes it's just a matter of preference when it comes to determining which language to use. If that's what it comes down to for you, and you can use Java, then I would go with Java. In the long term, I think it would be better use of your skills and help increase your proficiency with Java, something that is more likely to be marketable in the future. But if you are the only person in your shop familiar with Java, then there is always the issue of just who is going to maintain the code if you're unavailable.

Sometimes you just can't Java

Sometimes the tasks you are trying to perform just don't lend themselves to Java development. If you need access to the Notes front-end (UI) classes, then Java is not an option. If you plan on using COM classes to access other applications like spreadsheet or word processing applications, again, Java won't fit your needs.

Sometimes it's better to Java

When you have a certain task to perform, Java is the more logical choice. If you need to integrate your code with Websphere or other J2EE applications, use Java. If your code will be parsing data and/or reading Web pages, go with Java. Its string class provides a wide variety of methods for parsing data. Extensive and ever expanding, libraries provide methods for networking, handling graphics and much more. You can import a library into your project and the methods are available to you.

And, of course, Java is designed to run on many different operating systems. The choice of which language to use still comes down to your personal choice, but considering the differences, you can make a better, informed decision.

If you do Java be aware

There are a few things that you should be aware of if you haven't coded in Java before. Java is case sensitive, so referring to the variable myDatabase is not the same as my Database. In Java, a string never changes. You need to use a StringBuffer to concatenate and work with strings.

In Java, the console is your debugger. You don't have extensive debugging capabilities and will rely on the Java equivalent of print: System.out.println("Your debugging message").

But the biggest "Gotcha!" for beginning Domino Java developers is the need to recycle. When Java accesses Domino, it is doing so using the C API. Unlike LotusScript, which does extensive cleanup and garbage collection for you, you need to indicate what is garbage. To do this, use the recycle method once you are finished with a Domino object. For example: view.recycle(). This is very important to prevent memory leaks, which lead to exploding applications.

Where to start

This is a really high-level look at some of the things you need to consider. If you're an experienced Domino programmer, the basic syntax in Java is the same as the syntax in LotusScript. The Domino Object model is the same, although classes don't usually start with Notes. So what you want is a jump-start course and reference. A good place to start is Team-TSG.

Team-TSG (Two Short Guys) is the pairing of the Domino and Java expertise of Joe Litton and Tom Duff. The TSG site has links to their Lotusphere 2004 presentation, Java For The Domino Developer. In addition, each of their sites have some great tips and experience with Domino and Java (among other things). They recently wrote articles in Lotus Advisor Magazine on getting started in Java for Domino Developers (December 2003 and February 2004).

Other resources/references


Web Sites
Brian Mahoney is a developer for a financial-services firm in the Philadelphia area. In addition, he consults on technical and Web-related issues for a number of small and medium businesses. He has more than 10 years of Notes/Domino development and administration experience. He is a CLP application developer and administrator and a expert.


I think that Mahoney has taken a very simplistic view of this issue. Generally we take the following approach for the following reasons:

  1. When programming exclusively in the Lotus Notes Client, use LotusScript due to the access to the front-end UI classes.

  2. When programming exclusively for the Web use Java, both in query open and close agents, although I like to stay away from these if possible and use a Java Applet and Servlet for all retrieval of data such as lookup lists.

    The use of a DBLookup and DBColumn applet and servlet enables the developer to avoid page refreshes with cascading selection lists, thereby removing a significant performance hit from straight Domino @function-driven Web applications.

  3. Where there is the need to migrate a Web application to a J2EE platform at a later stage, we use HTML and JavaScript coupled with an n-tiered Java framework that is activated from a Domino agent to build high functionality applications. The only Domino design elements used are views and one agent. This provides a future growth path at minimal cost and gives a significant improvement in performance as Domino is only being used as the data storage mechanism.
-- John P.


Thanks for this article. I was stressing out about having to learn Java, but as I'm mainly developing in-house databases, it looks like I can probably put off learning Java for a while and concentrate upgrading my skills/qualifications to R6.

-- Walter P.

Do you have comments of your own? Let us know.

Dig Deeper on Java for Lotus Notes Domino

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...