swChef Active Member Licensed User Longtime User Sep 17, 2023 #1 I reproduced the problem I have in a minimal project. Create a new default B4XPage app, and change Button1_Click as follows: B4X: Copy Private Sub Button1_Click xui.MsgboxAsync("Hello world!", "B4X " & TryThisInstead) End Sub Sub TryThisInstead As String Dim jo As JavaObject Log("initializing MF") jo=jo.InitializeStatic("java.lang.management.ManagementFactory") Return "" End Sub This is a stripped down test. In my (larger) application, and when creating this minimal app, it is the first step, followed by getRuntimeMXBean, then getName, to get the PID. This is failing after Build Standalone Package trying to run the .exe (in this example, upon clicking the button), but works when run from the IDE. I've been using jdk 14 and also tried 11, same issue. I'm guessing there is perhaps a dll or additional jar to include, but haven't discovered that yet. Has someone run across this and has the solution? run_debug.bat shows the error while running the built .exe. B4X: Copy initializing MF b4xmainpage._trythisinstead (java line: -1) java.lang.ClassNotFoundException: java$lang$management$ManagementFactory at b4j/anywheresoftware.b4j.object.JavaObject.getCorrectClassName(Unknown Source) at b4j/anywheresoftware.b4j.object.JavaObject.InitializeStatic(Unknown Source) at b4j/b4j.example.b4xmainpage._trythisinstead(Unknown Source)
I reproduced the problem I have in a minimal project. Create a new default B4XPage app, and change Button1_Click as follows: B4X: Copy Private Sub Button1_Click xui.MsgboxAsync("Hello world!", "B4X " & TryThisInstead) End Sub Sub TryThisInstead As String Dim jo As JavaObject Log("initializing MF") jo=jo.InitializeStatic("java.lang.management.ManagementFactory") Return "" End Sub This is a stripped down test. In my (larger) application, and when creating this minimal app, it is the first step, followed by getRuntimeMXBean, then getName, to get the PID. This is failing after Build Standalone Package trying to run the .exe (in this example, upon clicking the button), but works when run from the IDE. I've been using jdk 14 and also tried 11, same issue. I'm guessing there is perhaps a dll or additional jar to include, but haven't discovered that yet. Has someone run across this and has the solution? run_debug.bat shows the error while running the built .exe. B4X: Copy initializing MF b4xmainpage._trythisinstead (java line: -1) java.lang.ClassNotFoundException: java$lang$management$ManagementFactory at b4j/anywheresoftware.b4j.object.JavaObject.getCorrectClassName(Unknown Source) at b4j/anywheresoftware.b4j.object.JavaObject.InitializeStatic(Unknown Source) at b4j/b4j.example.b4xmainpage._trythisinstead(Unknown Source)
EnriqueGonzalez Expert Licensed User Longtime User Sep 17, 2023 #2 sounds like an issue of the packager: Integrated B4JPackager11 - The simple way to distribute standalone UI apps B4JPackager11 is a utility written in B4J that uses the underlying Java tools to create a standalone package that doesn't depend on any other software being installed. It works with OpenJDK 11 and OpenJDK 14. Starting from B4J v8.30 it is integrated in the IDE and available under Project - Build... www.b4x.com try with packagerProperty: include = java.lang.management Upvote 0
sounds like an issue of the packager: Integrated B4JPackager11 - The simple way to distribute standalone UI apps B4JPackager11 is a utility written in B4J that uses the underlying Java tools to create a standalone package that doesn't depend on any other software being installed. It works with OpenJDK 11 and OpenJDK 14. Starting from B4J v8.30 it is integrated in the IDE and available under Project - Build... www.b4x.com try with packagerProperty: include = java.lang.management
Daestrum Expert Licensed User Longtime User Sep 17, 2023 #3 Add this to project attributes region ( you may not need the second line if you don't need remote connect ) Code: Copy #PackagerProperty: IncludedModules=java.management #PackagerProperty: IncludedModules=java.management.rmi Upvote 0
Add this to project attributes region ( you may not need the second line if you don't need remote connect ) Code: Copy #PackagerProperty: IncludedModules=java.management #PackagerProperty: IncludedModules=java.management.rmi
swChef Active Member Licensed User Longtime User Sep 17, 2023 #4 Daestrum said: Add this to project attributes region ( you may not need the second line if you don't need remote connect ) Code: Copy #PackagerProperty: IncludedModules=java.management #PackagerProperty: IncludedModules=java.management.rmi Click to expand... Thank you for the info. Using that to search I found another thread on this topic. Not sure how I didn't find that yesterday, other than the typos and '.lang.' included in my search. The thread has some information on how to determine the module to include. https://www.b4x.com/android/forum/threads/solved-missing-java-class-in-a-packaged-exe.118705/?amp=1 Upvote 0
Daestrum said: Add this to project attributes region ( you may not need the second line if you don't need remote connect ) Code: Copy #PackagerProperty: IncludedModules=java.management #PackagerProperty: IncludedModules=java.management.rmi Click to expand... Thank you for the info. Using that to search I found another thread on this topic. Not sure how I didn't find that yesterday, other than the typos and '.lang.' included in my search. The thread has some information on how to determine the module to include. https://www.b4x.com/android/forum/threads/solved-missing-java-class-in-a-packaged-exe.118705/?amp=1