ros2-java / ros2_java

Java and Android bindings for ROS2
Apache License 2.0
173 stars 93 forks source link

Running Ros2-java from IDE #229

Closed malte269 closed 1 year ago

malte269 commented 1 year ago

Hello Team, I try to run the ros2-java example from the IDE (IntelliJ Ultimate), but it is not working. First i tried with gradle version >= 7.5 but it gave me the error: "Configuration with name 'compile' not found.". I tried again with gradle version 6.9 and first i got the error that null cannot be split. Now loading jars works and i could start coding, I really don't know why. But when i execute, for example, the PublisherLambda I get the following error:

Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings
4 actionable tasks: 3 executed, 1 up-to-date
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/adminus/ros_java/ros2_java_ws/build/rcljava_common/jars/slf4j-jdk14-1.7.21.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/adminus/ros_java/ros2_java_ws/build/rcljava_common/jars/slf4j-log4j12-1.7.21.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.JDK14LoggerFactory]
März 01, 2023 11:52:52 AM org.ros2.rcljava.common.JNIUtils loadImplementation
INFORMATION: Loading implementation: org_ros2_rcljava_rcl_java__jni
März 01, 2023 11:52:52 AM org.ros2.rcljava.RCLJava <clinit>
SCHWERWIEGEND: Native code library failed to load.
java.lang.UnsatisfiedLinkError: no org_ros2_rcljava_rcl_java__jni in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib

FAILURE: Build failed with an exception.

What is this library and where do i get it from? Or is it, because i didn't source ros2-java from inside the ide? How do i do that? Can anyone help, do i miss something? I have an Ubuntu Jammy with ros2 humble and JDK 11 I downloaded the ros2-java repo following the instructions of the README and opened its ros2_java_examples

malte269 commented 1 year ago

Ok I got it to run by either sourcing the environment in the terminal, starting the ide from this terminal and run the file as an application or running a shell script :)