ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Use an external library in rosjava

asked 2011-09-26 23:51:25 -0600

Alexandr Buyval gravatar image

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

rosrun rosjava_bootstrap 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.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(
    at org.ros.RosRun.main(

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

edit retag flag offensive close merge delete


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.
morrowsend gravatar image morrowsend  ( 2011-10-11 12:32:49 -0600 )edit

2 Answers

Sort by » oldest newest most voted

answered 2011-09-27 21:44:10 -0600

updated 2011-09-28 09:31:16 -0600

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 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
edit flag offensive delete link more


Hm, there is more to it, it seems. I'll update this tomorrow
Felix Endres gravatar image Felix Endres  ( 2011-09-28 04:23:00 -0600 )edit
Node runs!!! I add "<rosjava-pathelement location="/home/alex/lejos_nxj/lib/pc/pccomm.jar" />" in manifest.xml and run "rosmake nxt_rosjava". Thank you!
Alexandr Buyval gravatar image Alexandr Buyval  ( 2011-09-28 05:04:45 -0600 )edit
Great! With the above description you can use the relative location, which makes your package portable to other computers.
Felix Endres gravatar image Felix Endres  ( 2011-09-28 09:32:58 -0600 )edit
I'm doing something similar and having problems. Even when I add the <rosjava-pathelement location="/direct/library/path"> 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.
morrowsend gravatar image morrowsend  ( 2011-10-05 06:15:17 -0600 )edit
I build project in Eclipse. Before build I add the path of the jar file in to the ros.compile.classpath and ros.compile.jarfileset properties.If I launch "rosmake" then those properties erase and I need to add again.
Alexandr Buyval gravatar image Alexandr Buyval  ( 2011-10-06 06:39:39 -0600 )edit
Ok, now I got it to build. But have a running problem, which probably requires its own post. Thanks for the help!!!
morrowsend gravatar image morrowsend  ( 2011-10-07 04:43:48 -0600 )edit

answered 2012-01-01 03:17:07 -0600

Did you solve the problems with pccomm.jar?

I have just uploaded some examples in LeJOS project:">

Juan Antonio

edit flag offensive delete link more


Yes, I have solved the problem with pccomm.jar. Now I am writting ros package for connect NXT through LeJOS.
Alexandr Buyval gravatar image Alexandr Buyval  ( 2012-02-01 20:59:47 -0600 )edit

Question Tools

1 follower


Asked: 2011-09-26 23:51:25 -0600

Seen: 1,465 times

Last updated: Jan 01 '12