Scott H Horwood commented on Sep 10, 2015

Re: Using existing Java in an Xpage

Thank you in terms of adding the jar to the lib dir. That helped a lot. Couldn't remember where to put them. Added org.json to my lib dir in web-inf then importPackage(org.json) and voila, using JSON in my XAgent rather than just strings.

Ruslan Slotin commented on Oct 14, 2011

Re: Using existing Java in an Xpage

To reuse existing code from Java script libraries in SSJS I used a LotusScript agent

doing the following:

- extract compiled .jar files from Java script libraries (they are attached to design notes as "%%object%%.jar" files);

- convert the extracted files to Rich Text format (CD segments);

- import converted files into the folder WebContent/WEB-INF/lib in the database

as file resources using DXL (to create a new design element without a real content) +

C API function MailAddMessageBodyComposite (to embed CD file as rich-text into the

just created design element).

That is why the agent it written on LotusScript: it is easy to call C functions from LS.

The agent should be launched after any modifications of Java script libraries to refresh

.JAR's in the WEB-INF folder

Notice that this solution became much less useful since 8.5.3 as there is a new design element:

Code\Java where you can write Java classes directly available in SSJS

David Gilmore commented on Nov 9, 2010

Using existing Java in an Xpage

- Is this for real? The only way to use a Java SL on a XPage is to export it and build a stand-alone JAR, with all the horrid ramifications? (violent shivver)

David g Burley commented on Oct 6, 2009

An alternate way to use this with agents

Rather than import the jar back into the java script library, place it in the jvm/lib/ext directory of your Notes or Domino install and use it directly from the agent.

import lotus.domino.*;

import org.foobar.myjar.*;

public class JavaAgent extends AgentBase {

public void NotesMain() {

try {

Session session = getSession();

AgentContext agentContext = session.getAgentContext();

// (Your code goes here)

CMChanges cmChanges = new CMChanges(session);


} catch(Exception e) {





This makes the code widely available without the need to import it back into one or several libraries.