I have a Java applet project that some of the package unable to be recognized in VSCode.
It because the project doesn't import plugin.jar
and I can't see it in JRE System Library [JavaSE-1.6]
.
I'm sure the plugin.jar
exists in my C:\Program Files\Java\jdk1.6.0_43\jre\lib
folder.
How can I add this plugin.jar
to the list?
By the way, I'm using Maven and I have a pom.xml
file. Here is it's content.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<properties>
<project.build.sourceEncoding>big5</project.build.sourceEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<pluginManagement>
<!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
CodePudding user response:
The original answer failed to solve the problem, the updated answer is as follows:
Use the following command to add a local .jar
package to the maven local repository.
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
After the addition is successful, modify the pom.xml
file to add dependencies.
<dependencies>
<dependency>
<groupId>group-id</groupId>
<artifactId>artifact-id</artifactId>
<version>version</version>
</dependency>
</dependencies>
original answer
This class should be stored in the jrt-fs.jar
under the Java folder. I have tried several versions of java (
Even if you delete a jrt-fs.jar
under a certain version, vscode will automatically reference jar files under other versions.
So I think a better solution is to use the Java version provided by the official website.
As far as the question you asked. You can add the .jar
as follows:
Since your project is built by maven, you can see these two dependency managers in the JAVA PROJECTS panel:
Of course, you can't change the system library, so you can only add dependencies for maven,
Click the plus sign on the right side of Maven Dependencies,
type in the package name you want to add and search for it.
Choose a library to add it.
This modifies the following in your pom.xml
file.
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.30</version>
</dependency>
</dependencies>
If it's just a normal Java project, click the plus sign to the right of Referenced Libraries and add the jar in the file manager.