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

ROSJAVA and External Libraries (again)

asked 2012-01-27 02:33:24 -0500

Markus Eich gravatar image

updated 2012-01-27 02:34:45 -0500

Dear all,

I try to include an external library to the example of rosjava_tutorial_pubsub_Listener.

I modified the code as follows:

 package org.ros.tutorials.pubsub;
 import org.apache.commons.logging.Log;
 import org.ros.message.MessageListener;
 import org.ros.namespace.GraphName;
 import org.ros.node.Node;
 import org.ros.node.NodeMain;
 import org.ros.node.topic.Subscriber;
 import cylinder_reasoner.*;

 * This is a simple rosjava {@link Subscriber} {@link Node}. It assumes an
 * external roscore is already running.
 * @author (Damon Kohler)
 public class Listener implements NodeMain {

  public GraphName getDefaultNodeName() {
  return new GraphName("rosjava_tutorial_pubsub/listener");

   public void onStart(Node node) {
   final Log log = node.getLog();
   CylinderReasoner reasoner=new CylinderReasoner();

   Subscriber<org.ros.message.std_msgs.String> subscriber =
     node.newSubscriber("chatter", "std_msgs/String");
    subscriber.addMessageListener(new MessageListener<org.ros.message.std_msgs.String>()   
    public void onNewMessage(org.ros.message.std_msgs.String message) {"I heard: \"" + + "\"");

Than I added the following line to the manifest.txt

<rosjava-pathelement location="/home/eich/Test.jar" />

Test Test.jar contains the Package cylinder_reasoner.CylinderReasoner.

Problem is I cannot compile. The error is that package cylinder_reasoner does not exist

Do I have to set the jar file somewhere else as well? Or only in the manifest. After calling rosmake, the .classpath is updated correctly, but it cannot find the package.

Do you have any ideas?

Thank you

edit retag flag offensive close merge delete

4 Answers

Sort by ยป oldest newest most voted

answered 2012-02-01 00:05:15 -0500

Markus Eich gravatar image

I solved the problem by adding the needed jars files to the This seems to work. The problem is I have to add them every time I call rosmake.

edit flag offensive delete link more


Sounds like a bug. I've filed this issue:
damonkohler gravatar image damonkohler  ( 2012-02-02 02:01:30 -0500 )edit

I also tried to use relative path (i.e. the jars are in the root directory of the rosjava project). They are not added to either.

Markus Eich gravatar image Markus Eich  ( 2012-02-15 03:47:46 -0500 )edit

answered 2012-01-29 22:42:17 -0500

Markus Eich gravatar image

updated 2012-01-29 22:43:13 -0500

Thanks for the answer. I tried both eclipse and ant. Ant gives a compile error

Compiling 1 source file to /home/eich/dev/rosjava_core/rosjava_tutorial_pubsub/target/classes
[javac] package cylinder_reasoner does not exist
[javac] import cylinder_reasoner.*;

Although I set up the path to my Test.jar in the manifest. I run make in the project folder and get a compile error.

When I try to run the project in Eclipse (which I would prefere) I get another error Usage: rosrun rosjava_bootstrap [args] __name:=<node name="">

How can I setup Eclipse to run the node? I tried to enter rosjava_tutorial_pubsub org.ros.tutorials.pubsub.Listener in the arguments list. Than I get another error

Loading node class: rosjava_tutorial_pubsub
Exception in thread "main" org.ros.exception.RosRuntimeException: Unable to locate node: rosjava_tutorial_pubsub
at org.ros.RosRun.main(
Caused by: java.lang.ClassNotFoundException: rosjava_tutorial_pubsub
edit flag offensive delete link more

answered 2012-01-29 22:49:14 -0500

Markus Eich gravatar image

I just realized that my Test.jar is NOT included in the after calling make. Shouldn't it be there after calling make? Where is the information stored where <rosjava-pathelement location="/home/eich/Test.jar"/> is pointing to?



edit flag offensive delete link more

answered 2012-01-27 03:40:49 -0500

damonkohler gravatar image

How are you compiling? Eclipse? Ant?

After modifying the manifest.xml, you'll need to run make in the package to update the ant scripts. After you've run make, you can then skip running make in the future and just compile with either ant or Eclipse. Skipping make is faster.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2012-01-27 02:33:24 -0500

Seen: 1,260 times

Last updated: Feb 01 '12