简体   繁体   English

Netbeans 8.0 Unsupported major.minor 版本 52.0 错误

[英]Netbeans 8.0 Unsupported major.minor version 52.0 error

I am having a problem with compiled .jar projects in netbeans.我在 netbeans 中编译 .jar 项目时遇到问题。 I recently upgraded to java 1.8 and netbeans 8.0.我最近升级到 java 1.8 和 netbeans 8.0。 After updating every project I compile and put onto my server running java 1.7.0_55 I get the "Unsupported major.minor version 52.0" issue.更新每个项目后,我编译并放到运行 java 1.7.0_55 的服务器上,我得到“不支持的 major.minor 版本 52.0”问题。 I know this is due to incompatible java versions.我知道这是由于不兼容的 java 版本。 I have tried changing the jdk used for building everywhere I can find it.我已经尝试更改用于在我能找到的任何地方构建的 jdk。 I have tried building with 1.7.0_55 and 1.7.0_07 and still get this issue.我尝试使用 1.7.0_55 和 1.7.0_07 进行构建,但仍然遇到此问题。 Does anyone know what I am missing?有谁知道我错过了什么? Each time I have changed the build settings I make sure to recompile the project.每次我更改构建设置时,我都会确保重新编译项目。 It is not possible to update the version of java on the server just yet.目前还不能更新服务器上的 java 版本。

If you are using Maven, you can set the JDK version of each module by placing a file called nb-configuration.xml beside your pom.xml with the following content:如果您使用的是 Maven,您可以通过在pom.xml旁边放置一个名为nb-configuration.xml的文件来设置每个模块的 JDK 版本,其中包含以下内容:

<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
    <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
        <netbeans.hint.jdkPlatform>JDK_1.7</netbeans.hint.jdkPlatform>
    </properties>
</project-shared-configuration>

The "JDK_1.7" Java platform must be configured in Tools -> Java Platforms -> Add Platform... “JDK_1.7”Java平台必须在Tools -> Java Platforms -> Add Platform...中配置。

Does anyone know what I am missing?有谁知道我错过了什么?

Well the one thing you were missing is that everything needs to be built for Java 1.7.好吧,您缺少的一件事是所有东西都需要为 Java 1.7构建 It is not sufficient to just configure the IDE to use JDK 1.7.仅将 IDE 配置为使用 JDK 1.7 是不够的。 You have to make the IDE do the rebuild ... for everything that was previously built with Java 1.8 as the target.您必须让 IDE进行重建……对于以前使用 Java 1.8 作为目标构建的所有内容

Clean and rebuild all relevant projects after changing the project's Java target platform.更改项目的 Java 目标平台后清理并重建所有相关项目。

I also recommend that you start using Maven / Gradle / whatever to specify your build configs.我还建议您开始使用 Maven/Gradle/whatever 来指定您的构建配置。 This allows you to specify in the build configs what the target platform should be.这允许您在构建配置中指定目标平台应该是什么。 If you do this, you are less likely to be burned with bad builds when you upgrade your IDE and/or development machine's default Java install.如果你这样做,当你升级你的 IDE 和/或开发机器的默认 Java 安装时,你不太可能被糟糕的构建所烧毁。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM