redhat-developer / redhat-developer/vscode-java

java is not on the classpath message in a non-Android Gradle project

未关闭
#1,876 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

classpath Gradle
主要语言
TypeScript
星标
2.3k
派生
546
平均合并
20 小时 1 分钟
30 天内合并 PR
11

描述

The error is:
.java is not on the classpath of project xxxx, only syntax errors are reported

Environment
  • Operating System: MacOs, Catalina 10.15.7
  • JDK version:

openjdk version "11.0.9" 2020-10-20 LTS
OpenJDK Runtime Environment Zulu11.43+21-CA (build 11.0.9+11-LTS)
OpenJDK 64-Bit Server VM Zulu11.43+21-CA (build 11.0.9+11-LTS, mixed mode)

  • Visual Studio Code version: 1.55.2
  • Java extension version: 0.76.0
Steps To Reproduce
  1. Import Gradle project
  2. Open .java file

Here are some other messages that I get:

Could not run phased build action using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-6.4.1-all.zip'.
The newly created daemon process has a different context than expected.
It won't be possible to reconnect to this daemon. Context mismatch:
Java home is different.
Wanted: DefaultDaemonContext[uid=null,javaHome=/nix/store/g4lwpql3c2lyw7m04wxbrx72x9kh0w9j-zulu11.43.21-ca-jdk11.0.9,daemonRegistryDir=/Users/xxxxx/.gradle/daemon,pid=49638,idleTimeout=null,priority=NORMAL,daemonOpts=--add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.base/java.lang=ALL-UNNAMED,--add-opens,java.base/java.lang.invoke=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,-XX:MaxMetaspaceSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=utf8,-Duser.country=GB,-Duser.language=en,-Duser.variant]
Actual: DefaultDaemonContext[uid=415ee891-9ddf-491a-a2cb-c7cee384bfab,javaHome=/nix/store/g4lwpql3c2lyw7m04wxbrx72x9kh0w9j-zulu11.43.21-ca-jdk11.0.9/zulu-11.jdk/Contents/Home,daemonRegistryDir=/Users/xxxxx/.gradle/daemon,pid=49652,idleTimeout=10800000,priority=NORMAL,daemonOpts=--add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.base/java.lang=ALL-UNNAMED,--add-opens,java.base/java.lang.invoke=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,-XX:MaxMetaspaceSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=utf8,-Duser.country=GB,-Duser.language=en,-Duser.variant]

Additional Informations

I am also trying to get Emacs work with this project. I have lots of NullPointerExceptions from the plugins in the lsp-log there.
I've read that Gradle projects for Android are not supported. Well, this one is not for Android.
Here is what I put in build.gradle:

plugins {
id 'java'
id 'eclipse'
id 'idea'
...

I also put this (to have the classes copied in bin and not only in the build directory:

task copyBuildToBin(type: Copy) {
from 'build/classes/java/'
from 'build/resources/'
into 'bin/'
}

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先复现 issue 中的 Gradle 导入,在 VS Code Java 扩展中打开一个 .java 文件,并检查项目的 build.gradle。将 classpath 错误与报告中的 Gradle 守护进程 Java-home 不匹配以及 language server 的 NullPointerExceptions 进行比较。当非 Android Gradle 项目能够在没有 classpath 警告的情况下导入,并且 Java 文件获得完整支持而不只是语法支持时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
java, vscode
领域
build-system, developer-experience
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。