How to add directory to classpath in an application run profile in IntelliJ IDEA?

sal picture sal · May 12, 2009 · Viewed 353.6k times · Source

I'm trying to add a directory to the classpath of an application run profile

If I override by using -cp x:target/classes in the VM settings, I get the following error:

java.lang.NoClassDefFoundError: com/intellij/rt/execution/application/AppMain

Any idea on how to add a directory to the classpath for my project?

Answer

stivlo picture stivlo · Jul 19, 2014

In Intellij 13, it looks it's slightly different again. Here are the instructions for Intellij 13:

  1. click on the Project view or unhide it by clicking on the "1: Project" button on the left border of the window or by pressing Alt + 1
  2. find your project or sub-module and click on it to highlight it, then press F4, or right click and choose "Open Module Settings" (on IntelliJ 14 it became F12)
  3. click on the dependencies tab
  4. Click the "+" button on the right and select "Jars or directories..."
  5. Find your path and click OK
  6. In the dialog with "Choose Categories of Selected File", choose Classes (even if it's properties), press OK and OK again
  7. You can now run your application and it will have the selected path in the class path