This problem might occur if you're using an older version of Java (below 11).

To fix this:

  1. Open VScode and go to Preferences -> Settings
  2. Search java.configuration.runtimes
  3. Select Edit in settings.json and paste the follwing:
"java.configuration.runtimes": [
  {
    "name": "JavaSE-1.8",
    "path": "/path/to/jdk-8",
  },
  {
    "name": "JavaSE-11",
    "path": "/path/to/jdk-11",
    "default": true
  },
  {
    "name": "JavaSE-14",
    "path": "/path/to/jdk-14",
  },
]
  1. Specify the path of the JDK which you would like to use in "path:"

usually the path of JDK for macOS is /Library/Java/JavaVirtualMachines/

  1. Set "default": true for that JDK

Suppose if you would like to use JDK 11, set "default": true in that code block.

Check for additional information here.

Answer from Praveen on Stack Overflow
🌐
Visual Studio Code
code.visualstudio.com › docs › languages › java
Java in Visual Studio Code
November 3, 2021 - VS Code supports code completion and IntelliSense for Java through Language Support for Java™ by Red Hat.
🌐
Visual Studio Code
code.visualstudio.com › docs › editing › intellisense
IntelliSense
November 3, 2021 - Visual Studio Code IntelliSense is provided for JavaScript, TypeScript, JSON, HTML, CSS, SCSS, and Less out of the box.
Discussions

Problem with IntelliSense and Java
I had a similar problem with Java and intellisense and vscode complained about something called "classpath". I started to use the "Create Java Project" option from command pallete which comes from the Java Extension Pack and it just worked. Turns out vscode needs the project files to be placed in correct folders and needs .class files to get the intellisense to work correctly More on reddit.com
🌐 r/vscode
12
8
April 15, 2019
VS Code IntelliSense support for QuPath?
Does anyone more developer-oriented than I am know how one might try to get IntelliSense in Visual Studio (VS) Code to work with QuPath and Groovy code? At the moment, I seem to be getting rudimentary auto-complete, which I assume is using information from the numerous QuPath-groovy scripts ... More on forum.image.sc
🌐 forum.image.sc
1
1
February 25, 2022
Java Intellisense doesn't work
For some weird reason during the first comp our intellisense stopped working, which made it difficult to program. Does anyone know a solution to this? More on chiefdelphi.com
🌐 chiefdelphi.com
0
January 15, 2023
intellisense failure
When I open vscode for a period of time, the intellisense fails, for example, when I enter s, the code fragment prompt of sout will not appear. After I restarted vsocde it started working fine agai... More on github.com
🌐 github.com
5
May 13, 2023
Top answer
1 of 2
22

This problem might occur if you're using an older version of Java (below 11).

To fix this:

  1. Open VScode and go to Preferences -> Settings
  2. Search java.configuration.runtimes
  3. Select Edit in settings.json and paste the follwing:
"java.configuration.runtimes": [
  {
    "name": "JavaSE-1.8",
    "path": "/path/to/jdk-8",
  },
  {
    "name": "JavaSE-11",
    "path": "/path/to/jdk-11",
    "default": true
  },
  {
    "name": "JavaSE-14",
    "path": "/path/to/jdk-14",
  },
]
  1. Specify the path of the JDK which you would like to use in "path:"

usually the path of JDK for macOS is /Library/Java/JavaVirtualMachines/

  1. Set "default": true for that JDK

Suppose if you would like to use JDK 11, set "default": true in that code block.

Check for additional information here.

2 of 2
8

Update on July 12, 2022

The Language Support for Java extension now contained a Java runtime by itself, which is used to launch the extension. That means in most cases, you don't need to specify java.home and jdt.ls.java.home.

All you need to do is use the setting java.configuration.runtimes to specify all the JDKs you have installed on your machine. Then the extension will pick the most suitable JDK according to your project's configuration.


There are two kinds of JDKs that VS Code Java will use.

I guess your problem is caused by that the Language Server cannot find a valid JDK to launch itself. (See the next paragraph about how to fix it)

  • The first kind is the JDK that is used to launch the Java Language Server, which requires JDK 11 or higher. And the setting java.home is used to specify which JDK is used to launch the Language Server. Make sure you set this setting and the Java version is >= 11.

  • The second kind is the JDKs that is used to build/launch your project. That's controlled by the setting java.configuration.runtimes, which is also mentioned by @Jayan Praveen's answer.

