simondlevy / BreezySLAM

Simple, efficient, open-source package for Simultaneous Localization and Mapping
GNU Lesser General Public License v3.0
758 stars 251 forks source link

Java can't find library when launching from terminal #14

Closed TheRussellMuscle closed 7 years ago

TheRussellMuscle commented 7 years ago

Hello, I have BreezySLAM unzipped in a folder and I ran all of the makes necessary. In my IDE (NetBeans) I am able to run a slam program by adding the BreezySLAM/java folder to the libraries section of my program in NetBeans. However, when I try to run the jar of the same program through the terminal it gives me these errors: java.lang.NoClassDefFoundError, java.lang.ClassNotFoundException. They regard the BreezySLAM libraries, here is the output from the terminal. I'm running Ubuntu.

java -jar ./ARMR.jar Stable Library Native lib Version = RXTX-2.2pre2 Java lib Version = RXTX-2.1-7 WARNING: RXTX Version mismatch Jar version = RXTX-2.1-7 native lib Version = RXTX-2.2pre2 RXTX Warning: Removing stale lock file. /var/lock/LCK..ttyUSB1 RXTX Warning: Removing stale lock file. /var/lock/LCK..ttyUSB0 Exception in thread "main" java.lang.NoClassDefFoundError: edu/wlu/cs/levy/breezyslam/components/Laser at armr.LIDARProcessor.initSlam(LIDARProcessor.java:53) at armr.LIDARProcessor.(LIDARProcessor.java:48) at armr.ARMRInitialize.(ARMRInitialize.java:47) at armr.run.main(run.java:22) Caused by: java.lang.ClassNotFoundException: edu.wlu.cs.levy.breezyslam.components.Laser at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 4 more

The same errors happen when I run the command: java -cp './ARMR.jar:usr/local/lib/BreezySLAM/java/' armr.run or the command: java -cp './ARMR.jar:usr/local/lib/BreezySLAM/' armr.run

I have also tried adding the libraries directly to the project, and messing around with maven. Does anyone know how to fix this? Thanks in advance.

TheRussellMuscle commented 7 years ago

Just found a fix. All I had to do was create a maven project within the structure of the library and then build and package with dependencies.