Unsupported major.minor version

本文介绍了因编译和运行JDK版本不一致导致的Unsupported major.minor version 52.0错误,并提供了详细的堆栈跟踪信息。文中解释了错误产生的原因,并给出了具体的解决方案,即确保编译和运行环境的JDK版本一致。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

详细堆栈信息:

 Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

错误原因:项目的编译使用的JDK版本跟项目运行的JDK版本不一致,笔者这个错误是编译用的1.8,运行用的1.7
后面的数字与JDK版本的对应关系

J2SE 8 = 52,
J2SE 7 = 51,
J2SE 6.0 = 50,
J2SE 5.0 = 49,
JDK 1.4 = 48,
JDK 1.3 = 47,
JDK 1.2 = 46,
JDK 1.1 = 45

解决方式:将项目编译的JDK版本和项目运行环境的JDK版本保持统一
这里写图片描述
修改相应的JDK版本即可

这是DronCAN的初始化函数,哪个是设置节点的函数void AP_DroneCAN::init(uint8_t driver_index, bool enable_filters) { if (driver_index != _driver_index) { debug_dronecan(AP_CANManager::LOG_ERROR, "DroneCAN: init called with wrong driver_index"); return; } if (_initialized) { debug_dronecan(AP_CANManager::LOG_ERROR, "DroneCAN: init called more than once\n\r"); return; } uint8_t node = _dronecan_node; if (node < 1 || node > 125) { // reset to default if invalid _dronecan_node.set(AP_DRONECAN_DEFAULT_NODE); node = AP_DRONECAN_DEFAULT_NODE; } node_info_rsp.name.len = hal.util->snprintf((char*)node_info_rsp.name.data, sizeof(node_info_rsp.name.data), "org.ardupilot:%u", driver_index); node_info_rsp.software_version.major = AP_DRONECAN_SW_VERS_MAJOR; node_info_rsp.software_version.minor = AP_DRONECAN_SW_VERS_MINOR; node_info_rsp.hardware_version.major = AP_DRONECAN_HW_VERS_MAJOR; node_info_rsp.hardware_version.minor = AP_DRONECAN_HW_VERS_MINOR; #if HAL_CANFD_SUPPORTED if (option_is_set(Options::CANFD_ENABLED)) { canard_iface.set_canfd(true); } #endif uint8_t uid_len = sizeof(uavcan_protocol_HardwareVersion::unique_id); uint8_t unique_id[sizeof(uavcan_protocol_HardwareVersion::unique_id)]; mem_pool = NEW_NOTHROW uint32_t[_pool_size/sizeof(uint32_t)]; if (mem_pool == nullptr) { debug_dronecan(AP_CANManager::LOG_ERROR, "DroneCAN: Failed to allocate memory pool\n\r"); return; } canard_iface.init(mem_pool, (_pool_size/sizeof(uint32_t))*sizeof(uint32_t), node); if (!hal.util->get_system_id_unformatted(unique_id, uid_len)) { return; } unique_id[uid_len - 1] += node; memcpy(node_info_rsp.hardware_version.unique_id, unique_id, uid_len); //Start Servers if (!_dna_server.init(unique_id, uid_len, node)) { debug_dronecan(AP_CANManager::LOG_ERROR, "DroneCAN: Failed to start DNA Server\n\r"); return; }
03-14
这是飞控中DronCAN的初始化函数,哪个是给其他设备设置节点语句void AP_DroneCAN::init(uint8_t driver_index, bool enable_filters) { if (driver_index != _driver_index) { debug_dronecan(AP_CANManager::LOG_ERROR, “DroneCAN: init called with wrong driver_index”); return; } if (_initialized) { debug_dronecan(AP_CANManager::LOG_ERROR, “DroneCAN: init called more than once\n\r”); return; } uint8_t node = _dronecan_node; if (node < 1 || node > 125) { // reset to default if invalid _dronecan_node.set(AP_DRONECAN_DEFAULT_NODE); node = AP_DRONECAN_DEFAULT_NODE; } node_info_rsp.name.len = hal.util->snprintf((char*)node_info_rsp.name.data, sizeof(node_info_rsp.name.data), "org.ardupilot:%u", driver_index); node_info_rsp.software_version.major = AP_DRONECAN_SW_VERS_MAJOR; node_info_rsp.software_version.minor = AP_DRONECAN_SW_VERS_MINOR; node_info_rsp.hardware_version.major = AP_DRONECAN_HW_VERS_MAJOR; node_info_rsp.hardware_version.minor = AP_DRONECAN_HW_VERS_MINOR; #if HAL_CANFD_SUPPORTED if (option_is_set(Options::CANFD_ENABLED)) { canard_iface.set_canfd(true); } #endif uint8_t uid_len = sizeof(uavcan_protocol_HardwareVersion::unique_id); uint8_t unique_id[sizeof(uavcan_protocol_HardwareVersion::unique_id)]; mem_pool = NEW_NOTHROW uint32_t[_pool_size/sizeof(uint32_t)]; if (mem_pool == nullptr) { debug_dronecan(AP_CANManager::LOG_ERROR, "DroneCAN: Failed to allocate memory pool\n\r"); return; } canard_iface.init(mem_pool, (_pool_size/sizeof(uint32_t))*sizeof(uint32_t), node); if (!hal.util->get_system_id_unformatted(unique_id, uid_len)) { return; } unique_id[uid_len - 1] += node; memcpy(node_info_rsp.hardware_version.unique_id, unique_id, uid_len); //Start Servers if (!_dna_server.init(unique_id, uid_len, node)) { debug_dronecan(AP_CANManager::LOG_ERROR, "DroneCAN: Failed to start DNA Server\n\r"); return; }
03-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值