B4J Question NoClassDefFoundError ??

rspitzer

Active Member
When I run my program via the B4X bridge, to my linux station, the program runs well, no issues.

When I run the stand alone packager and then copy the jar file to the linux system I am using, and run it, I get the Following error:

NoClassDefefFoundError:
cip._display_cip_picture (java line: 2091)
java.lang.NoClassDefFoundError: javafx/embed/swing/SwingFXUtils
    at anywheresoftware.b4j.objects.ImageViewWrapper$ImageWrapper.WriteToStream(ImageViewWrapper.java:199)
    at anywheresoftware.b4a.objects.B4XViewWrapper$B4XBitmapWrapper.WriteToStream(B4XViewWrapper.java:817)
    at b4j.serialtest.cip._display_cip_picture(cip.java:2091)
    at b4j.serialtest.cip$ResumableSub_Canvas4_MouseReleased.resume(cip.java:1243)
    at b4j.serialtest.cip._canvas4_mousereleased(cip.java:1141)
    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:109)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:96)
    at anywheresoftware.b4j.objects.NodeWrapper$3.handle(NodeWrapper.java:131)
    at anywheresoftware.b4j.objects.NodeWrapper$3.handle(NodeWrapper.java:1)
    at javafx.base@18-ea/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    at javafx.base@18-ea/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
    at javafx.base@18-ea/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at javafx.base@18-ea/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at javafx.base@18-ea/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at javafx.base@18-ea/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base@18-ea/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at javafx.base@18-ea/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base@18-ea/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at javafx.base@18-ea/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base@18-ea/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at javafx.base@18-ea/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.base@18-ea/javafx.event.Event.fireEvent(Event.java:198)
    at javafx.graphics@18-ea/javafx.scene.Scene$MouseHandler.process(Scene.java:3881)
    at javafx.graphics@18-ea/javafx.scene.Scene.processMouseEvent(Scene.java:1874)
    at javafx.graphics@18-ea/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2607)
    at javafx.graphics@18-ea/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:411)
    at javafx.graphics@18-ea/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:301)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics@18-ea/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:450)
    at javafx.graphics@18-ea/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:424)
    at javafx.graphics@18-ea/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:449)
    at javafx.graphics@18-ea/com.sun.glass.ui.View.handleMouseEvent(View.java:551)
    at javafx.graphics@18-ea/com.sun.glass.ui.View.notifyMouse(View.java:937)
    at javafx.graphics@18-ea/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at javafx.graphics@18-ea/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:316)
    at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.ClassNotFoundException: javafx.embed.swing.SwingFXUtils
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    ... 40 more

Can someone point me in a direction to solve this issue?
 

rspitzer

Active Member
I may not understand your answer. I apologize in advance.
When I run the program in bridge mode, the jar file runs perfectly.
Under the Project drop down menu, I choose Build Standalone Package. I assume the difference here is that this compilation does not contain the debug code for running the program using the Bridge. I then copy the new jar file to my Linux desktop home directory, and run the typical java -jar command line from the terminal mode. Same as I do to run the bridge. So what am I missing or doing wrong here?
You mentioned that this creates a "Full Package", but I assumed that this "Full Package" is for windows based systems, and I just need the jar file itself. Do I need to copy more files to my Linux Desktop? In past programs, I have not needed to do this, they used JavaFX and I assume some utilities in Swing, but now this does not work.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Simply run the app in release mode. It will create a single jar with everything needed.
2. The standalone packager creates a "package" made of many files. The advantage of this package is that it includes the required Java components.
3. You can use the external packager to create Linux packages but you don't need it for your use case.
 
Upvote 0
Top