B4J Question Java 11 problem

ThRuST

Well-Known Member
Licensed User
Longtime User
Hi! I'm trying to get my project to work with Java 11 downloaded from the B4X website and this is showing in the log as the app refuse to run

(IllegalAccessException) 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 @334541d6
main._appstart (java line: 5253)
java.lang.ClassCastException: class java.lang.ExceptionInInitializerError cannot be cast to class java.lang.Exception (java.lang.ExceptionInInitializerError and java.lang.Exception are in module java.base of loader 'bootstrap')
at anywheresoftware.b4a.BA.setLastException(BA.java:399)
at DS.AthenaLitePro.main._appstart(main.java:5253)
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:111)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
at DS.AthenaLitePro.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)

Any clues what this is all about?
 

agraham

Expert
Licensed User
Longtime User
You seem to have JavaObject code that is trying to access a non-public Java method that is not exported for general use. I guess it worked on Java 8 but if I remember correctly Java 11 tightened up use of undocumented public APIs. by not exporting their symbols.

It looks like it is in, or called by, your Sub Main.AppStart.
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
@agraham Thanks. that's correct I'm trying to upgrade from Oracle Java 8 to OpenJava 11. I am using the Java11 folder that I downloaded from B4X site.
I will have to trace it like you say in the initialization process at Main.AppStart. It should be useful to locate what's causing it since many might upgrade from Java 8 to 11.

So far I have tried this:
code:
#VirtualMachineArgs: --add-opens javafx.graphics/com.sun.glass.ui=ALL-UNNAMED

Log showed

Also this instead of the previous line
code:
#VirtualMachineArgs: --add-exports javafx.graphics/com.sun.glass.ui=ALL-UNNAMED

Log showed

Without these previous I've traced the error being caught here (from Main.AppStart)
code:
Try
    
            initRobot
    
            Public dims() As Int = AWTRobot.ScreenGetDimensions
            ScreenWidth  = dims(0)
            ScreenHeight = dims(1)
    
        Catch
            Log(LastException)
            xui.MsgboxAsync("Screen initialization failed: " & LastException, "")
        End Try


Sub initRobot
    robot = temp.InitializeStatic("com.sun.glass.ui.Application").RunMethodJO("GetApplication",Null).RunMethodJO("createRobot",Null)
End Sub
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
I disabled InitRobot since it didn't seem relevant to use with the AWTRobot library.

Log shows
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Since the line 5251 shows up in the log here's what's in it



There's about 100 sound files being initialized to be used by Mediaplayer.
Not sure if this is relevant to the error in the log. I might be chasing ghosts here.

Edit:
Here's the code for playing an mp3 file
mp3:
Sub PlaySND_Filemanager
  
    If Main.ToggleCheckbox5 = True Then
          
        MP3playSnd_Filemanager.Stop
        MP3playSnd_Filemanager.Position = 0
        MP3playSnd_Filemanager.Play
      
    End If
  
End Sub

ToggleCheckbox5 is related to the floating menu settings menu. There's many modules in that by Stevel05.
This might be just as hard as finding a needle in a haystack. Perhaps I should stay with Oracle Java 8 in this project!!
 
Last edited:
Upvote 0

agraham

Expert
Licensed User
Longtime User
It's the line number in the Java appstart method in Main.java you need, not in your B4J code. Find it under the Objects/src/... folder.

Something is throwing an ExceptionInInitializerError that can't be set as the B4J LastException because it has a different inheritance hierarchy.
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
@agraham I had no clue about this.

Here's the list of files in object/src folder
what should I do with this?


designerscripts folder is empty
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…