Is it possible to use Java API classes from starBASIC?
From reading documentation, it seems that it’s possible to use UNO classes (com.sun.star.*), but how about something like java.io.File, java.net.URLConnection? I couldn’t find such example in documentation.
Directly no, but, you can call other macros in Java. But, why don’t you develop directly in Java?, you don’t need Basic.
I think of more integrated solution, that’s why I’m asking about using from BASIC directly…
But just in case, could you provide an example of calling othermacros in Java?
Let’s look at a meaningful example of calling Java from Basic.
Sub TestRunMacro()
Dim scriptUri As String, oScript As Object, oScriptProvider As Object
oScriptProvider = createUnoService("com.sun.star.script.provider.MasterScriptProviderFactory").createScriptProvider("")
scriptUri = "vnd.sun.star.script:MemoryUsage.org.libreoffice.example.java_scripts.MemoryUsage.updateMemoryUsage?language=Java&location=share"
oScript=oScriptProvider.getScript(scriptUri)
oScript.invoke Array(), Array(), Array()
End Sub
See also LibreOffice Developer’s Guide: Chapter 18 - Scripting Framework.
1 Like