question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

jdt.ls cannot autocomplete third-party libraries

See original GitHub issue

Editor: neovim 0.4.0-DEV with coc-java. OS: Archlinux. build tool: Gradle. Gradle version:

------------------------------------------------------------
Gradle 5.2.1
------------------------------------------------------------

Build time:   2019-02-08 19:00:10 UTC
Revision:     f02764e074c32ee8851a4e1877dd1fea8ffb7183

Kotlin DSL:   1.1.3
Kotlin:       1.3.20
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          1.8.0_202 (Oracle Corporation 25.202-b26)
OS:           Linux 5.0.2-arch1-1-ARCH amd64

build.gradle:

/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Java project to get you started.
 * For more details take a look at the Java Quickstart chapter in the Gradle
 * User Manual available at https://docs.gradle.org/5.2.1/userguide/tutorial_java_projects.html
 */

plugins {
    // Apply the java plugin to add support for Java
    id 'java'

    id 'eclipse'
    // Apply the application plugin to add support for building an application
    id 'application'
}

sourceCompatibility = 1.8

repositories {
    // Use jcenter for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

dependencies {
    // This dependency is found on compile classpath of this component and consumers.
    implementation 'com.google.guava:guava:27.0.1-jre'
    implementation 'commons-cli:commons-cli:1.4'
    implementation 'com.squareup.okhttp3:okhttp:3.14.0'

    // Use JUnit test framework
    testImplementation 'junit:junit:4.12'
}

// Define the main class for the application
//mainClassName = 'm3u8Downloader.App'

project structure:

.
├── build.gradle
├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
    ├── main
    │   ├── java
    │   │   ├── m3u8Downloader
    │   │   │   ├── App.java
    │   │   │   └── Downloader.java
    │   │   └── m3u8parser
    │   │       ├── FormatException.java
    │   │       └── m3u8parser.java
    │   └── resources
    └── test
        ├── java
        │   └── m3u8Downloader
        │       └── AppTest.java
        └── resources

12 directories, 11 files

log:

!SESSION 2019-03-21 09:40:32.572 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_202
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Command-line arguments:  -data /home/xxxxxx/.config/coc/extensions/coc-java-data/jdt_ws_266a429de305e6bac55f8d917736af7f

!ENTRY org.eclipse.jdt.ls.core 1 0 2019-03-21 09:40:34.104
!MESSAGE class org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin is started

!ENTRY org.eclipse.jdt.ls.core 1 0 2019-03-21 09:40:34.204
!MESSAGE Main thread is waiting

!ENTRY org.eclipse.jdt.ls.core 1 0 2019-03-21 09:40:34.226
!MESSAGE >> initialize

!ENTRY org.eclipse.jdt.ls.core 1 0 2019-03-21 09:40:34.227
!MESSAGE Initializing Java Language Server 0.36.0.201903182216

!ENTRY org.eclipse.jdt.ls.core 1 0 2019-03-21 09:40:34.248
!MESSAGE >> initialized

!ENTRY org.eclipse.jdt.ls.core 1 0 2019-03-21 09:40:34.273
!MESSAGE Creating the Java project jdt.ls-java-project

!ENTRY org.eclipse.jdt.ls.core 1 0 2019-03-21 09:40:34.661
!MESSAGE Finished creating the Java project jdt.ls-java-project

!ENTRY org.eclipse.jdt.ls.core 1 0 2019-03-21 09:40:34.920
!MESSAGE Workspace initialized in 682ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2019-03-21 09:40:34.978
!MESSAGE >> workspace/didChangeConfiguration

!ENTRY org.eclipse.jdt.ls.core 1 0 2019-03-21 09:40:34.980
!MESSAGE >> registerFeature 'workspace/didChangeWatchedFiles'

!ENTRY org.eclipse.jdt.ls.core 1 0 2019-03-21 09:40:34.990
!MESSAGE >>New configuration: {java={jdt={ls={vmargs=-noverify -Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication}}, errors={incompleteClasspath={severity=ignore}}, configuration={checkProjectSettingsExclusions=true, updateBuildConfiguration=interactive}, trace={server=off}, import={gradle={enabled=false}, maven={enabled=true}, exclusions=[**/node_modules/**, **/.metadata/**, **/archetype-resources/**, **/META-INF/maven/**]}, referencesCodeLens={enabled=false}, signatureHelp={enabled=false}, implementationsCodeLens={enabled=false}, format={enabled=true, comments={enabled=true}, onType={enabled=true}}, autobuild={enabled=true}, maxConcurrentBuilds=1.0, completion={enabled=true, overwrite=false, guessMethodArguments=true, favoriteStaticMembers=[org.junit.Assert.*, org.junit.Assume.*, org.junit.jupiter.api.Assertions.*, org.junit.jupiter.api.Assumptions.*, org.junit.jupiter.api.DynamicContainer.*, org.junit.jupiter.api.DynamicTest.*, org.mockito.Mockito.*, org.mockito.ArgumentMatchers.*, org.mockito.Answers.*], importOrder=[java, javax, com, org]}, progressReports={enabled=true}, codeGeneration={hashCodeEquals={useJava7Objects=false, useInstanceof=false, useBlocks=false, generateComments=false}}}}

!ENTRY org.eclipse.jdt.ls.core 1 0 2019-03-21 09:40:34.992
!MESSAGE >> document/didOpen

!ENTRY org.eclipse.jdt.ls.core 1 0 2019-03-21 09:40:35.007
!MESSAGE Classpath is incomplete. Only syntax errors will be reported for file:///home/xxxxxxx/UNIX_Programming/java/m3u8Downloader/src/main/java/m3u8Downloader/Downloader.java

!ENTRY org.eclipse.jdt.ls.core 1 0 2019-03-21 09:40:35.728
!MESSAGE begin problem for /Downloader.java

!ENTRY org.eclipse.jdt.ls.core 1 0 2019-03-21 09:40:35.729
!MESSAGE 0 problems reported for /Downloader.java

!ENTRY org.eclipse.jdt.ls.core 1 0 2019-03-21 09:40:35.733
!MESSAGE Reconciled 0, validated: 1. Took 228 ms

.project in data directory:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>jdt.ls-java-project</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
    <linkedResources>
        <link>
            <name>src/m3u8Downloader/App.java</name>
            <type>1</type>
            <location>/home/xxxxxx/UNIX_Programming/java/m3u8Downloader/src/main/java/m3u8Downloader/App.java</location>
        </link>
        <link>
            <name>src/m3u8Downloader/Downloader.java</name>
            <type>1</type>
            <location>/home/xxxxxx/UNIX_Programming/java/m3u8Downloader/src/main/java/m3u8Downloader/Downloader.java</location>
        </link>
    </linkedResources>
</projectDescription>

.classpath in data directory:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    <classpathentry kind="output" path="bin"/>
</classpath>

Please help me… I haven’t found a solution for a long time.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
NitroCaocommented, May 21, 2019

I’m using coc-java plugin in coc.nvim completion plugin, which uses jdt.ls. And everything works fine. You can have a try.

Hello everyone. I am running Vim 8.1 on Arch and using ALE as the client for eclipse.jdt.ls. Unfortunately, even though linting and autocomplete are working for the core Java libraries, I can neither get auto-completion for third party libraries, similarly to what is shown by @JayceCao above, nor does it seem like there is any activity regarding Gradle when I open the project, as a clean ~/.gradle folder remains unpopulated. Even when I call Gradle to download the dependencies, I still get no autocompletion on the third party libraries, even though they are present. This is surely an issue with my configuration so I come here searching for some guidance. My questions are as follows, does autocomplete for third party libraries still work for you on eclipse.jdt.ls 0.35+, @JayceCao? Did setting GRADLE_USER_HOME and cleaning up ~/.gradle fix the issue for you @orlandoc01? Should eclipse.jdt.ls trigger Gradle when opening a project? Thank you for your time.

0reactions
Rheisencommented, Jun 13, 2020

Ah ok, I suppose I could download the jars manually for my projects, thanks! I am using gradle with coc-java and neovim when experiencing this problem. With vscode everything works fine, but with nvim I get package not found and symbol missing errors. I believe that shouldn’t be the case and it shouldn’t require manually downloading jars, but I’m having a hard time finding out why it is happening.

Read more comments on GitHub >

github_iconTop Results From Across the Web

r/vim - Auto-complete for third party libraries on Java with ALE ...
Hello everyone. Is anyone successfully using Vim with ALE and eclipse.jdt.ls to get auto-completion on third party Java libraries?
Read more >
Appcode doesn't autocomplete third party libraries
Some of the libraries that I use on the application doesn't work with AppCode autocomplete. I can't access the base code or do...
Read more >
Eclipse Community Forums: Java Development Tools (JDT)
For one of the two the AutoComplete feature does not seem to work anymore. And I can't see anything wrong with my settings....
Read more >
LSP Java
Emacs Java IDE using Eclipse JDT Language Server. ... to use Eclipse Che JDT LS. lsp-java-java-path - Path of the java executable. lsp-java-progress-string ......
Read more >
Gradle for Java - Visual Studio Marketplace
(Nested Gradle project discovery is not enabled by default, set "gradle. ... java.jdt.ls.java.home : Absolute path to JDK home folder as per ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found