This article is designed to help those traditional lotusscript developers turn to Java development. With virtually no Java knowledge, this article can help you start Java application development in IBM Lotus Domino.
Brief introduction
For IBM Lotus Notes application developers, the LotusScript and LotusScript classes are useful when designing a Notes application. The LotusScript API supports programmatic interaction with databases, documents, and even design elements. As Java developed into a mainstream programming language, the more Notes application developers turned their attention to Java.
This article contains three parts: the Java language, examples, and other elements. Java programmers can skip directly to the sample section, but beginners should start reading from the Java language section.
Java language
Published in 1995, Java is an object-oriented programming language, its emergence satisfies the platform independence demand. This is done by compiling the Java source code into bytecode, and then any Java Virtual machine (JVM) on any platform can interpret the byte code.
As a result, any Java application can be run as long as the JVM is implemented for the target platform.
Java's syntax is similar to C, and its object-oriented implementation is similar to C + +, so C + + programmers can easily master Java. However, lotusscript developers may find that Java syntax is very different from lotusscript.
As this article focuses on using Java in Lotus Domino, the examples shown will also be implemented in Lotus Domino's environment.
Let's start with the classic Hello World example. When you create a new Java proxy in Domino Designer, you receive the template code shown in the left column of table 1. The code in the right column has been modified to fit the needs of the "Hello World" sample.
Table 1. Hello World Example
Template Java Proxy Code |
Hello World Java Proxy code |
Import lotus.domino.*; public class Javaagent extends Agentbase { public void Notesmain () { try { Session session = GetSession (); Agentcontext agentcontext= Session.getagentcontext ();
(Your code goes here)
catch (Exception e) { E.printstacktrace (); } } } |
|
Import lotus.domino.*; public class Javaagent extends Agentbase { public void Notesmain () { try { Session session = GetSession (); Agentcontext agentcontext= Session.getagentcontext ();
(Your code goes here)
System.out.println ("Hello world!"); catch (Exception e) { E.printstacktrace (); } } } |