3

SOLUTION : my bad it was a build.gradle problem, by removing 'org.javamodularity.moduleplugin' version 1.8.12 from it, coc-java worked again !! But thank you all for your help !

I am working with Neovim and use coc.nvim for autocompletion, diagnosises, etc.

For Java, I am using coc-java and everything worked fine until I tried to code with JavaFX. coc.nvim doesn't recognize it :

package my.project.package;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start(Stage stage) throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader(Main.class.getResource("welcome.fxml"));
        Scene scene = new Scene(fxmlLoader.load(), 1000, 1000);
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch();
    }
}

In my editor, hovering any import from javafx display the error The type javafx.package.Module is not accessible (Java 16778666) (same thing for anything related to these imports of course). However, this program works fine when I execute it.

So I have tried to change my language server parameters, here is my coc-settings.json :

{
    "java.home": "/home/yayel4289/.jdks/jdk-20.0.2",
    "java.jdt.ls.vmargs": "-Xmx1G -XX:+UseG1GC --module-path=/usr/share/openjfx/lib --add-modules=javafx.controls,javafx.fxml,javafx.base,javafx.graphics,javafx.media",
    "java.project.referencedLibraries": [
        "/usr/share/openjfx/lib/*.jar"
    ],
    "java.trace.server": "verbose",
}

I also have logs in ~/.config/coc/extensions/coc-java-data, it is too heavy to put it here but would it help in any way?

10
  • 1
    "coc.nvim doesn't recognize it" -> there is not enough info here to understand what went wrong or assist you. For debugging help you will need to supply a minimal reproducible example -> a small program (formatted as code in the question) including everything needed to replicate the issue via copy-and-paste with instructions detailed enough that somebody could replicate the problem. Commented Apr 4 at 16:50
  • Thank you for your answer jewelsea, I just edited my message, is it better ? I really appreciate your help Commented Apr 4 at 17:28
  • Yes, it is better. As I understand it, your issue is with how to get JavaFX imports recognized by an editor you are using (neovim). I don't know neovim though, so cannot help you. Getting started instructions for JavaFX are at openjfx.io, but that don't cover neovim. Commented Apr 4 at 18:13
  • Ok thank you anyway, I'll wait for someone else thx. Could you at least upvote it so it has more chance to be seen by the others ? Commented Apr 4 at 18:17
  • 1
    @Slaw Yes coc-java recognizes everything else (like List, Junit, ...) but not JavaFX, I believe it is because it's not in the 'base' dependencies. So to answer your last quesiton : only JavaFX have this problem. However, after deleting ~/.config/coc/extensions/coc-java-data, coc-java now recognize classes like Scene, Stage, etc (there is a description and it is in the autocompletion buffer) but it still in red and coc-java doesn't recognize any method or attributes these objects can have (like getStyleSheets(), ...) Commented Apr 5 at 12:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.