Reputation: 463
I am building a desktop JavaFX 2.0 application that needs to interact with a card reader over the serial port. So I am using the RxTx library version 2.1-7r2 32bit.
To do some initial testing/learning I built out the RxTx functionality in a java console app and got that working great, by following the instructions to copy over the native DLLs and the jar file into my various 32bit JDK version jdk1.7.0_04 directories.
I then created a JavaFX app with a primitive UI and started to migrate the RxTx code over to this new project. This JavaFX app is pointing at the same 32bit JDK that I used for my console app.
The JavaFX app locates the jar file perfectly as I can import gnu.io.* and then write code that is correctly recognized by NetBeans, as well as JavaDocs, autocomplete etc. Unfortunately on execution it returns the following errors, which look suspiciously like the native DLLs aren't being located:
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.javafx.main.Main.launchApp(Main.java:486)
at com.javafx.main.Main.main(Main.java:638)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
at com.sun.javafx.application.LauncherImpl.access$000(Unknown Source)
at com.sun.javafx.application.LauncherImpl$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NoClassDefFoundError: gnu/io/CommPortIdentifier
at testfxscreens.TestFXScreens.setupSerialPort(TestFXScreens.java:186)
at testfxscreens.TestFXScreens.start(TestFXScreens.java:61)
at com.sun.javafx.application.LauncherImpl$5.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl$4.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl$3.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(Unknown Source)
at com.sun.glass.ui.win.WinApplication$2$1.run(Unknown Source)
... 1 more
Caused by: java.lang.ClassNotFoundException: gnu.io.CommPortIdentifier
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 9 more
I looked at the RxTx homepage and found an example solution to the above error, but it simply mentions that you likely don't have the DLLs and JAR files in your JDK correctly.
This is really odd as I'm able to get the console app, using the same JDK directories, working perfectly. I'm hoping I'm doing something really obviously wrong, but I haven't fiddled with the project settings to make me think I've messed anything up.
Are there any JavaFX 2.0 specific project settings to make RxTx work?
Any pointers on where to look to hunt this down, greatly appreciated!!!
Upvotes: 0
Views: 702
Reputation: 842
Andre, I'm porting a java Swing app, that use the RXTX library working fine, to a new JavaFX app, no compile issues but the same error in runtime. The solution: locate the library in your HD(in my case /system/library/java/Extensions/RXTXComm.jar), open the project properties pannel, go to libraries, select the button option Compile and click Add Jar/Folder, add the RXTXComm.jar to the list.
Upvotes: 2