简体   繁体   中英

Intellij-idea class import

there is a class called "Agent.class" that I wanna use inside of a java source file, and the .class file is in the same location as the .java file. the location is ./my/test/

when I tried to import this class by typing "import my.test.", Intellij-idea doesn't show autocomplete for the Agent.class but just the .java file.

inside the java file, a line of code Agent ag = new Agent(); failed because the compiler can't resolve the object "Agent".

What am I wrong here with the Intellij settings?

.class files are produced from compiled .java files, you need to have the Agent.java file in order to import Agent class to your own class. If you have the jar containing Agent class you can try this in Intellij:

  • ctrl+shift+alt+s to open Project Structure window
  • go to Libraries tab
  • press the add ( + ) button
  • select the path where your jar is and add it to your Module

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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