redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.08k stars 441 forks source link

How to enable intellisense #461

Closed Jomme5 closed 6 years ago

Jomme5 commented 6 years ago

[provide a description of the issue]

Environment

What do I have to do to enable intellisense for:

Intellisense or codecompletion/sugestions doesn't work at all.

gorkem commented 6 years ago

Do you see that vscode-java extension is up an running as described on https://github.com/redhat-developer/vscode-java#troubleshooting ? What kind of a project are you using? A maven project with a pom.xml at the root?

Jomme5 commented 6 years ago
gorkem commented 6 years ago

In order for the extension to resolve your 3rd party dependencies you need to use a build tool such as maven or gradle. We use these tools to pickup your external dependencies and provide information on them without those your intellisense will be limited to single file and standard java libraries.

Jomme5 commented 6 years ago

Funfact: I want to use VSCode to test some things out before programming it in Android Studio, with the slow Gradle-build-system. So I want to avoid complex build-systems. The external jar is already compiled with maven btw. It would be nice to use this jar in vscode with intellisense-support and use maven for building external jars once in a while. I already figured out how to compile my java-test program with the classpath-dependencies-variable. (javac -cp "/path-to-jar/*" test.java)

gorkem commented 6 years ago

I understand. sorry to hear it does not fit to your expectations but Java (the language) does not come with a standard way to define dependencies (no package.json for instance) so we chose to support the most commonly used methods in Javaland for defining those.

We also support eclipse style .classpath and .project files, but I am not sure if it would help you either.

Jomme5 commented 6 years ago
  1. I downloaded de "test_vs_code2.zip" from this issue
  2. Add "test_vs_code" project folder to Workspace via File->Add Folder.
  3. Copy-pasted my java test code in the main-class, altered the .classpath-file and it did what I asked. <classpathentry kind="lib" path="lib.jar" sourcepath="lib.source.jar"/>
nateshmbhat commented 6 years ago

What fixed it for me was

I reinstalled openjdk-11

If you have openjdk8 , try to upgrade or reinstall it.

Alexhaoge commented 4 years ago

Do you see that vscode-java extension is up an running as described on https://github.com/redhat-developer/vscode-java#troubleshooting ? What kind of a project are you using? A maven project with a pom.xml at the root?

https://github.com/redhat-developer/vscode-java/wiki/Troubleshooting#clean-the-workspace-directory

If the dependency is already configured in Maven, maybe cleaning the workspace and restarting Java extension is enough to solve this. At least it works for me.

If the dependency is not in Maven or Gradle, try Jomme's reply and reload workspace.

  1. I downloaded de "test_vs_code2.zip" from this issue
  2. Add "test_vs_code" project folder to Workspace via File->Add Folder.
  3. Copy-pasted my java test code in the main-class, altered the .classpath-file and it did what I asked. <classpathentry kind="lib" path="lib.jar" sourcepath="lib.source.jar"/>
piscopancer commented 11 months ago

In order for the extension to resolve your 3rd party dependencies you need to use a build tool such as maven or gradle. We use these tools to pickup your external dependencies and provide information on them without those your intellisense will be limited to single file and standard java libraries.

Please can you explain how to do it in detail? Is there a manual somewhere btw? I Have no intellisense for 3d party libs either. I do use gradle though, I am developing a mc forge mod.