B4J Question [Solved] ABMaterial cannot access collections.Map when running jar

swChef

Active Member
Licensed User
Longtime User
I followed this post to try out the ABMaterial sample, which worked fine.
My goal is to try it on a VPS, which would need to be able to launch the jar.

As the next step in the process I tried running the Template.jar on the command line (locally), but it gave error:
java error 1:
Exception in thread "main" java.lang.IllegalAccessError: class com.ab.template.main (in unnamed module @0x17ed40e0) cannot access class anywheresoftware.b4a.StandardBA (in module b4j) because module b4j does not export anywheresoftware.b4a to unnamed module @0x17ed40e0

Resolved that by adding --add-opens as in:
Add Opens:
java -cp Template.jar --add-opens b4j/anywheresoftware.b4a=ALL-UNNAMED  --add-opens b4j/anywheresoftware.b4a.keywords=ALL-UNNAMED com.ab.template.main
where the project package is com.ab.template.

Then it gave error:
Java Error 2:
java.lang.IllegalAccessError: class com.ab.abmaterial.ABMaterial (in unnamed module @0x3498ed) cannot access class anywheresoftware.b4a.objects.collections.Map (in module b4j) because module b4j does not export anywheresoftware.b4a.objects.collections to unnamed module @0x3498ed
        at com.ab.abmaterial.ABMaterial.<clinit>(ABMaterial.java:192)
        at com.ab.template.main._process_globals(main.java:193)
        at com.ab.template.main.initializeProcessGlobals(main.java:179)
        at com.ab.template.main.main(main.java:27)

... and I've been unable to get past that.

Is there a solution? I did try #AdditionalJar on ABMaterial.jar, and some guesses involving #PackagerProperty, VMArgs, and even adding JCore.jar as an AdditionalJar without success.
 

swChef

Active Member
Licensed User
Longtime User
Nevermind. I'm using jdk-14.0.1. The java.exe in C:\Program Files\Java\jdk-14.0.1\bin\ runs the .jar, and was used to compile the project. But there was one in [a different project]\Objects\temp\build\bin that was being used to command-line run the jar and gave the errors. It is also 14.0.1, but has the following difference reported by -version
works: OpenJDK 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)
doesn't: OpenJDK 64-Bit Server VM (build 14.0.1+7, mixed mode)
The latter one shows as modified in Sep of the same year but otherwise the properties including creation time are the same as the other in May of that year (2020).
Solved.
 
Upvote 0
Top