无法在Linux上的Intellij中指定SDK

huangapple go评论80阅读模式
英文:

Can't specify SDK in Intellij on Linux

问题

我正在运行在Linux(Ubuntu)机器上的IntelliJ IDEA 2017.1.6专业版,但它不允许我为任何Java项目选择SDK。

每当我启动该程序并转到“创建新项目” Java时,没有可用的SDK。如果我尝试在新建项目时指定我的JDK安装位置(我有几个),它总是会失败,显示相同的错误:
无法在Linux上的Intellij中指定SDK

我尝试过指定以下位置:

  • /usr/lib/jvm/
  • /usr/lib/jvm/java-11-openjdk-amd64/
  • /usr/lib/jvm/java-8-openjdk-amd64/
  • /usr/lib/jvm/openjdk-11/
  • /usr/lib/jvm/jdk-14.0.2/
  • /usr/lib/jvm/default-java
  • /usr/lib/jvm/java-1.11.0-openjdk-amd64
  • /usr/lib/jvm/java-1.8.0-openjdk-amd64

(最后三个都只是符号链接)

我知道我已经为我的默认Java版本安装了一个JDK。我可以通过命令行编译和运行代码:

justin@stephanie:~/temp$ ls
HelloWorld.java
justin@stephanie:~/temp$ javac HelloWorld.java 
justin@stephanie:~/temp$ ls
HelloWorld.class  HelloWorld.java
justin@stephanie:~/temp$ java HelloWorld
Hello,World!

readlink -f $(which java) 的输出是 /usr/lib/jvm/java-11-openjdk-amd64/bin/javajavac可执行文件的位置相同)。

我在线上查找的所有信息都表明,我应该能够选择/usr/lib/jvm/java-11-openjdk-amd64作为我的Java SDK,但却失败了。我觉得我一定对某些关键点有误解,因为我不知道为什么这不起作用。

任何帮助都将很有用,我以前从未使用过IntelliJ(我一直是Eclipse用户),在尝试了几个小时后,甚至不能在其中创建项目,这让人非常沮丧。

英文:

I am running IntelliJ IDEA 2017.1.6 Pro on a Linux (Ubuntu) machine and, it will not let me select an SDK for any Java project.

Whenever I start up the program and go to "Create a New Project" Java has no SDKs available. If go to new and try to specify where my JDKs are installed (I have a few) it always fails with the same error:
无法在Linux上的Intellij中指定SDK

I've tried specifying the locations:

  • /usr/lib/jvm/
  • /usr/lib/jvm/java-11-openjdk-amd64/
  • /usr/lib/jvm/java-8-openjdk-amd64/
  • /usr/lib/jvm/openjdk-11/
  • /usr/lib/jvm/jdk-14.0.2/
  • /usr/lib/jvm/default-java
  • /usr/lib/jvm/java-1.11.0-openjdk-amd64
  • /usr/lib/jvm/java-1.8.0-openjdk-amd64

(these last three are all just symlinks)

I know I have a JDK installed for my default Java version. I can compile and run code via command line:

justin@stephanie:~/temp$ ls
HelloWorld.java
justin@stephanie:~/temp$ javac HelloWorld.java 
justin@stephanie:~/temp$ ls
HelloWorld.class  HelloWorld.java
justin@stephanie:~/temp$ java HelloWorld
Hello, World!

The output of readlink -f $(which java) is /usr/lib/jvm/java-11-openjdk-amd64/bin/java (same location for javac exectuable).

Everything I've looked at online suggest that I should just be able to select /usr/lib/jvm/java-11-openjdk-amd64 as my Java SDK but it is failing. I feel like I must be misunderstanding something essential here as I don't know why this isn't working.

Any help would be useful, I've never used IntelliJ before (I've always been an Eclipse user) and it is very frustrating I can't even create a project in it after a couple hours of trying to mess around with it.

答案1

得分: 1

The /usr directory is mounted at /var/run/host.

You should find your jdk under /var/run/host/usr/lib/jvm.

英文:

The /usr directory is mounted at /var/run/host.

You should find your jdk under /var/run/host/usr/lib/jvm.

答案2

得分: 0

1. 请首先尝试使用较新版本的IntelliJ,最好是最新版本(目前是2020.2)。

2. 我在我的Kubuntu系统上使用2020.2版本遇到了相同的问题,通过简单地通过IntelliJ下载和安装SDK来修复了它。

英文:

1. Please try first with a newer version of IntelliJ, preferably the most current one (currently this is 2020.2)

2. I had the same problem (with version 2020.2 on my Kubuntu system) and fixed it by simply downloading and installing the SDK via IntelliJ.

huangapple
  • 本文由 发表于 2020年8月25日 14:27:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/63573136.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定