由于新的文件夹结构,在Linux上的Intellij IDEA中正确设置Java 9作为SDK [英] Properly set up Java 9 as SDK in Intellij IDEA on Linux due to new folder structure

查看:863
本文介绍了由于新的文件夹结构,在Linux上的Intellij IDEA中正确设置Java 9作为SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在你写下我之前,请考虑这些都不是我的问题的答案:




  • 主要区别:




    • Linux版本:他们使用Mint 18,我正在使用Debian Stretch。

    • OpenJDK是写作时回购的最新版本:9~b181-4~bpo9 + 1。虽然版本相同,但在我的情况下它仍然不起作用。



    编辑:另一个可能的副本: intellij idea没有看到java 9标准类



    我不明白评论的答案。尝试为JDK(9和1.9)设置不同的名称,但它仍然没有显示模块而不是类路径,类路径仍为空。

    解决方案

    目前的debian二进制包 openjdk-9-jre-headless 9~b181-4 包含编译错误的 lib / jrt-fs.jar 文件。

    idea youtrack ubuntu启动板



    正如此处所示:


    可能的原因:

    lib / jrt-fs.jar中的类由Java 9编译,选项为-source 8/目标8。它们应该用--release 8选项编译(或者用Java 8编译)


    临时解决方法可能正在替换 /usr/lib/jvm/java-9-openjdk-amd64/lib/jrt-fs.jar Oracle JDK 中的一个。

    你可以还尝试使用建议选项 - release 8 重新编译openjdk-9源代码。



    无论如何我建议投票支持这个问题在上面的链接上吸引了开发团队的更多关注。


    Before you write me off, please consider that neither of these are answers to my question:


    In IntelliJ IDEA 2017.2.6, attempting to add JDK9 as an SDK passes but does not work as the classpaths end up empty. Steps to reproduce:

    1. Open 'Add new SDK dialog'
      (go to Project Settings > Project > Project SDK > New > JDK)
    2. Select JDK 9
    3. Passes, but if you look under SDK > JDK9 classpaths are empty and your code errors out due to base classes not being found. See image:

    In IntelliJ IDEA 2017.3 EAP you get an error about JDK classes not being found. See images below:

    1. Open 'Add new SDK dialog'
      (go to Project Settings > Project > Project SDK > New > JDK)
    2. Select JDK 9
    3. Should pass, but produces error popup

    Command line compilation of HelloWorld example with jdk9 works as expected.

    EDIT: Found an almost-duplicate: Intellij IDEA 2017.2 can't add openjk 9 on Linux Mint 18. Key differences:

    • Linux version: they're using Mint 18, and I'm using Debian Stretch.
    • OpenJDK is the latest from the repo at the moment of writing: 9~b181-4~bpo9+1. Even though is the same version, it still does not work in my case.

    EDIT: Another possible duplicate: intellij idea does not see java 9 standard classes

    I did not understand the answer from the comments though. Tried setting different names for JDK (9 and 1.9) but it still did not show modules instead of classpaths and classpaths remained empty.

    解决方案

    Current debian binary package openjdk-9-jre-headless 9~b181-4 contains incorrectly compiled lib/jrt-fs.jar file.
    There are 2 filed issues separately on both idea youtrack and also ubuntu launchpad.

    As it is indicated here:

    Probable reason:
    Classes in lib/jrt-fs.jar were compiled by Java 9 with options "-source 8"/"target 8". They should be compiled with "--release 8" option instead (or by Java 8)

    A temporary workaround may be replacing /usr/lib/jvm/java-9-openjdk-amd64/lib/jrt-fs.jar with the one from Oracle JDK.
    You may also try to recompile the openjdk-9 source using the advised option "--release 8".

    Anyway I advice to vote up this issue on the above link to attract more attention by dev team.

    这篇关于由于新的文件夹结构,在Linux上的Intellij IDEA中正确设置Java 9作为SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