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

compiling java file in ros environment

asked 2012-12-18 00:05:41 -0600

safzam gravatar image

Hi, I have a ros package my_pkg. I have c++ files in my_pkg/src folder and I can make the ros nodes using command "rosmake my_pkg". Is there any way to compile java file too while compiling the package if I add file. I dont want to use rosjava I just want to get Server.class and later want to run this class with command "java Server". Any hints please.. thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-12-18 00:32:12 -0600

KruseT gravatar image

rosmake is a wrapper aound make. You can extend the Makefile or the CMakeLists.txt of your project to invoke javac or ant.

From your description I would try to extend CMakeLists.txt with a custom command (look for a recipe with Google), but several other approaches exist.

edit flag offensive delete link more


I used command EXECUTE_PROCESS(COMMAND "${PROJECT_SOURCE_DIR}/classes/javac") in at the end in CMakeList.txt of my_pkg. The package was comiped successfully but I dont see any Server.class I doing something wrong?

safzam gravatar image safzam  ( 2012-12-18 01:02:49 -0600 )edit

Don't use execute_process. It will be executed during configuration, not when your targets are built. You really need to use a custom command. If you need examples for building jave, have a look at client_rosjava_jni. There we define a cmake macro for building java code.

Lorenz gravatar image Lorenz  ( 2012-12-18 02:06:22 -0600 )edit

I had a look at and stack.yaml I didn't find any clue about "javac". I dont want to depend upon rosjava. want a command to compile and give Server.class in my_pkg/classes dir. Can you plz just write me command? thnx

safzam gravatar image safzam  ( 2012-12-18 03:02:19 -0600 )edit

Just have a look at the corresponding cmake macros in client_rosjava_jni. You don't need to use it or depend on it. Just copy and adjust the cmake macro.

Lorenz gravatar image Lorenz  ( 2012-12-18 03:04:00 -0600 )edit

I found this command in macro add_java_source_dir_internal: COMMAND ${JAVA_COMPILE} -source 1.5 -classpath "${_javac_classpath_param}:$ENV{ROSJAVA_AUX_CLASSPATH}" -d ${JAVA_OUTPUT_DIR} ${_java_source_files} but I don' understand how does it execute javac

safzam gravatar image safzam  ( 2012-12-18 03:45:54 -0600 )edit

Question Tools


Asked: 2012-12-18 00:05:41 -0600

Seen: 139 times

Last updated: Dec 18 '12