简体   繁体   English

无法编译Java代码-“类文件的版本错误为52.0,应为48.0”

[英]Cannot compile Java code - “class file has wrong version 52.0, should be 48.0”

I know that this appears everywhere with a bunch of threads but I followed the instructions and it did not work! 我知道这随处可见,但有一堆线程,但是我按照指示进行了操作,但是没有用! I get the following error: 我收到以下错误:

cannot access java.lang.Object bad class file: /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/rt.jar(java/lang/Object.class) class file has wrong version 52.0, should be 48.0 Please remove or make sure it appears in the correct subdirectory of the classpath. 无法访问java.lang.Object错误的类文件:/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/rt.jar(java/lang/Object.class)类文件的版本错误52.0,应为48.0。请删除或确保它出现在类路径的正确子目录中。 public static void main (String [] args){ ^ 1 error 公共静态无效主(String [] args){^ 1错误

I downloaded the latest runtime, and the latest JDK. 我下载了最新的运行时和最新的JDK。 If I do /java version in Terminal (I'm using Mac), I get: 如果我在终端中使用/ java版本(我使用Mac),则会得到:

java version "1.8.0_60" Java(TM) SE Runtime Environment (build 1.8.0_60-b27) Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)XXXXX-MacBook-Pro:~ XXXXX$ java版本“ 1.8.0_60” Java SE运行时环境(内部版本1.8.0_60-b27)Java HotSpot™64位服务器VM(内部版本25.60-b23,混合模式)XXXXX-MacBook-Pro:〜XXXXX $

What should I do now? 我现在应该怎么办? I set the JAVA_HOME and it still doesn't work. 我设置了JAVA_HOME,但它仍然不起作用。 Thanks for your help. 谢谢你的帮助。

I believe you answered your own question. 我相信您回答了自己的问题。 You are currently using 1.8, which is greater than the required 48 (see here ). 您当前正在使用1.8,它大于所需的48(请参阅此处 )。 To use version 48, you will have to install JDK 1.4. 要使用版本48,您将必须安装JDK 1.4。 Also, make sure your system paths point to the 1.4 version after you've installed it. 另外,在安装后,请确保系统路径指向1.4版本。

Do a which java in your terminal and then go into that directory or run that executable with the --version switch to verify the version number. 在终端中执行哪个java ,然后进入该目录或使用--version开关运行该可执行文件以验证版本号。 Sometimes, the installer will default to the newer version of Java while maintaining symbolic links to the older versions in the same folder. 有时,安装程​​序将默认使用Java的较新版本,同时在同一文件夹中维护到较旧版本的符号链接。 You will have to relink your Java to the older, 1.4 version if this is the case. 在这种情况下,您将必须将Java重新链接到旧的1.4版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 并行处理:类文件的版本为49.0,应为48.0 - parallel processing: class file has wrong version 49.0, should be 48.0 Class 文件版本错误 52.0,应该是 50.0 - Class file has wrong version 52.0, should be 50.0 class文件版本55.0错误,应该是52.0 - Class file has wrong version 55.0, should be 52.0 类文件有错误的版本 55.0,应该是 52.0 (IntelliJ) - Class file has wrong version 55.0, should be 52.0 (IntelliJ) VSCode Java Project:类文件的版本为55.0,应为52.0,Gradle Build Failing - VSCode Java Project: Class file has wrong version 55.0, should be 52.0, Gradle Build Failing 编译javaFX项目时“类文件的版本错误为54.0,应该是52.0” - "class file has wrong version 54.0, should be 52.0" while compiling javaFX project 如何修复此错误:class 文件的版本错误 52.0,应该是 49.0 - how to fix this error: class file has wrong version 52.0, should be 49.0 Xamarin.Android 错误:class 文件版本错误 55.0,应该是 52.0 - Xamarin.Android Error: class file has wrong version 55.0, should be 52.0 Xamarin升级导致“类文件有错误版本52.0,应该是50.0”错误 - Xamarin upgrade causes “class file has wrong version 52.0, should be 50.0” error 构建 Alfresco 时出现错误“类文件的版本 55.0 错误,应为 52.0” - error "class file has wrong version 55.0, should be 52.0" when building Alfresco
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM