B4J Question help #VirtualMachineArgs and standalone package

fernando1987

Active Member
Licensed User
I have a program that relies on simulating key presses, and I am using the following VirtualMachineArgs configuration:


#VirtualMachineArgs: --add-opens javafx.graphics/com.sun.glass.ui=ALL-UNNAMED

While everything works smoothly in the development environment, the issue arises when I compile the program as a standalone package using the recommended JDK 11. It appears that the #VirtualMachineArgs configuration does not get carried over to the final package. Is this expected behavior?
 

Daestrum

Expert
Licensed User
Longtime User
#PackagerProperty possibly?
 
Upvote 0

fernando1987

Active Member
Licensed User
este es el cdigo que deseo usar y estoy trabajando con OpenJDK 19.0.2 + OpenJFX 17.0.6

B4X:
Sub ENTER_PRESS
    
    
    Dim robot1 As JavaObject
    Dim jo1 As JavaObject
    Dim keycodes As JavaObject
    keycodes.InitializeStatic("javafx.scene.input.KeyCode")
    jo1.InitializeStatic("com.sun.glass.ui.Application")
    robot1 = jo1.RunMethodJO("GetApplication",Null).RunMethodJO("createRobot",Null)


    ' you have to think how you would type the characters
    robot1.RunMethod("keyPress", Array(keycodes.GetField("ENTER")))
    robot1.RunMethod("keyRelease", Array(keycodes.GetField("ENTER")))
End Sub
 
Upvote 0

fernando1987

Active Member
Licensed User
1. Publique el mensaje de error completo de run_debug.bat

2. Hay una API más nueva que lo solucionará: https://www.b4x.com/android/forum/threads/mouse-move-and-click-in-ide-ok-after-compiling-java-11- nok.124005/post-776666

Thanks erel solution 2 was the answer now it works correctly in case anyone else has a similar problem these are the changes I made add

#PackagerProperty: VMArgs = --add-opens javafx.graphics/com.sun.javafx.tk=ALL- UNNAMED

and change the code to the following

B4X:
Sub ENTER_PRESS
    
    
    Dim robot1 As JavaObject
    Dim keycodes As JavaObject

    keycodes.InitializeStatic("javafx.scene.input.KeyCode")

    robot1.InitializeNewInstance("javafx.scene.robot.Robot", Null)

    

    robot1.RunMethod("keyPress", Array(keycodes.GetField("ENTER")))
    robot1.RunMethod("keyRelease", Array(keycodes.GetField("ENTER")))
End Sub
 
Upvote 0
Top