简体   繁体   English

将库导入java

[英]importing library into java

I am very new to java我对java很陌生

I downloaded an open source java project我下载了一个开源的java项目

which has this line of code有这行代码

import sun.swing.SwingUtilities2;

I am getting this error我收到此错误

Error:(94, 38) java: cannot find symbol
  symbol:   variable SwingUtilities2
  location: class org.apache.ctakes.gui.component.SmoothToolTip.SmoothToolTipUI

I have downloaded this jar file from here我已经从这里下载了这个 jar 文件

http://www.java2s.com/Code/Jar/j/Downloadjsdgstubsjre15jar.htm http://www.java2s.com/Code/Jar/j/Downloadjsdgstubsjre15jar.htm

I am trying to add it to my project我正在尝试将其添加到我的项目中

through going to project structure in IntelliJ and then add library通过在 IntelliJ 中转到项目结构然后添加库

but I get another error when i click the ok button但是当我单击“确定”按钮时出现另一个错误

在此处输入图片说明

how to import this library in my project ?如何在我的项目中导入这个库?

It's like to be a maven project.这就像是一个 Maven 项目。 if so, why not trying to add the dependency instead of downloading the jar file manually?如果是这样,为什么不尝试添加依赖项而不是手动下载 jar 文件?

try to add:尝试添加:

<!-- https://mvnrepository.com/artifact/com.sun/tools -->
<dependency>
    <groupId>com.sun</groupId>
    <artifactId>tools</artifactId>
    <version>1.5.0</version>
    <scope>system</scope>
</dependency>

to your pom file and then build the project again.到您的 pom 文件,然后再次构建项目。 this way maven download it for you automatically.这样maven会自动为你下载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM