Rosanswers logo

I wrote a node (rosjava) that uses the library "lejos". Node compile without error, but when I run the node

rosrun rosjava_bootstrap run.py nxt_rosjava org.ros.nxt_rosjava.Listener

I get an error

Buildfile: /home/alex/lego-nxt-car-like/nxt_rosjava/dependencies.xml


Total time: 3 seconds
Executing command: ['java', '-classpath', u'/home/alex/lego-nxt-car-like/nxt_rosjava/target/org.ros.rosjava.nxt_rosjava-0.0.0.jar:/home/alex/.ros/rosjava/lib/org.ros.rosjava.test_ros-0.0.0.jar:/home/alex/.ros/rosjava/lib/org.ros.rosjava.roscpp-0.0.0.jar:/home/alex/.ros/rosjava/lib/org.ros.rosjava.topic_tools-0.0.0.jar:/opt/ros/diamondback/stacks/rosjava_core/apache_xmlrpc/target/org.ros.rosjava.apache-xmlrpc-3.1.3.jar:/opt/ros/diamondback/stacks/rosjava_core/rosjava_bootstrap/target/org.ros.rosjava.rosjava_bootstrap-0.0.0.jar:/home/alex/.ros/rosjava/lib/org.ros.rosjava.std_msgs-0.0.0.jar:/opt/ros/diamondback/stacks/rosjava_core/rosjava/target/org.ros.rosjava-0.0.0.jar:/home/alex/.ros/rosjava/lib/org.ros.rosjava.rosgraph_msgs-0.0.0.jar:/home/alex/.ros/rosjava/lib/org.ros.rosjava.geometry_msgs-0.0.0.jar:/opt/ros/diamondback/stacks/rosjava_core/apache_commons_util/target/org.ros.rosjava.ws-commons-util-1.0.2.jar:/home/alex/.m2/repository/com/google/guava/org.ros.rosjava.guava/r07/org.ros.rosjava.guava-r07.jar:/home/alex/.m2/repository/dnsjava/org.ros.rosjava.dnsjava/2.1.1/org.ros.rosjava.dnsjava-2.1.1.jar:/home/alex/.m2/repository/org/apache/commons/com.springsource.org.apache.commons.codec/1.3.0/com.springsource.org.apache.commons.codec-1.3.0.jar:/home/alex/.m2/repository/org/apache/commons/com.springsource.org.apache.commons.httpclient/3.1.0/com.springsource.org.apache.commons.httpclient-3.1.0.jar:/home/alex/.m2/repository/org/apache/commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar:/home/alex/.m2/repository/org/jboss/netty/netty/3.2.4.Final/netty-3.2.4.Final.jar', 'org.ros.RosRun', 'org.ros.nxt_rosjava.Listener']
Loading node class: org.ros.nxt_rosjava.Listener
Exception in thread "main" java.lang.NoClassDefFoundError: lejos/nxt/Motor
    at org.ros.nxt_rosjava.Listener.main(Listener.java:36)
    at org.ros.RosRun.main(RosRun.java:71)

I think that I need add "/home/alex/lejos_nxj/lib/pc/pccomm.jar" in dependencies.xml, but how to do it?

Originally posted by Alexandr Buyval on ROS Answers with karma: 641 on 2011-09-26

Post score: 1

Original comments

Comment by morrowsend on 2011-10-11:
I realize this is solved, but I wrote a quick tutorial for what worked for me. it may be of some use for someone else. http://coe.uncc.edu/~acharris/How_To_ROSJAVA/ROSJAVA_Tutorial.html


1 Answer 1


Rosanswers logo

You need to add the path of the jar file in manifest.xml in the rosjava_pathelement tag. And you also need to add the path in ros.properties to the classpath and jarfileset properties. Take care to use the right delimiter (, vs :).

Edit: So my procedure to include external (i.e. non-ros) jar files now is:

  • Create a package, e.g., "external_jar", create subfolder, put jar-files there
  • Add a rosjava_pathelement tag with the relative path to each jar file to external_jar's manifest.xml (see other rosjava manifest.xml files for exact syntax)
  • Declare dependency on external_jar in manifest of the package where the jar-files are needed.
  • Rosmake your package

Originally posted by Felix Endres with karma: 6468 on 2011-09-27

This answer was ACCEPTED on the original site

Post score: 2

Original comments

Comment by morrowsend on 2011-10-07:
Ok, now I got it to build. But have a running problem, which probably requires its own post. Thanks for the help!!!

Comment by Alexandr Buyval on 2011-10-06:
I build project in Eclipse. Before build I add the path of the jar file in ros.properties to the ros.compile.classpath and ros.compile.jarfileset properties.If I launch "rosmake" then those properties erase and I need to add again.

Comment by morrowsend on 2011-10-05:
I'm doing something similar and having problems. Even when I add the to my manifest.xml, my builds keep failing because it can't find the imports for the new library. This is a completely non-ROS library I'm adding so "depend" doesn't work.

Comment by Felix Endres on 2011-09-28:
Great! With the above description you can use the relative location, which makes your package portable to other computers.

Comment by Alexandr Buyval on 2011-09-28:
Node runs!!! I add "" in manifest.xml and run "rosmake nxt_rosjava". Thank you!

Comment by Felix Endres on 2011-09-28:
Hm, there is more to it, it seems. I'll update this tomorrow


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.