ros2_java icon indicating copy to clipboard operation
ros2_java copied to clipboard

rcljava_common build error: source option 6 is no longer supported. Use 8 or later.

Open Hyrtsi opened this issue 1 year ago • 1 comments

Building on desktop. Ubuntu 22.04, ROS2 Humble.

Starting >>> rcljava_common
Finished <<< ament_cmake_export_jni_libraries [0.27s]
--- stderr: rcljava_common                              
warning: [options] bootstrap class path not set in conjunction with -source 6
error: Source option 6 is no longer supported. Use 8 or later.
error: Target option 6 is no longer supported. Use 8 or later.
gmake[2]: *** [CMakeFiles/rcljava_common_jar.dir/build.make:92: CMakeFiles/rcljava_common_jar.dir/java_compiled_rcljava_common_jar] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:154: CMakeFiles/rcljava_common_jar.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
gmake: *** [Makefile:146: all] Error 2
---
Failed   <<< rcljava_common [1.32s, exited with code 2]

Summary: 4 packages finished [2.50s]
  1 package failed: rcljava_common

Hyrtsi avatar Oct 15 '24 11:10 Hyrtsi

I guess I managed to solve this (using Java 21):

diff --git a/rcljava_common/CMakeLists.txt b/rcljava_common/CMakeLists.txt
index 3bc04fd..e351257 100644
--- a/rcljava_common/CMakeLists.txt
+++ b/rcljava_common/CMakeLists.txt
@@ -30,7 +30,7 @@ if(NOT WIN32)
   add_compile_options(-Wall -Wextra -Wpedantic)
 endif()
 
-set(CMAKE_JAVA_COMPILE_FLAGS "-source" "1.6" "-target" "1.6")
+set(CMAKE_JAVA_COMPILE_FLAGS "-source" "21" "-target" "21")

Check your java version like this: java --version It looks like this for me: openjdk 21.0.5 2024-10-15 OpenJDK Runtime Environment (build 21.0.5+11-Ubuntu-1ubuntu124.04) OpenJDK 64-Bit Server VM (build 21.0.5+11-Ubuntu-1ubuntu124.04, mixed mode, sharing)

ChristophSchwanke avatar Jan 22 '25 19:01 ChristophSchwanke