🌐
Visual Studio Code
code.visualstudio.com › docs › java › extensions
Java extensions for Visual Studio Code
November 3, 2021 - For example, IntelliSense for TLE function names, parameter references, signature help, Go to Definition, Peek Definition, and Peek References as well as Errors and Warnings, making it quick and easy to author Azure Resource Manager templates in VS Code. Visit Azure Extensions to find more Azure extensions. If the extensions above do not meet your requirement, you can also search for other Java ...
🌐
Visual Studio Code
code.visualstudio.com › docs › java › java-tutorial
Getting Started with Java in VS Code
November 3, 2021 - Visual Studio Code also supports more complex Java projects — see Project Management. You can use code snippets to scaffold your classes and methods. VS Code also provides IntelliSense for code completion, and various refactor methods.
🌐
Microsoft
devblogs.microsoft.com › dev blogs › microsoft for java developers › java on visual studio code update – august 2020
Java on Visual Studio Code Update – August 2020 - Microsoft for Java Developers
September 11, 2020 - On to the update. IntelliSense is one of the most frequently used VS Code features. After carefully examined current design and implementation, we were able to identify areas for improvements.
Find elsewhere
🌐
Visual Studio Code
code.visualstudio.com › docs › java › java-editing
Navigate and edit Java source code
November 3, 2021 - The extension is powered by the same Java development tools (JDT) behind Eclipse, so you can expect the same level of support. In addition, there's also AI-assisted IntelliSense called IntelliCode.
🌐
Visual Studio Code
code.visualstudio.com › docs › java › java-debugging
Running and debugging Java
November 3, 2021 - Java Language Support extension fails to start. ... Program Error: Could not find or load main class X. Program throws ClassNotFoundException. Failed to complete Hot Code Replace. Please specify the host name and the port of the remote debuggee in the launch.json. Failed to evaluate. Reason: Cannot evaluate because the thread is resumed. Cannot find a class with the main method. No delegateCommandHandler for vscode.java.startDebugSession when starting Debugger.
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
Extension Pack for Java - Visual Studio Marketplace
3 weeks ago - Extension for Visual Studio Code - Popular extensions for Java development that provides Java IntelliSense, debugging, testing, Maven/Gradle support, project management and more
🌐
GitHub
github.com › redhat-developer › vscode-java
GitHub - redhat-developer/vscode-java: Java Language Support for Visual Studio Code
java.configuration.runtimes: Map Java Execution Environments to local JDKs. ... Standard: Provides full features such as intellisense, refactoring, building, Maven/Gradle support etc.
Starred by 2.2K users
Forked by 511 users
Languages   TypeScript 91.4% | JavaScript 5.5% | CSS 2.3% | Java 0.8%
🌐
Oracle
docs.oracle.com › en › graalvm › enterprise › 20 › docs › tools › vscode › graalvm-extension
GraalVM Extension
January 16, 2025 - GraalVM VSCode Extension enables a polyglot environment in VSCode, thus making it suitable and convenient to work with GraalVM from an integrated development environment, and to allow VS Code users to edit and debug applications written in any of the GraalVM supported languages (Java, JS, Ruby, ...
🌐
Visual Studio Code
code.visualstudio.com › docs › java › java-project
Managing Java Projects in VS Code
November 3, 2021 - To get the complete Java language support in Visual Studio Code, you can install the Extension Pack for Java, which includes the Project Manager for Java extension.
🌐
Chief Delphi
chiefdelphi.com › technical › programming
Java Intellisense doesn't work - Programming - Chief Delphi
January 15, 2023 - For some weird reason during the first comp our intellisense stopped working, which made it difficult to program. Does anyone know a solution to this?
🌐
GitHub
github.com › redhat-developer › vscode-java › issues › 3191
intellisense failure · Issue #3191 · redhat-developer/vscode-java
May 13, 2023 - When I open vscode for a period of time, the intellisense fails, for example, when I enter s, the code fragment prompt of sout will not appear. After I restarted vsocde it started working fine agai...
Published   Jul 10, 2023
🌐
Reddit
reddit.com › r/vscode › help: java auto-complete extension doesn't work?
r/vscode on Reddit: Help: Java auto-complete extension doesn't work?
February 27, 2024 -

how do i enable java auto-complete(one where it would only suggest possible keywords or methods while typing) in VSCode? i've tried installing JDK from brew, setting java.jdt.ls.java.home to the home folder of JDK, disabling/re-enabling and uninstalling/reinstalling the extensions but it still doesn't work. i watched a couple videos on youtube and all it took for them was installing the extension pack for java and the auto-complete just works right out of the box? feels like i'm missing something obvious... thanks in advance!

FIXED: The extension "Language Support for Java(TM) by Red Hat" requires version ^1.79.0 of VS Code but I was using version 1.78.0. A quick update to VS Code should fix it. I found the error by checking the runtime status of the said extension.

lol, can't believe it took me to long to fix though

🌐
Visual Studio Code
code.visualstudio.com › docs › languages › overview
Programming Languages
November 3, 2021 - IntelliSense (⌃Space (Windows, Linux Ctrl+Space)) will show you the available language identifiers.
🌐
InfoWorld
infoworld.com › home › software development › development tools
Review: Visual Studio Code shines for Java | InfoWorld
June 8, 2022 - It comes with built-in support for JavaScript, TypeScript, and Node.js and has a rich ecosystem of extensions for other programming languages (such as Java, C++, C#, Python, PHP, and Go), runtimes (such as .NET and Unity), environments (such as Docker and Kubernetes), and clouds (such as Amazon Web Services, Microsoft Azure, and Google Cloud Platform). Aside from the whole idea of being lightweight and starting quickly, Visual Studio Code has IntelliSense code completion for variables, methods, and imported modules; graphical debugging; linting, multi-cursor editing, parameter hints, and other powerful editing features; snazzy code navigation and refactoring; and built-in source code control including Git support.