Referencing a .class file in IntelliJ Java Project

DeveloperInToronto picture DeveloperInToronto · Aug 26, 2012 · Viewed 16.5k times · Source

I just started playing around with IntelliJ. I need to call a function from a class file I downloaded, so I need to reference a .class file in my project. Can't figure out how to add it to my project. Would appreciate it if someone could guide me.

Answer

Ingo Kegel picture Ingo Kegel · Aug 26, 2012

Open the project structure dialog with "File->Project Structure", select "Project Settings->Modules" on the left, then select the module whose classpath you want to modify. On the "Dependencies" tab on the right side of the dialog you can add the classpath root directory of your class file.

Of course the class file has to be in the right directory structure corresponding to the package of the class, otherwise it will not work.