1

I'm trying to use LS2J to invoke the Simple API for the ODF Toolkit (https://incubator.apache.org/odftoolkit/simple/index.html) from LotusScript, and I've been unable to use it properly.

I've included in a Java library called ODFDOM the following:

  • odfdom-java-0.8.7.jar
  • simple-odf-v0.4.5.jar
  • Xerces-J-bin.2.11.0-xml-schema-1.1-beta.zip

With this code in the Sub Initialize of the agent:

Dim js As javasession
Dim jc As Javaclass
Dim jerr As JAVAERROR
Dim jms As JavaMethodCollection
Dim jobj As Javaobject, jdoc As JavaObject
Dim jm As JAVAMETHOD

Set js = New JavaSession
Set jc = js.Getclass("org/odftoolkit/simple/SpreadsheetDocument")
Set jm = jc.GetMethod("newSpreadsheetDocument", "()Lorg/odftoolkit/simple/SpreadsheetDocument;")
Set jdoc = jm.Invoke

execution gives an error:

JS2J Error: Threw java.lang.NullPointerException

Any clues about what am I doing wrong?

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
richieadler
  • 135
  • 9

1 Answers1

1

You have to "Use" your library "ODFDOM" and get your class in Java notation with dots. You can shorten your code with direct call of your static method:

Use "ODFDOM"
Dim js As javasession
Dim jSpreadsheetDocumentClass As Javaclass
Dim jdoc As JavaObject

Set js = New JavaSession
Set jSpreadsheetDocumentClass  = js.Getclass("org.odftoolkit.simple.SpreadsheetDocument")
Set jdoc = jSpreadsheetDocumentClass.newSpreadsheetDocument()

UPDATE:

LS2J doesn't work with resources. Whenever you use resources in Java code it won't work with LS2J. After a short look into ODF Toolkit source code I saw resources used.

So, create an Java agent instead and call it from LotusScript.

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
  • I _did_ include **Use "ODFDOM"** in the Options section, I was just pasting code from Initialize. But it's a good point, though. _When you use the dot "." notation on the Macintosh, the Mac will return an error that the Class cannot be found. Instead, use the slash "/" notation. The slash "/" notation works on all platforms. Use the slash "/" notation in your applications for multi-platform support._ (Designer manual) I made the changes suggested, but the error is the same. – richieadler Jan 14 '14 at 13:28
  • 1
    Ok, good to know, didn't developed for Mac yet. I worked a lot with LS2J and I think it won't work for ODF Toolkit. See my updated answer. – Knut Herrmann Jan 14 '14 at 13:49