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

rosjava(pure) pubsub tutorial

asked 2011-06-15 12:24:41 -0500

hughie gravatar image


I'm using the new, pure-java rosjava. I installed ros(diamonback) and rosjava by rosinstall in my ubuntu(lucid). and build rosjava.jar successfully.

I want talk to other node using pubsub tutorial in rosjava. I imported rosjava.jar and other libraries in eclipse project and modified the source as below. (commons-codec-1.3.jar, commons-httpclient-3.1.jar, commons-loggin-1.1.1.jar, dnsjava-2.1.1.jar, guava-r07.jar, junit-4.8.2.jar, mockito-all-1.8.5.jar, netty-3.2.4.Final.jar, rosjava.jar)

When I run below program by java application, I got this error message.

    at org.ros.Node.<init>(
    at Hell.main(
    at Hell.main(

I also tried to debugging with eclipse but, I couldn't debugging with source with this message

Source not found, [Edit Source Lookup Path ...] button.

I tried to connect ros source directory(ros/rosjava/rosjava/src) and include the rosjava source(org.ros), but It also fail to find the source.

Please help me. I'm beginner of the java language. If this question is too sil7ly, Please understand me.


 * Copyright (C) 2011 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.


import org.ros.Node;
import org.ros.NodeConfiguration;
import org.ros.NodeMain;
import org.ros.Publisher;

public class Hell implements NodeMain {
    private Node node;
     * @param args
    public void main(NodeConfiguration configuration){
        Preconditions.checkState(node == null);
        try {
          node = new Node("talker", configuration);
          Publisher<org.ros.message.std_msgs.String> publisher =
              node.createPublisher("chatter", org.ros.message.std_msgs.String.class);
          int seq = 0;
          while (true) {
            org.ros.message.std_msgs.String str = new org.ros.message.std_msgs.String();
   = "Hello world! " + seq++;
        } catch (Exception e) {
          if (node != null) {
          } else {
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        Hell h = new Hell();
        NodeConfiguration node_cfg = new NodeConfiguration();

    public void shutdown() {
        node = null;


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2011-06-16 00:26:58 -0500

damonkohler gravatar image

I see a couple of issues:

First, you should pull the latest version. Your line numbers don't match up with my source.

To view the source, you should be able to attach the source to rosjava.jar as you described. Make sure you select "External folder" and select the "rosjava/src" folder not the "org" folder beneath it.

Finally, I believe your problem is that you have an invalid NodeConfiguration. Admittedly, the error message could be better.

Try using: NodeConfiguration node_cfg = NodeConfiguration.createDefault();

edit flag offensive delete link more


Now, everything is fine. Thanks.
hughie gravatar image hughie  ( 2011-06-20 00:37:28 -0500 )edit
Please accept the answer if it works for you. Thanks!
damonkohler gravatar image damonkohler  ( 2011-06-20 05:40:41 -0500 )edit

answered 2011-06-27 20:46:41 -0500

david gravatar image

Hi Hughie,

Can you provide a working set of elementary project files for communication between Android and ROS? I am definitely asking for too much, but I would appreciate a lot of your help, because I am just another student just recently started learning the ROS and the Android. Thanks! My address is


edit flag offensive delete link more


There are Android tutorials in the rosjava project: /trunk/android/tutorials.
damonkohler gravatar image damonkohler  ( 2011-06-29 01:29:59 -0500 )edit
Yes, I downloaded from that place. and it is changing very frequently.
hughie gravatar image hughie  ( 2011-06-29 18:57:36 -0500 )edit

Question Tools

1 follower


Asked: 2011-06-15 12:24:41 -0500

Seen: 1,775 times

Last updated: Jun 27 '11