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

how to set JAVA_HOME in launch file?

asked 2011-07-01 17:09:30 -0500

Kei Okada gravatar image

I'd like to set JAVA_HOME environment variable from program

  < node name="json_prolog" pkg="json_prolog" type="json_prolog"
        launch-prefix='JAVA_HOME=`rosrun rosjava`'

produces following error

Roslaunch got a 'No such file or directory' error while attempting to run:

JAVA_HOME=`rosrun rosjava` /home/k-okada/ros/diamondback/knowrob-trunk/json_prolog/bin/json_prolog jsk_semantic_maps __name:=json_prolog __log:=/home/k-okada/.ros/log/240f00c8-a37e-11e0-9734-005056c00001/json_prolog-2.log

Please make sure that all the executables in this command exist and have
executable permission. This is often caused by a bad launch-prefix.


roslaun jsk_semantic_maps example-eng2-map.launch --args /json_prolog | bash


edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2011-07-03 02:10:51 -0500

Lorenz gravatar image

updated 2011-07-03 21:50:52 -0500

I'm not sure if it is possible to use $() or `` inside roslaunch since it is actually bash syntax and I guess roslaunch just uses python. Instead, I suggest a different solution, something like a wrapper script to run something with JAVA_HOME set correctly. The script could look like this:

export JAVA_HOME=$(rosrun rosjava
exec $@

Then use it as launch-prefix for your node. If you have it working and want it to be added to the rosjava package, please drop me an email.

edit flag offensive delete link more


How would you tell the launch file to execute the script? I guess the question is: How to use the "launch-prefix" for the node. Thanks in advance!
ubuntuslave gravatar image ubuntuslave  ( 2011-07-16 04:32:02 -0500 )edit
Please have a look at the roslaunch documentation ( In short: <node name="foo" pkg="bar" type="baz" launch-prefix="$(find foo)/"/>
Lorenz gravatar image Lorenz  ( 2011-07-16 08:15:58 -0500 )edit

answered 2011-07-02 21:21:44 -0500

Does running rosrun rosjava work? And if you do a roscd rosjava, does exist somewhere in the directory you get to?

The version of rosjava that you are using has recently been renamed to rosjava_jni; perhaps you have installed the new rosjava in parallel, and ROS tries to find your script in the wrong package.

edit flag offensive delete link more


Just a quick note: rosjava hasn't really been renamed yet, only the corresponding wiki page. But at least the debian package will probably be renamed soon :)
Lorenz gravatar image Lorenz  ( 2011-07-03 02:12:24 -0500 )edit

Question Tools


Asked: 2011-07-01 17:09:30 -0500

Seen: 562 times

Last updated: Jul 03 '11