How to add referenced libraries to Selenium Java project in VS code?

Viewed 200

In my code I have added the below in my settings.json file in the VS code java project still I don't see the referenced jar files added the project

"java.project.referencedLibraries": [
    "library/**/*.jar",
    "/home/username/lib/foo.jar"
]
1 Answers

You need to click the refresh button then the added jar should be displayed under the option Referenced Libraries:

enter image description here

This is specified for no build tools project.

However, Maven project uses dependencies and there's a command called Maven: Add a dependency provided by the extension Maven for Java, you can search needed dependencies then they will be added to pom.xml.

About adding customized jars to maven project, you need to install the jar to local repository:

 mvn install:install-file -Dfile=path\to\foo.jar '-DgroupId=com.example' -DartifactId=foo '-Dversion=1.0.0' -Dpackaging=jar 

then add related dependency to pom.xml:

 <dependency>
     <groupId>com.example</groupId>
     <artifactId>foo</artifactId>
     <version>1.0.0</version>
 </dependency>

Detailed information about mvn install please view Apache Maven Install usage

Related