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

rosjava unable to find node (can't run resulting class)

asked 2011-10-05 02:09:02 -0500

morrowsend gravatar image

I built my own package, then I copied in the source form the Publisher/subscriber tutorial ( and into the "src" directory. Building works fine, the resulting .class files are located in ../my_package/build/org/ros/tutorials/my_package. I attempt to run the code using this command (after roscore is running of course):

rosrun rosjava_bootstrap my_package org.ros.tutorials.my_package.Listener

However, each time I try to run it, I get the following result:

    Buildfile: /home/user/ros_workspace/my_package/dependencies.xml


Total time: 3 seconds
Executing command: ['java', '-classpath', u'/home/user/ros_workspace/my_package/target/org.ros.rosjava.my_package-0.0.0.jar:/home/user/.ros/rosjava/lib/org.ros.rosjava.test_ros-0.0.0.jar:/home/user/.ros/rosjava/lib/org.ros.rosjava.roscpp-0.0.0.jar:/home/user/.ros/rosjava/lib/org.ros.rosjava.topic_tools-0.0.0.jar:/home/user/ros_workspace/rosjava/apache_xmlrpc/target/org.ros.rosjava.apache-xmlrpc-3.1.3.jar:/home/user/ros_workspace/rosjava/rosjava_bootstrap/target/org.ros.rosjava.rosjava_bootstrap-0.0.0.jar:/home/user/.ros/rosjava/lib/org.ros.rosjava.std_msgs-0.0.0.jar:/home/user/ros_workspace/rosjava/rosjava/target/org.ros.rosjava-0.0.0.jar:/home/user/.ros/rosjava/lib/org.ros.rosjava.rosgraph_msgs-0.0.0.jar:/home/user/.ros/rosjava/lib/org.ros.rosjava.geometry_msgs-0.0.0.jar:/home/user/ros_workspace/rosjava/apache_commons_util/target/', 'org.ros.RosRun', 'org.ros.tutorials.my_package.Listener']
Loading node class: org.ros.tutorials.my_package.Listener
Unable to locate node: org.ros.tutorials.my_package.Listener

I have no idea how it can not find the Listener.class file since the path is correct. Am I missing something here?

edit retag flag offensive close merge delete


After posting this, I found a similar topic mentioning that a .jar is not being created. This seems to be the case for me as well, even though my manifest.xml has an Export section as mentioned in the ROSJava/build page. I am unsure how to create the jar.
morrowsend gravatar image morrowsend  ( 2011-10-05 02:30:27 -0500 )edit
I got it working. I added the "jar" sections to my build.xml (copied form the pubsub build.xml). Then I had to explicitly build the jar in Eclipse's Ant window. ONce the jar was there, everything went smoothly.
morrowsend gravatar image morrowsend  ( 2011-10-05 02:49:45 -0500 )edit
Could you please post your solution as an answer and mark it as accepted?
damonkohler gravatar image damonkohler  ( 2011-10-08 04:33:38 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2011-10-11 09:53:17 -0500

morrowsend gravatar image

To get this working, you have to use a better skelaton build.xml file than provided on the ROSJAVA wiki. The one I used is below. It basically adds the jar information to the build settings.

You must build the jar file from the ANT window in eclipse in order to create a new jar file each time you want to recompile. I haven't found a way to automate that part yet.

<?xml version="1.0" encoding="UTF-8"?>
<project name="my_second_package" default="default">

  <property file="" />
  <property name="build" location="build" />

  <property name="dist" location="dist" />
  <property name="build" location="build" />
  <property name="src" location="src" />
  <property name="jar" location="${ros.artifact.built}" />

  <path id="classpath">
    <pathelement path="${ros.compile.classpath}" />

    <echo message="${toString:classpath}" />

  <target name="default" depends="init, compile, jar" />

  <target name="init">
    <fail unless="ros.compile.classpath" message=" is missing.  Please type 'rosmake' first "/>
    <mkdir dir="${build}" />
    <mkdir dir="${dist}" />

  <target name="compile" depends="init">

    <javac destdir="${build}">
      <classpath refid="classpath" />
      <src path="${src}" />

      <target name="jar" depends="compile">
        <jar destfile="${jar}">
          <fileset dir="${build}" />

  <target name="clean">
    <delete dir="${build}" />
    <delete dir="${dist}" />

  <!-- required entry point -->
  <target name="test" />

edit flag offensive delete link more

Question Tools


Asked: 2011-10-05 02:09:02 -0500

Seen: 762 times

Last updated: Oct 11 '11