None of my Java projects are being built properly by the language server.
All my projects are failing, even previously working projects
Fundamentally, I'm getting JRE errors such as The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files.
I'm unable to open standalone Java files, vanilla Java projects and packages, or Maven projects properly.
Here are some things I've tried:
JAVA_HOME, java.home to jEnv symlinks .jenv/versions/14.0 and directly to the JDK installations themselves /usr/local/Cellar/openjdk/14.0.1/./Library/Java/JavaVirtualMachines/...I'm using jenv to manage my JDKs, and I've enabled the export and maven plugins. Compilation with javac and running with java works just fine.
.java file and define a class.redhat.java/client.log.2020-08-26
client.log
Plugin is unable to find JRE classes which causes compilation errors for the server.
Plugin should be able to link to JRE classes and compile properly, providing Intellisense without any errors.
Seems to be related to #483, but the logs produced are different:
{
"resource": "/Users/bryan/Library/Application Support/Code/User/workspaceStorage/1b823d7928b6aa52270ae85776f4b072/redhat.java/jdt_ws/Labs_ad3d80ac",
"owner": "_generated_diagnostic_collection_name_#2",
"code": "0",
"severity": 8,
"message": "The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project",
"source": "Java",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 1,
"endColumn": 1
}
@snjeza see this exception from the log:
{
message: '[Error - 10:59:33 PM] 26 Aug 2020, 10:59:33 pm An internal error occurred during: "Update Installed JREs".\n' +
'null\n' +
'java.lang.NullPointerException\n' +
'\tat org.eclipse.jdt.internal.launching.JavaClasspathVariablesInitializer.initialize(JavaClasspathVariablesInitializer.java:50)\n' +
'\tat org.eclipse.jdt.internal.launching.LaunchingPlugin$VMChanges.rebind(LaunchingPlugin.java:319)\n' +
'\tat org.eclipse.jdt.internal.launching.LaunchingPlugin$VMChanges.access$0(LaunchingPlugin.java:315)\n' +
'\tat org.eclipse.jdt.internal.launching.LaunchingPlugin$VMChanges$1.run(LaunchingPlugin.java:301)\n' +
'\tat org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:41)\n' +
'\tat org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:736)\n' +
'\tat org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2292)\n' +
'\tat org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2317)\n' +
'\tat org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5895)\n' +
'\tat org.eclipse.jdt.internal.launching.LaunchingPlugin$VMChanges.doit(LaunchingPlugin.java:305)\n' +
'\tat org.eclipse.jdt.internal.launching.LaunchingPlugin$JREUpdateJob.run(LaunchingPlugin.java:402)\n' +
'\tat org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)\n',
level: 'info',
timestamp: '2020-08-26 22:59:33.198'
}
@bryanmylee can you please share your vscode settings.json?
@bryanmylee Could you try the following:
rm -rf "/Users/bryan/Library/Application Support/Code/User/globalStorage/redhat.java"
rm -rf "/Users/bryan/Library/Application Support/Code/User/workspaceStorage"
@fbricon
{
"workbench.colorTheme": "Night Owl",
"workbench.iconTheme": "material-icon-theme",
"workbench.editor.showTabs": true,
"breadcrumbs.enabled": true,
"diffEditor.ignoreTrimWhitespace": false,
"editor.lineHeight": 20,
"editor.rulers": [100, 120],
"editor.fontLigatures": true,
"editor.suggestSelection": "first",
"editor.fontFamily": "\"Fira Code\", \"SF Mono\", monospace",
"editor.minimap.enabled": false,
"explorer.confirmDelete": false,
"explorer.confirmDragAndDrop": false,
"extensions.ignoreRecommendations": true,
"files.trimTrailingWhitespace": true,
"scm.diffDecorations": "gutter",
"scm.inputFontFamily": "editor",
"terminal.integrated.shell.osx": "zsh",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"files.exclude": {
"**/.classpath": true,
"**/.project": true,
"**/.settings": true,
"**/.factorypath": true
},
// Languages
"java.semanticHighlighting.enabled": true,
"java.trace.server": "messages",
"sonarlint.rules": {
"java:S106": {
"level": "off"
}
},
"python.languageServer": "Microsoft",
"python.diagnostics.sourceMapsEnabled": false,
"emmet.includeLanguages": {
"javascript": "javascriptreact",
},
"eslint.validate": [
"javascript",
"svelte",
],
"javascript.updateImportsOnFileMove.enabled": "always",
"typescript.updateImportsOnFileMove.enabled": "always",
"[javascript]": {
"editor.tabSize": 2,
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"r.bracketedPaste": true,
"vim.leader": ",",
"vim.easymotion": true,
"vim.useSystemClipboard": true,
"vim.useCtrlKeys": true,
"vim.hlsearch": true,
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["<Leader>", "l"],
"commands": [":nohl"]
},
{
"before": ["<Space>"],
"after": ["^"]
},
{
"before": ["<CR>"],
"after": ["$"]
},
{
"before": ["U"],
"after": ["<C-r>"]
},
{
"before": ["j"],
"after": ["g", "j"]
},
{
"before": ["k"],
"after": ["g", "k"]
},
{
"before": ["<C-e>"],
"after": ["3", "<C-e>"]
},
{
"before": ["<C-y>"],
"after": ["3", "<C-y>"]
},
{
"before": ["Z", "Z"],
"commands": [":wq"]
},
{
"before": ["g", "a"],
"commands": ["wwm.aligncode"]
},
{
"before": ["g", "H"],
"commands": ["editor.action.quickFix"]
},
{
"before": ["g", "<Space>"],
"commands": ["editor.action.sourceAction"]
},
{
"before": ["]", "g"],
"commands": ["editor.action.marker.prev"]
},
{
"before": ["[", "g"],
"commands": ["editor.action.marker.next"]
},
],
"vim.easymotionMarkerBackgroundColor": "darkslategray",
"vim.easymotionMarkerForegroundColorOneChar": "white",
"vim.easymotionMarkerForegroundColorTwoChar": "lightgray",
"vim.easymotionMarkerFontWeight": "normal",
"vim.replaceWithRegister": true,
"vim.camelCaseMotion.enable": true,
}
@snjeza I've done so and I am still getting the same results. I've tried wiping and reinstalling VSCode, including its support files, if that helps.
For some additional context, the language of coc-java for coc.nvim works with my nvim install.
@bryanmylee could you add the following property to your settings.json:
"java.home": "/usr/local/Cellar/openjdk/14.0.1/",
and send your logs
Added the java.home property to my brew install of openjdk, but still facing the same issues.
I am also getting this issue.
I've tried everything above, as well as reverting to older versions of the extension and running mvn clean eclipse:clean eclipse:eclipse to try force recreation of project settings with no success. Also tried various JDKs, including openJDK and Adopt.
In VSCode open Command Palette: Java: Clean Java Language Server Workspace -> then restart VSCode fixed this issue for me
Having the same problem on a Linux, I wonder how to verify that the a Java environment was indeed identified. Using the command "Java: Configure Java Runtime" and looking at the tab "Java tooling Runtime", it is empty despite having
"java.home": "/home/me/tools/Store/jdk-11",
"java.configuration.runtimes": [
{
"name": "JavaSE-11",
"path": "/home/me/tools/Store/jdk-11"
},
{
"name": "JavaSE-1.8",
"path": "/home/me/tools/Store/jdk-8",
"default": true
}
]
in my settings.json. Though I do see a java process with some .../.vscode/extensions/redhat.java-0.74.0/... parts on the command line, which seems to indicate this part is actually working.
I could not find this mentioned anywhere, but the path is correct if it contains ./bin/javac and the other java commands?
Most helpful comment
In VSCode open Command Palette: Java: Clean Java Language Server Workspace -> then restart VSCode fixed this issue for me