B4J Question Resolved: IllegalAccessException

BeneBarros

Active Member
Licensed User
Longtime User
I had to format my pc.
I reinstalled everything again.
Now on B4J I get this error.

tballoon._initialize (java line: 459)
java.lang.IllegalAccessException: class anywheresoftware.b4j.object.JavaObject cannot access class com.sun.glass.ui.Application (in module javafx.graphics) because module javafx.graphics does not export com.sun.glass.ui to unnamed module @7564b97b
at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:361)
at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:591)
at java.base/java.lang.reflect.Method.invoke(Method.java:558)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
at anywheresoftware.b4j.object.JavaObject.RunMethodJO(JavaObject.java:139)
at b4j.example.tballoon._initialize(tballoon.java:459)
at b4j.example.main._appstart(main.java:126)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at b4j.example.main.start(main.java:37)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)


error only in release mode.
in debug mode it works.

Can someone help me
 
Last edited:

BeneBarros

Active Member
Licensed User
Longtime User
Can you post the code that causes the error (Initialize sub of TBaloon)?
the error occurs when you compile the Reflector or Javaobject.
I've removed tBaloon now the same error in utils.Init
B4X:
Public Sub Init
    DApp = GetCanonicalPath (File.DirApp)
    Private jo As JavaObject
    jo.InitializeStatic ("com.sun.glass.ui.Application")
    robot = jo.RunMethodJO ("GetApplication", Null) .RunMethodJO ("createRobot", Null)
End Sub

B4X:
tBaloon 
Public Sub Initialize(prt As Pane)
    Showing = False
    Parent = prt
    imIndicator.Initialize("")
    frBalloon.Initialize("frBalloon", 180, 102)
    frBalloon.SetFormStyle("TRANSPARENT")
    frBalloon.BackColor = fx.Colors.transparent
    frBalloon.RootPane.Style = "-fx-background-color: transparent;"
    lbMsg.Initialize("")
    lbMsg.WrapText = True
    lbMsg.Font  = fx.CreateFont("Arial Narrow", 14, True, True)
    lbMsg.TextColor=fx.Colors.RGB(14,16,106) 
    lbTitle.Initialize("")
    lbTitle.Font  = fx.CreateFont("Arial Narrow", 16, True, False)
    lbTitle.TextColor=fx.Colors.White   
    base.Initialize("")
    Shdw = "-fx-effect: dropshadow( three-pass-box, rgba(0,0,0,0.6), 5, 0.0, 5, 5);"   
    base.Style = "-fx-background-color: #fdffc7;" & _
                "-fx-border-color: black;" & Shdw
    frBalloon.RootPane.AddNode(base, 10, 10, 10, 10)
    Dim Obj As Reflector
    Obj.Target = frBalloon.RootPane 
    Obj.AddEventHandler2("RPKeyPressed", "onKeyPressedProperty")   
    Private jo As JavaObject
      jo.InitializeStatic("com.sun.glass.ui.Application")
      robot = jo.RunMethodJO("GetApplication",Null).RunMethodJO("createRobot",Null)                               
End Sub
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This error is related to a new requirement in Java 11.

You can add this line to get it running in the IDE in release mode:
B4X:
#VirtualMachineArgs: --add-opens javafx.graphics/com.sun.glass.ui=ALL-UNNAMED

You will need to make a similar change to release_java_modules.txt in B4JPackager11 when you want to build an installer for the app.
 
Last edited:
Upvote 0

BeneBarros

Active Member
Licensed User
Longtime User
This error is related to a new required in Java 11.

You can add this line to get it running in the IDE in release mode:
B4X:
#VirtualMachineArgs: --add-opens javafx.graphics/com.sun.glass.ui=ALL-UNNAMED

You will need to make a similar change to release_java_modules.txt in B4JPackager11 when you want to build an installer for the app.

Unrecognized option: --add
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
 
Upvote 0

BeneBarros

Active Member
Licensed User
Longtime User
[QUOTE = "Erel, post: 659524, member: 1"] Você está usando o Java 11? Você está usando o B4J-Bridge?
Funcionou aqui. [/ QUOTE]


I am not using the B4J-Bridge
 

Attachments

  • Sem Título-2.png
    Sem Título-2.png
    7.9 KB · Views: 367
Upvote 0

BeneBarros

Active Member
Licensed User
Longtime User
I've reinstalled everything without success.

Is there any way to download the old SDK

Resolved: I reinstalled the SDK for the second option on the site.
 
Last edited:
Upvote 0
Top