W3docs

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

To add a directory to the classpath in an application run profile in IntelliJ IDEA, follow these steps:

To add a directory to the classpath for an application run configuration in IntelliJ IDEA, follow these steps:

  1. Open Run > Edit Configurations (or click the run configuration dropdown next to the green play button and select Edit Configurations...).
  2. Select your application configuration from the list on the left.
  3. Switch to the Classpath tab.
  4. Click the + button and select JARs or directories... (or Add Content Root).
  5. Navigate to and select the directory you want to add, then click OK.
  6. Click Apply and OK to save the changes.

The selected directory will now be included in the run configuration's classpath and available when you run your application. You can verify this by checking the Classpath tab in the Run/Debug Configurations window.

(Note: The steps above configure the run profile directly. If you need to add the directory to the module classpath instead, use File > Project Structure > Modules > Dependencies and follow the same process.)

I hope this helps. Let me know if you have any questions.