scalameta/metals

Simple Java Project not working

FlorianKirmaier opened this issue · 7 comments

Describe the bug

Actually, I was trying to create a sample project, for a more complicated bug, but then I noticed that my "minimal project" doesn't seem to work without any changes

https://github.com/JPro-one/HelloJPro.

Screenshot 2023-01-11 at 22 21 58

This is a pure Java project. The question is, is that supposed to work?
I'm asking because Metals it's a scala language server.

When I look into my other projects, the Java parts sometimes work with Metals/Bloop, and sometimes not.
But Metals/Bloop is always trying to compile it, so I guess it's in the scope of the project.
So, I thought I start by posting the most simple case as a bug report.

If you wonder why I post this, I usually have a lot of mixed Scala/Java projects.

Expected behavior

No response

Operating system

macOS

Editor/Extension

None

Version of Metals

v1.21.0

Extra context or search terms

No response

Thanks for reporting! We do have a limited Java support and it should always compile correctly, so this might be soemthing that we need to take a look into.

Thanks for reporting! We do have a limited Java support and it should always compile correctly, so this might be soemthing that we need to take a look into.

Great to hear!
Tell me when you need further Infos.

I've just retested it for the record, and I still have the same/similar problem on very basic Java-Projects.
Screenshot 2023-06-15 at 14 42 59
If I would guess, any Java projects with modules kind of fail.

Looks like we are missing javafx in the classpath. Currently, we need the Metals Java classpath to correspond to the one you need to use. Could you make sure that metals.javaHome is set to the proper Java home? You should be prompted to replace the Bloop configuration. You might also need to reimport the project, not sure.

Let me know if any of that helps you out!

I've set the JavaHome, but it doesn't help.

Nowadays, JavaFX is usually (except for some weird JDK distributions) not part of the JDK.
We use JavaFX exclusively as a Library. It also doesn't find other libraries - so this is not limited to JavaFX.
It generally doesn't use the libraries - but according to the screenshot, it finds the library in the dependency.

I would guess that the java-compiler is somehow called wrongly.
Screenshot 2023-06-16 at 15 50 31

Screenshot 2023-06-16 at 15 49 13

Looks like the source of issues is module-info.java which isn't proeprly handled in Bloop. I am getting file should be on source path, or on patch path for module, not sure what that is about yet. I will try and transfer the issue to Bloop.

Thank you!
This seems like the correct description of what is failing.
Guess it's also worth mentioning, that this is a Gradle project - so this might be a error specific on how Gradle is handled.