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

How to generate service .class files in rosjava?

asked 2017-03-10 04:42:45 -0600

ysg gravatar image

I am new to ros and rosjava. I am going through basic tutrials of ros and rosjava. I have followed below steps. 1. Created a rosjava pakage.

> mkdir -p myjava/src
> cd myjava/src
> catkin_create_rosjava_pkg testpkg1
> cd ..
> catkin_make
> source devel/setup.bash

Then created rosjava project inside this package

>cd rosjava_catkin_package_a
>catkin_create_rosjava_project subproject1
>cd ../..

So now I have testpkg1 inside which is java project subproject1. I want to try my own service example given in tutorials. So I created msg folder and srv folder inside my package testpkg1 but outside project subproject1. Inside the msg and srv are my .msg and .srv files respectivey. Structure below.

  >package.xml,CmakeList.txt,gradlew,build.gradle etc

I made below changes in package.xml


I made changes in CMakeList.txt

find_package(CATKIN REQUIRED std_msgs message_generation)
 generate_messages(DEPENDENCIES std_msgs)
catkin_package(DEPENDENCIES message_runtime std_msgs)

I didnot make any changes to build.gradle. After sourcing I am trying catkin_make. The build gets succeeded however I only see AddSum.h files, AddSumRequest.h, AddSumResponse.h and same, .py ,.js,.lisp files I am not able to see any .java files for same and .class files too. Should this files get generated in this same step or am I missing something? i have also tried

genjava_message_artifacts --verbose - p testpkg1

but it is still not generating any java related files.. I do see the .class files for Listener and Talker but not for AddSum srv.

Any help will appreciated! Thanks..

edit retag flag offensive close merge delete


At a first glance I can't see what's wrong with the code. I guess that if you could create the rosjava pkg you have the build tools sourced. Have you found a solution? Take a look at this commit for reference:

jubeira gravatar image jubeira  ( 2017-09-27 12:58:12 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-11-06 08:51:18 -0600

jubeira gravatar image

updated 2018-09-17 11:05:01 -0600

While the tutorial is built, this issue can be used as a reference: .

Note that generating new messages and services is not related with rosjava in particular: the mechanism is the same used for regular ROS, but adding the Java generators. That can be done, for example, installing rosjava from source and sourcing the workspace. Then, using catkin_make on a package will also generate the .class artifacts for that package.

Also, see this example using services: .

EDIT: see

edit flag offensive delete link more

Question Tools



Asked: 2017-03-10 04:42:45 -0600

Seen: 504 times

Last updated: Sep 17 '18