I have a pci-modem in my laptop and I tried to run a program that opens the port and configures it.I get an excepcion while doing it, I think that it can't see the port, even though it is on COM3. Is there any way of doing it in java?
The error I get is noClassDefFoundError. It says the SerialPortEventListener class isn't found. I'm using rxtxcomm. I tried using javax.comm but it doesn't find the port either.
Thanks a lot
A NoClassDefFoundError indicates that you're missing a JAR file from your classpath, specifically the one that is holding SerialPortEventListener class. Check your classpath.
Have you followed the installation instructions for rxtxcomm ? Note you have to handle a library and a jar file. You need to specify a system library path for the native component.
You may find that you get the 'no class def found' if the appropriate .jar is found, but it can't find the corresponding native library to load.
Related
In my app, I am adding third party hardware connectivity and using their provided code for java. Also using jna.jar to interact with that code as it uses native library to load some .so files. It throws the error:
java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/android-arm/libjnidispatch.so) not found in resource path (.) Please help where can I get the jar with android-arm/libjnidispatch.so in it.`
I tried adding android-arm.jar which is having libjnidispatch.so separately but compiler is looking for jna.jar's path. Thanks!
Extract the com/sun/jna/linux-arm/libjnidispatch.so from the jar file
put the .so file in the following directory (when using android studio): yourproject\app\src\main\jniLibs\armeabi-v7a\libjnidispatch.so
And also please note that linux architecture != android architecture (google uses a different c library (bionic), which is a different one than the normal linux distributions)
For all architectures see:
https://github.com/java-native-access/jna/tree/master/lib/native
Which version of JNA do you use? (There was a bug in JNA 4.2.2/4.3.0 which might also be a cause)
I am trying to deploy an opencv java application with opencv 2.49, I have build the libopencv_java249.so and opencv-249.jar in the Ubuntu server and these are available in the class path when the application starts.
But it's throwing a exception saying libopencv_java245 not found, so initially I was under a impression that it's referring to a wrong opencv version. so to verify this I have removed the libopencv_java249.so from class path and then it was complaining that libopencv_java249 not available.
As an additional testing I also renamed libopencv_java249.so to libopencv_java245.so then it was saying again that opencv_java249 not found.
With this I guess we can confirm that it looks for the right version of opencv (that is libopencv_java249) but in addition to that it aslo requires libopencv_java245 also. Is my assumption is correct, it would be really helpful if someone can guide me.
I am currently working on an API for a server software so users can extend my software by programming plugins for it instead of modifying the software themselves, and allow other users without programming knowledge to easily change the software by adding these plugins. So far, everything is working fine. But, I am running into a problem with configuration.
You see, each plugin has a plugin.yml file stored with these 4 attributes:
Main: The main class is stored here
Name: This is where the plugin name is stored
Version: This is where the plugin version is stored
Author: This is where the plugin author is stored
Now, in order for the plugin to print something to the console, they use a function called: this.getServer().getLogger().info("MESSAGE); (They extend another class for plugins, thats why they use "this" instead of another class to log)
But, I do not have any idea on how to get which plugin is which when they are calling the function. I have a ArrayList of PluginSessions which event handlers use to cycle through to run Event Functions.
My solution is to get the jar from which a class is being called so I can then get the plugin.yml from there. But, I have NO idea on how to get that, I have tried using Class.forName(); and some other code. But because the class is non-existent within the jar/project running the code, It will throw a ClassNotFoundException.
Does anyone here know how to get the jar from which a class is coming from without using Class.forName()? Thanks! -Trent
Take a look at Class.getResource.
If you call MyClass.getResource("plugin.yml") (or "/plugin.yml" with leading slash, I forget) you get back a file URL pointing to the plugin.yml file in the same jar as MyClass. (Or null if the path is wrong or the jar doesn't contain a "plugin.yml" file.) You can then open an InputStream to that resource. In a plugin framework you may want to use myPluginInstance.getClass().getResource.
Assuming jar for 'PluginSessions' is already added in you classpath by eclipse then you can try the following trick -
Select/highlight PluginSessions by double clicking on it
Now press CTRL+SHIFT+T
A dialog named Open Type is appeared. Here you found from where the PluginSessions class is coming from. If you have more than one jar containing PluginSessions class than you have a list of them.
To benefited from this CTRL+SHIFT+T trick you need to add all of your jar need by the project to be added in your classpath.
In order to communicate with my serial port I downloaded rxtx for windows 64 bit and pluged into my eclipse. Everything looks fine. But while I'm debugging it when it comes to
SerialPort serialPort = (SerialPort) portIdentifier.open("ListPortClass", 300);
int b = serialPort.getBaudRate();
it goes to class file editor and says rxtxport.class not found. What could be the issue?
The problem sounds like a classpath problem. I'd say check the Eclipse Build Path.
Weirdly, the code snippet you provided did not contain said class, either it's incomplete or you might have the problem that it is a referenced class and a further 3rd party library is needed (ie, your package of rxtx is incomplete).
I'm not familiar with rxtx myself, so I cannot say if this is a definite probability, and on the other hand, this also comes down to the original answer: It is most likely a classpath problem, check whether all required libraries are included in the Eclipse Build Path.
My problem is as follow : I am developing an eclipse plugin and sometimes I lose track of where the classes are loaded from. What I would like is to see in the debugger stacktrace where a class is loaded from (which jar on the harddrive).
Am I missing some obvious Eclipse option ?
Any help would be greatly appreciated !
To see location of classes loaded : In Run configurations -> Arguments tab add vm argument -verbose. That will include the full path of classes loaded.
EDIT:
To find a particular class from a list of jars:
I use a jar class finder plugin. I do not recall the exact location from where i downloaded, the alphaworks link seems broken as of now. But you can find similar tools.
Note : In eclipse, if the console fills up to a point you are not able to see previous logs, then in Common tab -> Standard I/O check File option.