Open Nacandcheese opened 3 years ago
Ignore the mcfunction plugin in the image of the versions, the plugin has nothing to do with the issue from what I have tested.
Opening a package folder 'Chapter10' as root doesn't work, you must open a parent directory containing the packages.
For example, you could create another root folder such as 'Exercise', and put 'Chapter10' folder under it, then open 'Exercise' in VS Code.
├── Exercise
│ └── Chapter10
│ ├── Test.java
│ └── Person.java
That is rather odd, I have been running from a Programming 2 folder this entire time and it still refuses to work. Even adding another folder wouldn't work. I can't get the customer file to see that it is an extension of Person. It basically will not even read from the files in the package.
In VS Code just right-click on the src (the folder which contains .java files) folder and select the " Add folder to Java source path" option. If it didn't' worked, then try to remove it first by selecting "remove the folder from Java source path" and then adding it again.
Restart once when done. Hope it works for you.
It keeps telling me to edit the pom.xml file
Same issue as @retbleed. Error is "Unsupported operation: Please use pom.xml to manage the source directories of maven projects.". Cleaning the workspace fixed the issue.
Please use build.gradle file to manage the source directories of gradle project.
when dealing with an Android APK project and trying to do "Add folder to Java source path"
I was working with multi-module Quarkus Maven project. I was facing the same issue. I just hit Java: Clean Java language server Workspace
. After reloading the workspace, the issue was no more.
Whenever there is pom.xml
or build.gradle
in my root project, this error happen.
And I can't manage an Android project without maven or gradle.
It keeps telling me to edit the pom.xml file i followed this and it worked for me https://stackoverflow.com/questions/9752972/how-to-add-an-extra-source-directory-for-maven-to-compile-and-include-in-the-bui
Press "Ctrl + Shift + P", choose "java : Clean java Language Server workspace". If not run, right click on src, choose "add folder to java source path"
This solution works for me with correct gradle file.
Press "Ctrl + Shift + P", choose "java : Clean java Language Server workspace". If not run, right click on src, choose "add folder to java source path"
This solution works for me with correct gradle file.
Press "Ctrl + Shift + P", choose "java : Clean java Language Server workspace". If not run, right click on src, choose "add folder to java source path"
This solution works for me with correct gradle file.
I tried the above solution and it resolved issue successfully. My project is with Maven.
Experiencing the issue described here on my machine (MacOS Ventura 13.2.1, JDK17) with a multi-module maven project.
I have tried the following to no avail:
"java.jdt.ls.java.home": "/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home",
to my settings.json fileClean java Language Server workspace
src
project and clicking Add Folder to Source Path
, which throws the error Unsupported operation. Please use pom.xml file to manage the source directories of maven project
.pom.xml
by adding a space to force VSCode to reloadDoes anyone have any other suggestions to try?
I have a problem where I have some Java Workspaces
And when I click the run button it runs the other projects Main.java
. I have to remove the other one from the source path to run the first one, otherwise the wrong one runs even though the run button is on the first Main.java
file.
Dumb question, Are the files inside the SRC folder? That was it for me....
Experiencing the issue described here on my machine (MacOS Ventura 13.2.1, JDK17) with a multi-module maven project.
I have tried the following to no avail:
- Adding
"java.jdt.ls.java.home": "/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home",
to my settings.json file- Ctrl + Shift + P ->
Clean java Language Server workspace
- Right clicking my
src
project and clickingAdd Folder to Source Path
, which throws the errorUnsupported operation. Please use pom.xml file to manage the source directories of maven project
.- Changing my
pom.xml
by adding a space to force VSCode to reloadDoes anyone have any other suggestions to try?
@doulikecookiedough same to me , did you get any solution?
@shenguanjiejie Unfortunately no. I abandoned using VSCode for my Java projects, moved onto IntelliJ IDEA Studio (Community Edition). Happy to try out another solution if anyone has any suggestions, but I don't have scope at this time to dig into it and investigate further.
@doulikecookiedough I have fixed this problem. check your ~/.m2 directory , If there not have ~/.m2/settings.xml, find it and copy to there. then reload vscode.
The solution for me. If you have this structure (with kotlin gradle):
1 - Compile the gradle project even if it is not in the classpath of the project. 2 - Add them to the classpath of the parent: in case of kotlin gradle rootProject.name = "main" include("microservice 1/module","microservice 2/module") 3 - Compile the gradle of the parent (the children will be compiled) 4 - java : Clean java Language Server workspace
Every time I try to create a package for my java classes so I can finish my projects for school, errors like this occur: When I finally try to run the program, I get an even more infuriating message: It hurts me to be unable to properly test my code, even if I know I did well. It has been giving me anxiety for quite a while now, so I'm quite surprised this has slipped under the radar for so long.
Operating System:
JDK version: 15.0.2
Visual Studio Code version:
Java extension version:
Steps To Reproduce
Here is my code as an example of what can cause it. Try compiling either Test.java or Customer.java and it should be quite apparent. Chapter10.zip
Current Result
A warning that constantly results in weird compiler errors
Expected Result
A working class that I can use