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

Revision history [back]

click to hide/show revision 1
initial version

Hi @rezenders,

The error is because the class you are trying to execute is not in the classpath.

Also, is it necessary to use catkin_create_rosjava_project my_pub_sub_tutorial ? Is it possible to run programs the same way it is done with python? Like just creating a file.py and adding permissions to run?

The short answer is no.

Let me explain a bit: every Java program has a fixed entrypoint (aka main method) that is the first thing executed. In rosjava you regularly write a ROS node overriding AbstractNodeMain, so you need some main method to actually run the node for you. That is provided in RosRun class, which is the standard entrypoint for any rosjava application (look at the project level build.gradle file; you should see mainClassName declared there). When you execute the command rosrun [package] [project] [class name] you are actually calling an executable script generated by Gradle, which runs RosRun class (which is part of rosjava), which in turn loads your node to the classpath and executes it. There are some more details around all of this, but as you can guess it's not the same as executing a python script.

Did you follow the steps of the tutorial one by one without skipping anything? You shouldn't encounter any errors there.