Search code examples
javamavenintellij-14

importing library into java


I am very new to java

I downloaded an open source java project

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

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

but I get another error when i click the ok button

enter image description here

how to import this library in my project ?


Solution

  • It's like to be a maven project. if so, why not trying to add the dependency instead of downloading the jar file manually?

    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. this way maven download it for you automatically.