我试图将一个目录添加到应用程序运行概要文件的类路径

如果在虚拟机设置中使用-cp x:target/classes进行覆盖,会得到以下错误:

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

关于如何将目录添加到我的项目的类路径有任何想法吗?


当前回答

您可以尝试java应用程序启动器的-Xbootclasspath/a:path选项。通过描述,它指定了“一个以冒号分隔的目录、JAR存档和ZIP存档的路径,要附加到默认引导类路径中。”

其他回答

在Intellij 13中,它看起来又略有不同。以下是Intellij 13的使用说明:

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 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) click on the dependencies tab Click the "+" button on the right and select "Jars or directories..." Find your path and click OK In the dialog with "Choose Categories of Selected File", choose Classes (even if it's properties), press OK and OK again You can now run your application and it will have the selected path in the class path

您不需要指定类文件夹。Intellij应该能够加载它。 如果“Project Compiler output”为空,则会出现此错误。

只要确保下面的值被设置: 项目设置->项目->项目编译器输出 到projectDir/out文件夹

您可以尝试java应用程序启动器的-Xbootclasspath/a:path选项。通过描述,它指定了“一个以冒号分隔的目录、JAR存档和ZIP存档的路径,要附加到默认引导类路径中。”

打开设置 在项目设置下,选择“项目设置(1)” 在左侧,选择“modules” 选择所需的模块 选择“Sources”选项卡 在树状结构中,找到要添加的目录。然后作为源或测试源添加。

我用的是Idea 8。 在模块依赖项选项卡中(在项目结构对话框中)。添加“模块库”。然后确保运行概要文件在运行时使用正确模块的Classpath和JDK(这是在运行配置对话框中)。