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

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 find-java-home.sh program

http://code.cs.tum.edu/indefero/index...

  < node name="json_prolog" pkg="json_prolog" type="json_prolog"
        args="jsk_semantic_maps"
        launch-prefix='JAVA_HOME=`rosrun rosjava find-java-home.sh`'
        />

produces following error

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

JAVA_HOME=`rosrun rosjava find-java-home.sh` /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.

but

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

works.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

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:

#!/bin/bash
export JAVA_HOME=$(rosrun rosjava find-java-home.sh)
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

Comments

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 (www.ros.org/wiki/roslaunch). In short: <node name="foo" pkg="bar" type="baz" launch-prefix="$(find foo)/with_java_home.sh"/>
Lorenz gravatar image Lorenz  ( 2011-07-16 08:15:58 -0500 )edit
0

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

Does running rosrun rosjava find-java-home.sh work? And if you do a roscd rosjava, does find-java-home.sh 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

Comments

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

Stats

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

Seen: 543 times

Last updated: Jul 03 '11