IDEA運行Java項目報錯java: 錯誤: 不支持發(fā)行版本 xx的解決方法
更新時間:2025年04月17日 09:38:09 作者:一枚風雨流蘇
這篇文章主要介紹了IDEA運行Java項目報錯java: 錯誤: 不支持發(fā)行版本 xx的解決方法,文中有詳細的解決方案供大家參考,對大家解決問題有一定的幫助,需要的朋友可以參考下
報錯場景:
IDEA運行Java項目報錯,點擊運行之后,IDEA在編譯代碼的時候就出現(xiàn)報錯:
報錯類型一:java: 錯誤: 不支持發(fā)行版本 21 報錯類型二:java: 錯誤: 無效的源發(fā)行版:21
詳細報錯如下:
Executing pre-compile tasks... Running 'before' tasks Checking sources Copying resources... [spring6-ioc-annotation] Checking dependencies… [spring6-ioc-annotation] Dependency analysis found 0 affected files Updating dependency information… [spring6-ioc-annotation] Searching for compilable files... [spring6-ioc-annotation] Parsing java… [spring6-ioc-annotation] java: 錯誤: 不支持發(fā)行版本 21 Dependency analysis found 0 affected files Errors occurred while compiling module 'spring6-ioc-annotation' javac 17 was used to compile java sources Finished, saving caches… Module 'spring6-ioc-annotation' was fully rebuilt due to project configuration/dependencies changes Compilation failed: errors: 1; warnings: 0 Executing post-compile tasks... Compilation failed: errors: 1; warnings: 0 Synchronizing output directories... 2024/3/5 10:28 - Build completed with 1 error and 0 warnings in 4 sec, 114 ms
截圖如下:
報錯原因:
Javac編譯器的版本與JDK版本不對應
解決方法:
參考以下文章:
保持文章里面4大點的版本一直即可:
- ①File——>Project Structure——>Project;
- ②File——>Project Structure——>Modules;
- ③File——>Project Structure——>SDKs;
- ④File——>Settings——>Build, Execution, Deployment——>Compiler——>Java Compiler。
例如,我這里是第四點的版本不一致:
到此這篇關(guān)于IDEA運行Java項目報錯java: 錯誤: 不支持發(fā)行版本 xx的解決方法的文章就介紹到這了,更多相關(guān)Java錯誤不支持發(fā)行版本內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
SpringBoot讀取properties中文亂碼解決方案
本文主要介紹了在Spring?Boot中讀取帶有中文字符串的application.properties文件時遇到亂碼問題的解決方案,具有一定的參考價值,感興趣的可以了解一下2024-12-12springboot+vue實現(xiàn)websocket配置過程解析
這篇文章主要介紹了springboot+vue實現(xiàn)websocket配置過程解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2020-04-04