B4J Question [XLUtils] Creating MS Word Documents on the MAC

gregchao

Member
Licensed User
Longtime User

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
ut xlutils uses powershell to interact with Excel.
this is incorrect, xlutils uses powershell to create pdfs from word but thats the only part that requieres powershell, the rest is java based apis.

it should work. Any help is welcome.
what is the error ? or what happens when it fails?
 
Upvote 0

gregchao

Member
Licensed User
Longtime User
It is very difficult to debug on MAC because you have to run compiled code. I first run the code in windows and it works fine. The code is bare bones too. After the coversion to MAC, no file is created. The program continues to function.
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
It is very difficult to debug on MAC because you have to run compiled code.
no, if you have them on the same lan then use b4j bridge.
 
Upvote 0

gregchao

Member
Licensed User
Longtime User
I was able to get some clues through java error code when I try to run on the mac. When I try to run the following code:

B4X:
Dim wd As WordUtils
wd.Initialize
Dim doc As WordDocument = wd.CreateDocument
'doc.Append($"[p]Word document with two lines. This is the second line.[/p]"$)
Dim ff As String = doc.SaveAs(MainPg.outputpath, MainPg.outputbasename & ".docx", True)

I get the following error which seems to indicate that there is a problem with "wd.CreateDocument". Any help would be appreciated.

B4X:
Diagnostic XML Bean debug log file created: /var/folders/lw/hzlx04kx1430kh11qbh95kcr0000gn/T/xmlbeandebug10945634728781600448.log
wordutils._createdocument (java line: -1)
java.lang.ExceptionInInitializerError
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Unknown Source)
    at b4j/org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl.build(Unknown Source)
    at b4j/org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.<init>(Unknown Source)
    at b4j/org.apache.xmlbeans.metadata.system.sXMLSCHEMA.TypeSystemHolder.<init>(Unknown Source)
    at b4j/org.apache.xmlbeans.metadata.system.sXMLSCHEMA.TypeSystemHolder.<clinit>(Unknown Source)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Unknown Source)
    at b4j/org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl.build(Unknown Source)
    at b4j/org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.<init>(Unknown Source)
    at b4j/org.apache.xmlbeans.metadata.system.sXMLLANG.TypeSystemHolder.<init>(Unknown Source)
    at b4j/org.apache.xmlbeans.metadata.system.sXMLLANG.TypeSystemHolder.<clinit>(Unknown Source)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Unknown Source)
    at b4j/org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl.build(Unknown Source)
    at b4j/org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.<init>(Unknown Source)
    at b4j/org.apache.xmlbeans.metadata.system.sXMLCONFIG.TypeSystemHolder.<init>(Unknown Source)
    at b4j/org.apache.xmlbeans.metadata.system.sXMLCONFIG.TypeSystemHolder.<clinit>(Unknown Source)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Unknown Source)
    at b4j/org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl.build(Unknown Source)
    at b4j/org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.<init>(Unknown Source)
    at b4j/org.apache.poi.schemas.ooxml.system.ooxml.TypeSystemHolder.<init>(Unknown Source)
    at b4j/org.apache.poi.schemas.ooxml.system.ooxml.TypeSystemHolder.<clinit>(Unknown Source)
    at b4j/org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocument1$Factory.getTypeLoader(Unknown Source)
    at b4j/org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocument1$Factory.newInstance(Unknown Source)
    at b4j/org.apache.poi.xwpf.usermodel.XWPFDocument.onDocumentCreate(Unknown Source)
    at b4j/org.apache.poi.xwpf.usermodel.XWPFDocument.<init>(Unknown Source)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Unknown Source)
    at java.base/java.lang.reflect.ReflectAccess.newInstance(Unknown Source)
    at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(Unknown Source)
    at java.base/java.lang.Class.newInstance(Unknown Source)
    at b4j/anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(Unknown Source)
    at b4j/b4j.example.wordutils._createdocument(Unknown Source)
    at b4j/b4j.example.print$ResumableSub_B4xpage_Appear.resume(Unknown Source)
    at b4j/b4j.example.print._b4xpage_appear(Unknown Source)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
    at b4j/anywheresoftware.b4a.keywords.Common.CallSub4(Unknown Source)
    at b4j/anywheresoftware.b4a.keywords.Common.access$0(Unknown Source)
    at b4j/anywheresoftware.b4a.keywords.Common$CallSubDelayedHelper.run(Unknown Source)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Unknown Source)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
Caused by: org.apache.xmlbeans.SchemaTypeLoaderException: XML-BEANS compiled schema: Could not locate compiled schema resource org/apache/xmlbeans/metadata/system/sXMLTOOLS/index.xsb (org.apache.xmlbeans.metadata.system.sXMLTOOLS.index) - code 0
    at b4j/org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl$XsbReader.<init>(Unknown Source)
    at b4j/org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.initFromHeader(Unknown Source)
    at b4j/org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.<init>(Unknown Source)
    at b4j/org.apache.xmlbeans.metadata.system.sXMLTOOLS.TypeSystemHolder.<init>(Unknown Source)
    at b4j/org.apache.xmlbeans.metadata.system.sXMLTOOLS.TypeSystemHolder.<clinit>(Unknown Source)
    ... 51 more
 
Upvote 0

gregchao

Member
Licensed User
Longtime User
I actually tried two ways:

1. I tried to get b4j-bridge working. I put jdk-14.0.2.jdk in /libray/java/javaVirtualMachine but I did not know what to do with javafx folders. I tried putting the javafx folders in the same directory. I got the b4j-bridge working but when I ran my program, I got the error:

Error: JavaFX runtime components are missing, and are required to run this application

At that point, I abandoned that approach.

2. Next, I tried using the MacSigner. The error code was generated after I hit the "Link" button and running it using "run.command"
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
e but I did not know what to do with javafx folders
you are mixing a lot of stuff and hinders our ability to help you.

if you want to use b4j bridge then download the jdk from here:

if you want to do it with the macSigner then follow the instructions here:
where clearly says what to do with the javafx folder.
 
Upvote 0

gregchao

Member
Licensed User
Longtime User
I think I did the MacSigner process correctly and the last post still is valid.

I downloaded the jdk from the B4jpackager11 and tried to put it /library/java/javaVirtualMachine but I get the error: "jdk-14.1.1" is damaged and can't be opened. when I try to run java from the terminal. There must be a more complicated process to installing the JDK that I do not know about.
 
Upvote 0

gregchao

Member
Licensed User
Longtime User
Yea!!! Got B4j-Bridge working on my MAC!!!

1. Installed JDK - Downloaded Java 14 as recommended above. Double clicked on .tar file. Then, moved the three programs to Computer/MAC SSHD/library/java/javaVirtualMachine. This effectively installed JDK on my MAC

2. Ran B4j-bridge - Opened Terminal. "cd" to b4j-bridge.jar location. Ran "java -jar -b4j-bridge.jar"

3. Ran B4j - Connected to bridge in B4j. Ran program. Code to create MS Word is now working great.

Erel, Thank you for your patience. Enrique, thank you for suggesting B4j-bridge.
 
Upvote 0
Top