vscode-java
vscode-java copied to clipboard
Building Java project shows error: "Build failed, do you want to continue?"
Building Java project shows error: "Build failed, do you want to continue?" when the build is actually completed because when I click "Proceed" it will run updated version of my code and autobuild enabled when I type new code. javatest.zip
Environment
- Operating System: Windows 10 Pro (1709)
- JDK version: 9.0.4
- Visual Studio Code version: 1.21.1
- Java extension version: 0.22.0
Steps To Reproduce
- Open attached java project in Visual Studio Code with Java Extensions Pack installed
- Start debugging by F5
Current Result
Build error
Expected Result
No error
Additional Informations
I have another project built with this extension and it builds without any error.
this sample project builds without errors on my mac. I can run the Main class, although it stops because it can't connect to the socket, but that's irrelevant to this problem.
The log you attached references a bunch of classes that are not present in your sample.
message: Helper cannot be resolved;code: 570425394
message: Device cannot be resolved to a type;code: 16777218
message: ClientThread cannot be resolved to a type;code: 16777218
message: ClientThread cannot be resolved to a type;code: 16777218
message: Constants cannot be resolved to a type;code: 16777218
message: Constants cannot be resolved to a type;code: 16777218
message: Constants cannot be resolved to a type;code: 16777218
message: Constants cannot be resolved to a type;code: 16777218
message: Constants cannot be resolved to a type;code: 16777218
message: Constants cannot be resolved to a type;code: 16777218
message: Constants cannot be resolved to a type;code: 16777218
message: Constants cannot be resolved to a type;code: 16777218
message: ClientThread cannot be resolved to a type;code: 16777218
message: ClientThread cannot be resolved to a type;code: 16777218
message: ClientThread cannot be resolved to a type;code: 16777218
message: Helper cannot be resolved;code: 570425394
message: Device cannot be resolved to a type;code: 16777218
message: Constants cannot be resolved to a variable;code: 33554515
message: ClientThread cannot be resolved to a type;code: 16777218
message: ClientThread cannot be resolved to a type;code: 16777218
message: ClientThread cannot be resolved to a type;code: 16777218
message: ClientThread cannot be resolved to a type;code: 16777218
message: Device cannot be resolved to a type;code: 16777218
Are those classes yours? Have you tried cleaning up the workspace directory?
This is all the classes from my another project. I don't know why they are here, maybe they compiled in shared folder but that was unwanted behavior.
Get exactly the same error when I try to build/debug a Java project of mine. After proceeding, the project seems to have been built fine. IntelliJ is also not throwing any errors when I build.
Environment Operating System: Mac OS X El Capitan JDK version: 8 Update 161 Visual Studio Code version: 1.21.1 Java extension version: 0.22.0
Any updates on this? I am having the same issue.
Builds fine from the command line. It's only when running VS Code Debug this occurs.
Same problem here (works perfect in the past, but this problem occures weeks ago by an update!)
Same problem here, hadnt made any changes to the project. Building without problemas in IntelliJ
Guys, if you want to help please:
- check whether cleaning the workspace helps or not (and report it back here)
- provide sample projects consistently reproducing the problem
Ok, cleaning workspace seems to have fixed it (at least by now). Can't provide sample project!
Thanks for your help
@fbricon That seems to have solved it for me as well!
I don't have a sample project to share unfortunately.
However, I think this issue appeared right after update to VS Code 1.22.1
I've deleted the complete workspaceStorage but the problem still there. Attached you will find a small Test Project where the error appears.
Well after pressing "Proceed" the code executed normal!
Ok, solved it, the problem caused by a compile error in the Java Code. If I compile the code on the terminal the error was reported and I can fix it.
But why are compile errors not reported by the extension in the problem tab !?!?!
Yeah, I couldn't find any logs whatsoever for the failed build process.
Run into same error, please clone https://github.com/wpcfan/gtm.git
and cd backend
-> code .
, if we debug the project, the error will show up
Get exactly the same error when I try to debug a Maven Java project of mine (Ubuntu18.04). "Build Failed".
"Build Failed" will not display when I save my workspace as a file
Temporary solution
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug (Launch)-ProviderUserApplication<microservice-simple-provider-user>",
"request": "launch",
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopOnEntry": false,
"preLaunchTask": "package", //package before debug
"mainClass": "com.itmuch.cloud.study.ProviderUserApplication",
"projectName": "microservice-simple-provider-user",
"args": ""
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "package",
"type": "shell",
"command": "mvn package",
"group": "build"
},
{
"label": "test",
"type": "shell",
"command": "mvn -B test",
"group": "test"
}
]
}
Maybe your code has error,check it here.This is my case.
I am getting this same error. I have a maven project that builds fine from the command line, and if I press the "Proceed" button will debug correctly.
Same here. Cleaning up the workspace did not help. Project compiles fine on command line. No errors shown on the trace console in vscode.
The project is a multi-module project that includes an Android submodule (which I don't care about when using vscode). I know that Android projects are not supported by the extension. I tried to exclude the Android submodule from the vscode context (using files.exclude), but the Java extension seems not to support this. The directory in the project basically vanishes from view, but is still checked and issues appearing in the warnings list.
The language server log shows:
!ENTRY org.eclipse.jdt.ls.core 4 0 2018-05-25 10:57:21.048
!MESSAGE Error occured while building workspace. Details:
message: The project was not built since its build path is incomplete. Cannot find the class file for android.os.Handler. Fix the build path then try building this project;code: 0
message: The type android.os.Handler cannot be resolved. It is indirectly referenced from required .class files;code: 16777540
..which is expected (I think) due to the missing Android support.
So I think this is a feature request: it should be possible to exclude modules/directories for the language server.
This also does not work and makes no difference:
"java.import.exclusions": [
"**/android/**"
Is there any way of excluding a directory from the language server?
Same Problem.
The project is https://github.com/swagger-api/swagger-codegen
mvn complie success, but get error when debug
Maven and jdk version
Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-25T03:49:05+08:00)
Maven home: C:\apache-maven-3.5.3\bin..
Java version: 1.8.0_172, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_172\jre
Default locale: en_US, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Same Problem too. Yet it looks like to be fixed on my problem. 1.I tried to change the jdk.home path from jdk10 to jdk 8, and it works fine!!!! 2.I have tried to clean the workspace before, but nothing changed. 3.maven on my vscode is working fine, compiling is also good, but vscode java debug is always failed.
I have been tearing my hear out with this issue, clearing the workspace has fixed it for me.
I was getting lots of errors related to another project. I can't recall but the other project was a project i used as a template for this one, so it was either that those files were at one time in the workspace and were no-longer, or I had previously opened that project with VS code.
Either way, that the time, the files were not in the workspace any more but the build was showing errors relating to them, deleting the workspace completely solved the issue but its obviously not a permanent fix as it could return. It seems the workspace is keeping residual class/java files behind that are no-longer relevant.
For now, I can continue without the build error. So i'm happy. 👍
Is the wiki out of date? The "cleaning the workspace" instructions don't seem to make sense any more (there's nothing that says "Executing ..." anywhere in the developer tools console).
@dsyer entirely possible some instructions are stale, but the overall idea of deleting the workspace directory is still valid. We'll look into it
Thanks. I can see the workspace storage directories, but I don't have a way to know which one is relevant to my current workspace. Also, maybe you could clarify what "clean" means? Is it literally just "delete the whole directory"?
@dsyer it's indeed hard to see which one corresponds to your workspace. So the simplest is to delete the whole directory.
but I guess we can change the directory naming scheme to add the current folder name as a suffix to the path hash, to make it easier to identify
I had the same issue, and was able to fix it by clearing my workspace directory.
@dsyer @fbricon The instructions are indeed stale. However if you open the Java Language Server logs (> Java: Open Java Language Server log file
), you can find -data
flag somewhere in the file.
Deleting everything in the workspaceStorage/
folder did help. Make sure you reload your window after doing it though.
I'm having the same issue... Cleaning the workspace does not help. Interesting is if a hit proceed it works fine...
@augustocdias What is your VSCode java version?
@yaohaizh sorry for taking too long to reply. I'm using the latest stable versions for all. All extensions updated and also latest stable VSCode