Visual Studio Code, Java Extension, howto add jar to classpath

后端 未结 8 903
攒了一身酷
攒了一身酷 2020-11-29 03:20

In Eclipse, I add a jar library using

project -> build path ->configure build path

What is the equivalent in VisualStudioCode? I had a look into launch.json

8条回答
  •  醉话见心
    2020-11-29 03:54

    You must have the Java Dependency Viewer extension installed which helps import the jar files and add them to the project's classpath OR add the libraries to the ".classpath" file manually by using tags within tags for each jar file.

    First what you want to do is know how to create a proper Java "project" in VS Code.

    To do that:

    1. Have a folder opened in VSCode
    2. Press Ctrl+Shift+P to open the Command Palette
    3. Type in Java: Create New Project
    4. Follow the steps according to your requirements and provide the project name

    Then : Expand the Java Dependencies section in your Explorer Panel then Expand your "project name".

    1. When you hover over "Referenced Libraries" you will see the "+" sign. Click it.
    2. It will open the explorer. Use it to select all your jar files and click "Select Jar Files" button.

    That's it!!!!

    By the way you can see all of this in detail at https://code.visualstudio.com/docs/java/java-project#_working-with-jar-files , it has a clear visual representation of everything related.

    Happy Coding!!!

提交回复
热议问题