I'd be grateful for help with this issue.
I'm using Jackcess to read a .MDB database in B4J on a Windows 10 PC (64-b20H2 with Java JDK11.0.1 and Java 8 Update 271)
The program works perfectly when run from the B4J UI (in either debug or release mode) provided I include a "#AdditionalJar: commons-logging-1.1.3" statement in Main (btw also needed when using Jackcess in B4A).
But when I build a standalone package the .EXE crashes with an error message that begins "java.lang.ExceptionInInitializerError" (full text below). The form is displayed and MsgBox "1" appears, but when it's dismissed the program then fails so it's the Access.Open statement (ie the invocation of Jackcess) that's causing the problem (MsgBox "2" doesn't appear).
My code is:
I've attached a zip containing the program and another containing the database so you can test if you want to.
Again, huge thanks for any help you can give.
I'm using Jackcess to read a .MDB database in B4J on a Windows 10 PC (64-b20H2 with Java JDK11.0.1 and Java 8 Update 271)
The program works perfectly when run from the B4J UI (in either debug or release mode) provided I include a "#AdditionalJar: commons-logging-1.1.3" statement in Main (btw also needed when using Jackcess in B4A).
But when I build a standalone package the .EXE crashes with an error message that begins "java.lang.ExceptionInInitializerError" (full text below). The form is displayed and MsgBox "1" appears, but when it's dismissed the program then fails so it's the Access.Open statement (ie the invocation of Jackcess) that's causing the problem (MsgBox "2" doesn't appear).
My code is:
Test program which opens and reads MS Access DB on Windows 10 PC:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Public Const PLDir As String = "D:\New Folder" ' Hardcoded just for demo program
Public const PLFile As String="COVID-19.mdb"
Public Access As JackcessDatabase
Public ACTable As JackcessTable
Public ACIndex As JackcessIndex
End Sub
Public Sub Initialize
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
xui.MsgboxAsync("1 " & PLDir & "\" & PLFile & CRLF & File.Exists(PLDir,PLFile),"Test")
Wait for msgbox_result
Access.open(PLDir & "\" & PLFile)
xui.MsgboxAsync("2 DB " & PLFile & " opened","Test")
Wait for msgbox_result
ACTable.Initialize(Access.GetTable("Electoral_Roll"))
ACIndex.Initialize(ACTable.GetIndex("Android"))
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Sub Button1_Click
xui.MsgboxAsync("3 " & NumberFormat(ACTable.GetRowCount,1,0) & " Members","Test")
wait for msgbox_result
ExitApplication
End Sub
From Main module:
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#AdditionalJar: commons-logging-1.1.3
#End Region
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
b4xmainpage$ResumableSub_B4XPage_Created.resume (java line: -1)
java.lang.ExceptionInInitializerError
at b4j/com.healthmarketscience.jackcess.GeneralLegacyIndexCodes.getCharHandler(Unknown Source)
at b4j/com.healthmarketscience.jackcess.GeneralLegacyIndexCodes.writeNonNullIndexTextValue(Unknown Source)
at b4j/com.healthmarketscience.jackcess.IndexData$GenLegTextColumnDescriptor.writeNonNullValue(Unknown Source)
at b4j/com.healthmarketscience.jackcess.IndexData$ColumnDescriptor.writeValue(Unknown Source)
at b4j/com.healthmarketscience.jackcess.IndexData.createEntryBytes(Unknown Source)
at b4j/com.healthmarketscience.jackcess.IndexData.access$3000(Unknown Source)
at b4j/com.healthmarketscience.jackcess.IndexData$EntryCursor.beforeEntry(Unknown Source)
at b4j/com.healthmarketscience.jackcess.IndexCursor.findPotentialRow(Unknown Source)
at b4j/com.healthmarketscience.jackcess.IndexCursor.findFirstRowByEntryImpl(Unknown Source)
at b4j/com.healthmarketscience.jackcess.IndexCursor.findFirstRowByEntry(Unknown Source)
at b4j/com.healthmarketscience.jackcess.Database$DefaultTableFinder.findRow(Unknown Source)
at b4j/com.healthmarketscience.jackcess.Database$TableFinder.findObjectId(Unknown Source)
at b4j/com.healthmarketscience.jackcess.Database.readSystemCatalog(Unknown Source)
at b4j/com.healthmarketscience.jackcess.Database.<init>(Unknown Source)
at b4j/com.healthmarketscience.jackcess.Database.open(Unknown Source)
at b4j/com.healthmarketscience.jackcess.Database.open(Unknown Source)
at b4j/com.healthmarketscience.jackcess.Database.open(Unknown Source)
at b4j/com.healthmarketscience.jackcess.Database.open(Unknown Source)
at b4j/com.healthmarketscience.jackcess.Database.open(Unknown Source)
at b4j/com.healthmarketscience.jackcess.Database.open(Unknown Source)
at b4j/anywheresoftware.b4a.objects.JackcessDatabase.Open(Unknown Source)
at b4j/b4j.example.b4xmainpage$ResumableSub_B4XPage_Created.resume(Unknown Source)
at b4j/anywheresoftware.b4a.BA.checkAndRunWaitForEvent(Unknown Source)
at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
at b4j/anywheresoftware.b4a.BA$1.run(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
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)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: failed loading index codes file com/healthmarketscience/jackcess/index_codes_genl
eg.txt
at b4j/com.healthmarketscience.jackcess.GeneralLegacyIndexCodes.loadCodes(Unknown Source)
at b4j/com.healthmarketscience.jackcess.GeneralLegacyIndexCodes$Codes.<clinit>(Unknown Source)
... 32 more
Caused by: java.io.IOException: Could not load jackcess resource com/healthmarketscience/jackcess/index_codes_genleg.txt
at b4j/com.healthmarketscience.jackcess.Database.getResourceAsStream(Unknown Source)
... 34 more
C:\Users\xxxxxxxxxxxx\Dropbox\Documents\B4J\Projects\test\B4J\Objects\temp\build\bin>pause
Press any key to continue . . .
I've attached a zip containing the program and another containing the database so you can test if you want to.
Again, huge thanks for any help you can give.