Connect Lotus Script to Java using LS2J

Share

Introduced in Lotus Notes 6, LS2J allows the use of Java code from Lotus Script. To use LS2J from within Notes, your Lotus Script code must include this line:

UseLSX "*javacon"

This loads the LS2J Dynamic Link Library (DLL) on Win32 and registers all the Application Data Types (ADTs). Lotus Script provides a JavaSession ADT to be used as an instance to connect with the JVM.

The next statement creates a new Java session. If the JVM has not been started, one is created at this time.

Set mySession = New JavaSession

LotusScript locates the Java class files in two ways:
– In the Script Libraries that the user specified through the USE statement.
– On the file system as specified in the Notes.ini variable JavaUserClasses.

public class Calculator {
    // Java property
    public static String title = "LS2J Calculator";
    // Java methods
    public int addNumbers(int a, int b) {
        return a + b;
   }
 
   public int substractNumbers(int a, int b) {
	return a - b;
   }
 
   public int multiplyNumbers(int a, int b) {
	return a * b;
   }
 
   public int divideNumbers(int a, int b) {
	return a / b;
  }
}

Besides the LS2J classes used in this example, you may also find classes such as JavaError, JavaMethodCollection, JavaPropertyCollection. For further reading please follow the references link below.

Declare classes explicitly public, to avoid java.lang.InternalError exceptions that occured in later versions of the Notes client when trying to access the public member variables.

Option Public
Option Declare
UseLSX "*javacon"
Use "Calculator"
 
Sub Initialize()
Dim myClass As JavaClass
Dim myObject As JavaObject
    Dim title As String
    Dim a As Integer
    Dim b As Integer
    Dim sum As Integer
    Dim mySession As JavaSession
 
    Set mySession = New JavaSession()
    ' Set Lotus Script values
    a = 15
    b = 3
    Set mySession = New JavaSession()
    ' Get Java "Calculator" class
    Set myClass = mySession.GetClass("Calculator")
    ' Call Java "Calculator" Constructor
    Set myObject = myClass.CreateObject
    ' Get Java property
    title = myObject.title
    ' Call Java Methods
    sum = myObject.addNumbers(a, b)
 
    MsgBox title + " " + sum
End Sub

LS2J has some limitations due to security reasons:
– Only public methods and fields are available;
– LS2J has the same access rights as a Java program which does not contain a package statement.

References:
LS2J Online Help

Finally, there’s another very important peculiarity of what does Cialis that brings it so high above its alternatives. It is the only med that is available in two versions – one intended for use on as-needed basis and one intended for daily use. As you might know, Viagra and Levitra only come in the latter of these two forms and should be consumed shortly before expected sexual activity to ensure best effect. Daily Cialis, in its turn, contains low doses of Tadalafil, which allows to build its concentration up in your system gradually over time and maintain it on acceptable levels, which, consequently, makes it possible for you to enjoy sex at any moment without having to time it.

By continuing to use the site, you agree to the use of cookies. More information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close