Discovering Notes 8: Enabling Java 5 source compilation


I’m playing around with Notes 8 to get my bearings on the Gold release and I’m liking it. I’m kind of a Java-nut so I wanted to see if Lotus delivered on their promises to include Java 5 in Notes 8 and they did. Unfortunately the Java API hasn’t been updated for this release but hopefully this will happen in the near future. I know I will certainly stress that it will in the Domino Application Development Design Partner program where I have been fortunately enough to be included (together with Nathan and a fine line of other fine folks).

To test it out I fired up Domino Designer and created an agent to use generics and some autoboxing. Both are highly awaited in the Notes Java world – at least by me – and it will be really nice to have. The test agent code is as follows (generics and autoboxing is highlighted):

import lotus.domino.*;
import java.util.*;

public class JavaAgent extends AgentBase {

   public void NotesMain() {

      try {
         Session session = getSession();
         AgentContext agentContext = session.getAgentContext();

         int size = new Integer(10);
         List<Document> docs = new ArrayList<Document>(size);
         for (Document d : docs) {
            d.getUniversalID();
         }

      } catch(Exception e) {
         e.printStackTrace();
      }
   }
}

To my surprise the above code didn’t compile and gave me the below compile error message.

I tried compiling the same code in Eclipse (using Java 5 source compatibility) and importing the class file as an Imported Java agent which worked fine. Hmmm – binary support but no source support? Last resort – look for clues in the release notes and there you have it! In the section “Installation, migration, upgrade, and configuration informationUpgrade notesNotes/Domino 8 upgrade to JDK (Java Development Kit) 1.5” it states that in order to keep backwards compatibility Java 5 source compilation in Domino Designer is disabled out of the box. To enable it add the following notes.ini variable and restart Notes:

JavaCompilerTarget=1.5

Once this line has been added I was able to compile the above code… 🙂

11 thoughts on “Discovering Notes 8: Enabling Java 5 source compilation”

  1. “Unfortunately the Java API hasn’t been updated for this release but hopefully this will happen in the near future”

    I assume that you mean the Notes.jar API and not the Java 5 API. Things like Scanner and Integer.valueOf(int) are now available in Notes 8, in addition to the Java 5 Compiler specifications, of course.

    Like

  2. I find that at least for my Java practices Domino 7 was a great step forward. The JAXP-standard conform xml parser and java1.4. No matter which java1.4-compatible java bonus library I happen to drag and drop from my Eclipse environment to the /jvm/lib/ext, they all just work (jdom, rome, jakarta-stuff). People reported that hibernate works, too, though I find that rather pointless, because you can’t cache objects in classic notes environments and thats a must to make hibernate perform well (should be possible in Expeditor).

    Personally I don’t find the advantages of generics or the for loop very big. At least this is my personal impression after using java5 in non-Domino projects for some time.
    Btw: One easily overlooks the Enum feature. A pitty, because they make sense for some situations and its quite easy to use.
    For friends of books: The Sierra/Bates scjp5 book gives a very pragmatic introduction AND explanation into a lot of Java5 features. Unfortuatedly only those which are relevant for SCJP5 certification. No Annotations, which are very promising, though still I can’t design my own annotations (but its high on the agenda).
    If people really think to need generics and new for loop features in their access to Domino objects, it might be more realistic to ask the Domingo developers (and contribute if one has time). It could be built into that layer, as generics-collections are designed to be mixed with tradition collections (with high potential for confusion because of just that).

    just my 2 cents
    Thanks for the excelent Notes 8 coverage.

    Axel

    Like

  3. If you mean replace the JVM supplied with Notes/Domino 7 so you can use Java 5 featues in agents etc. then unfortunately no. If you mean using a Java 5 JDK outside Notes to work with data in Notes/Domino 7 then yes.

    Like

Comments are closed.