0
$\begingroup$

Rosanswers logo

I built my own package, then I copied in the source form the Publisher/subscriber tutorial (LIstener.java and Talker.java) 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 run.py 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

get-dependencies:

BUILD SUCCESSFUL
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.rosjava.ws-commons-util-1.0.2.jar:/home/user/.ros/rosjava/lib/org.ros.rosjava.sensor_msgs-0.0.0.jar:/home/user/.m2/repository/com/google/guava/org.ros.rosjava.guava/r07/org.ros.rosjava.guava-r07.jar:/home/user/.m2/repository/dnsjava/org.ros.rosjava.dnsjava/2.1.1/org.ros.rosjava.dnsjava-2.1.1.jar:/home/user/.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/user/.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/user/.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/user/.m2/repository/org/jboss/netty/netty/3.2.4.Final/netty-3.2.4.Final.jar', '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?


Originally posted by morrowsend on ROS Answers with karma: 56 on 2011-10-05

Post score: 0


Original comments

Comment by damonkohler on 2011-10-08:
Could you please post your solution as an answer and mark it as accepted?

Comment by morrowsend on 2011-10-05:
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.

Comment by morrowsend on 2011-10-05:
After posting this, I found a similar topic http://answers.ros.org/question/2121/cant-run-a-ros-package-created-with-rosjava 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.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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="ros.properties" />
  <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}" />
  </path>
    
    <echo message="${toString:classpath}" />

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

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

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

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

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

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

</project>

Originally posted by morrowsend with karma: 56 on 2011-10-11

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

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