Home > Java > javaTutorial > body text

How to Add a Directory to the Classpath for Application Run Profiles in IntelliJ IDEA?

Linda Hamilton
Release: 2024-11-06 04:35:02
Original
1039 people have browsed it

How to Add a Directory to the Classpath for Application Run Profiles in IntelliJ IDEA?

Setting the Classpath for Application Run Profiles in IntelliJ IDEA

Adding a directory to the classpath of an application run profile in IntelliJ IDEA can be a tricky task. Attempting to override the classpath using the -cp x:target/classes parameter in VM settings can result in the "java.lang.NoClassDefFoundError: com/intellij/rt/execution/application/AppMain" error.

Correct Procedure for IntelliJ 13

In Intellij 13, the steps for adding a directory to the classpath are slightly different:

  1. Display the Project view by pressing Alt 1.
  2. Highlight your project or sub-module and press F4 or right-click to select "Open Module Settings" (F12 in IntelliJ 14).
  3. Click on the "Dependencies" tab.
  4. Use the " " button on the right to add "Jars or directories...".
  5. Navigate to the desired path and click OK.
  6. In the "Choose Categories of Selected File" dialog, select "Classes" (even for properties files).
  7. Click OK twice.

Additional Notes

After completing these steps, the project will have the selected directory included in its classpath. This allows you to access classes and resources located within that directory during runtime.

The above is the detailed content of How to Add a Directory to the Classpath for Application Run Profiles in IntelliJ IDEA?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template