Ask Your Question
0

compiling java file in ros environment

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

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 Server.java 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
2

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

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

Comments

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

safzam gravatar image safzam  ( 2012-12-18 01:02:49 -0500 )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 -0500 )edit

I had a look at http://ros.org/rosdoclite/fuerte_bak/api/client_rosjava_jni/repo.yaml and stack.yaml I didn't find any clue about "javac". I dont want to depend upon rosjava. want a command to compile Server.java 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 -0500 )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 -0500 )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 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

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

Seen: 96 times

Last updated: Dec 18 '12