Referencing a .class file in IntelliJ Java Project

≯℡__Kan透↙ 提交于 2019-12-01 15:07:24

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.

Select the root of your project and press F4. Then you'll see the project structure. Select the 'Libraries' section on the left hand side and click the plus symbol to create a 'New Project Library'. Choose 'Java' and select the directory where the .class file(s) is located. Proceed the remaining steps by clicking 'OK'.

To get to the dependencies tab double click on the "src" folder, then click on the green plus button on the top right hand side. click "JARs or Directories", then add the parent folder of your .class file.

For the newer versions of Intellij, press Ctrl + Alt + Shift + s to open project settings, then choose Modules, under Dependencies tab choose the green + and add the folder in which your .class file is located. Under scope, choose compile.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!