- 
  Notifications
 
You must be signed in to change notification settings  - Fork 1.4k
 
如何修复 Java.lang.UnsupportedClassVersionError: Unsupported major.minor version #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
 
  Open
 
 
 
 
  Open
 Changes from all commits
 Commits
 
 
 File filter
Filter by extension
Conversations
 Failed to load comments. 
 
 
 
  Loading
 
 Jump to
 
 Jump to file
 
 
 
 Failed to load files. 
 
 
 
  Loading
 
 Diff view
Diff view
 Add files via upload
 
 - Loading branch information
 
 
 
 commit 1c837a7c1d46e03e5e247b73fe8e65f127a04106
 
 
There are no files selected for viewing
 
 
 
 49 changes: 49 additions & 0 deletions
 
 
 
 ...o-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-version.md
 
 
 
 
  
 
 
 
 
 
 
 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
 Learn more about bidirectional Unicode characters
 
 
 
 
 | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| 
  | 
||
| ##如何修复 Java.lang.UnsupportedClassVersionError: Unsupported major.minor version | ||
| 
  | 
||
| 
  | 
||
| ##问题描述 | ||
| 
  | 
||
| 我正在使用Notepad++ 做编辑、运行、编译一体化的工具。 | ||
| 我已经装了JRE并且设置好了环境变量。 | ||
| 当我在nodepad++上运行"Hello world",我看到了以下信息: | ||
| java.lang.UnsupportedClassVersionError: test_hello_world : | ||
| Unsupported major.minor version 51.0 | ||
| at java.lang.ClassLoader.defineClass1(Native Method) | ||
| at java.lang.ClassLoader.defineClassCond(Unknown Source) | ||
| ......................................... | ||
| 
  | 
||
| 我想这是一个版本问题,java的版本太老或者太新。 | ||
| 1.怎么修复? | ||
| 2.我需要装jdk并且设置我的环境变量而不是设置JRE? | ||
| 3.设置JRE和JDK的环境变量有什么不同? | ||
| 
  | 
||
| 
  | 
||
| ##回答 | ||
| 
  | 
||
| 所示版本号表示类文件可兼容的JRE版本 | ||
| 
  | 
||
| 主要的版本号有: | ||
| Java SE 14 = 58, | ||
| Java SE 13 = 57, | ||
| Java SE 12 = 56, | ||
| Java SE 11 = 55, | ||
| Java SE 10 = 54, | ||
| Java SE 9 = 53, | ||
| Java SE 8 = 52, | ||
| Java SE 7 = 51, | ||
| Java SE 6.0 = 50, | ||
| Java SE 5.0 = 49, | ||
| JDK 1.4 = 48, | ||
| JDK 1.3 = 47, | ||
| JDK 1.2 = 46, | ||
| JDK 1.1 = 45 | ||
| (来源:Wikipedia) | ||
| 
  | 
||
| 修复这个问题你需要使用更新版本的JAVA JRE来运行你的java代码,或者为java指定具体的target参数以指示编译器创建与早期Java版本兼容的代码。 | ||
| 
  | 
||
| 例如,创建java 1.4的可执行class文件,使用命令行: javac -target 1.4 HelloWorld.java | ||
| 
  | 
||
| 对于较新版本的Java编译器,可能会收到一条关于未设置引导类路径的警告。关于这个错误的更多信息可以看博客文章(https://blogs.oracle.com/darcy/new-javac-warning-for-setting-an-older-source-without-bootclasspath) | ||
| 
  | 
||
| stackoverflow原地址 https://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-version | 
 Add this suggestion to a batch that can be applied as a single commit.
 This suggestion is invalid because no changes were made to the code.
 Suggestions cannot be applied while the pull request is closed.
 Suggestions cannot be applied while viewing a subset of changes.
 Only one suggestion per line can be applied in a batch.
 Add this suggestion to a batch that can be applied as a single commit.
 Applying suggestions on deleted lines is not supported.
 You must change the existing code in this line in order to create a valid suggestion.
 Outdated suggestions cannot be applied.
 This suggestion has been applied or marked resolved.
 Suggestions cannot be applied from pending reviews.
 Suggestions cannot be applied on multi-line comments.
 Suggestions cannot be applied while the pull request is queued to merge.
 Suggestion cannot be applied right now. Please check back later.