I created an example.
It works in Debug and Release but if I call the jar in command prompt, I get errors.
If I add the extra parameters, it runs.
Create and Read PKCS12 Keystore
'Non-UI application (console / server application) #Region Project Attributes #CommandLineArgs: #MergeLibraries: True #End Region #VirtualMachineArgs: --add-exports java.base/sun.security.x509=ALL-UNNAMED #PackagerProperty: VMArgs = --add-opens java.base/sun.security.x509=b4j Sub...
www.b4x.com
It works in Debug and Release but if I call the jar in command prompt, I get errors.
B4X:
C:\Users\aeric\Desktop\readp12\Objects>C:\Java\jdk-19.0.2\bin\java -jar readp12.jar MyPassword ../Objects/keystore.p12
Creating ../Objects/keystore.p12...
Success
Reading ../Objects/keystore.p12...
Alias: b4x
main._appstart (java line: 53)
java.lang.RuntimeException: java.lang.IllegalAccessException: class anywheresoftware.b4j.object.JavaObject cannot access class sun.security.x509.X509CertImpl (in module java.base) because module java.base does not export sun.security.x509 to unnamed module @5ae9a829
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:140)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
at anywheresoftware.b4a.keywords.Common$3.run(Common.java:1118)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:47)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:43)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:180)
at b4j.example.main._appstart(main.java:53)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
at b4j.example.main.main(main.java:28)
Caused by: java.lang.IllegalAccessException: class anywheresoftware.b4j.object.JavaObject cannot access class sun.security.x509.X509CertImpl (in module java.base) because module java.base does not export sun.security.x509 to unnamed module @5ae9a829
at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:420)
at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:709)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
at b4j.example.main._readcert(main.java:224)
at b4j.example.main$ResumableSub_CheckCert.resume(main.java:129)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:156)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
... 11 more
C:\Users\aeric\Desktop\readp12\Objects>
If I add the extra parameters, it runs.
B4X:
C:\Users\aeric\Desktop\readp12\Objects>C:\Java\jdk-19.0.2\bin\java --add-opens java.base/sun.security.x509=ALL-UNNAMED --add-exports java.base/sun.security.x509=ALL-UNNAMED -jar readp12.jar MyPassword ../Objects/keystore.p12
Creating ../Objects/keystore.p12...
Success
Reading ../Objects/keystore.p12...
Alias: b4x
Serial Number: 13353879566025462026
C:\Users\aeric\Desktop\readp12\Objects>