redhat-developer / redhat-developer/vscode-java

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

Open
#1,876 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

classpath Gradle
Dominant language
TypeScript
Stars
2.3k
Forks
546
Avg merge
20h 1m
Merged PRs (30d)
11

Description

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/'
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Gradle import from the issue, opening a .java file in the VS Code Java extension, and reviewing the project's build.gradle. Compare the classpath error with the reported Gradle daemon Java-home mismatch and the language-server NullPointerExceptions. Done means a non-Android Gradle project imports without the classpath warning and Java files are fully supported rather than syntax-only.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, vscode
Domain
build-system, developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.