"Cannot start compilation: the output path is not specified for module..."

JavaIntellij IdeaGradleIntellij 13

Java Problem Overview


I have a very simple Java + Gradle project. It builds fine. It runs fine from the shell with "gradle run". However, if I try to run inside of IntelliJ, I get:

Cannot start compilation: the output path is not specified for module "xyz" Specify the output path in Configure Project.

My "Compiler output" is set to "Inherit project compile output path". I don't want a custom output path, whatever that is, just do a normal gradle build and run.

Java Solutions


Solution 1 - Java

You just have to go to your Module settings > Project and specify a "Project compiler output" and make your modules inherit from project. (For that go to Modules > Paths > Inherit project.

This did the trick for me.

Solution 2 - Java

You have to define a path in the "Project compiler output" field in

> File > Project Structure... > Project > Project compiler output

This path will be used to store all project compilation results.

Solution 3 - Java

I'm answering this so that I can find the solution when I have to google this error again.

Set project compile output path to path_of_the_project_folder/out. That's what is working today. The intellj documentation makes it seem like we can select any folder but that's not the case.

Solution 4 - Java

While configuring idea plugin in gradle, you should define output directories as follows.

idea{
    module{
        inheritOutputDirs = false
        outputDir = compileJava.destinationDir
        testOutputDir = compileTestJava.destinationDir
    }
}

Solution 5 - Java

If none of the above method worked then try this it worked for me.

Go to File > Project Structure> Project and then in Project Compiler Output click on the three dots and provide the path of your project name(name of the file) and then click on Apply and than on Ok.

Solution 6 - Java

Open .iml file. Look for keyword 'NewModuleRootManager'. Check if attribute 'inherit-compiler-output' is set to true or not. If not set to true.

Like this :

component name="NewModuleRootManager" inherit-compiler-output="true">
    <content url="file://$MODULE_DIR$">
      <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
      <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
      <sourceFolder url="file://$MODULE_DIR$/app" isTestSource="false" />
 

Solution 7 - Java

Two things to do:

  1. Project Settings > Project compiler output > Set it as "Project path(You actual project's path)”+”\out”.

  2. Project Settings > Module > Path > Choose "Inherit project compile path"

Solution 8 - Java

After this

Two things to do:

> Project Settings > Project compiler output > Set it as "Project > path(You actual project's path)”+”\out”. > > Project Settings > Module > Path > Choose "Inherit project compile > path""

If button ran is not active

You must reload IDEA

Solution 9 - Java

I get this error too when creating a project in IntelliJ without using a template.

I have 2 SDKs installed: Amazon Corretto and java version 11.0.4 and so, what I do when I have this error is "change the SDK" it usually works fine with Corretto

to do that you need to click on File (in IntelliJ)/ Project Structure / Project / Project SDK: select corretto from the dropdown list (or check the option in your computer) as shown here

hope this will work for you too

Best, Constantin

Solution 10 - Java

None of the suggestions worked for me until I ran the command "gradle cleanIdeaModule ideaModule" info here: https://docs.gradle.org/current/userguide/idea_plugin.html

Solution 11 - Java

change drop down to start file your project

enter image description here

Solution 12 - Java

Bugs caused by missing predefined folder for store compiled class file which is normally is /out folder by default. You can give a try to close Intellij > Import Project > From existing source. This will solve this problem.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionclayView Question on Stackoverflow
Solution 1 - Javapranavrao1View Answer on Stackoverflow
Solution 2 - JavaBullyWiiPlazaView Answer on Stackoverflow
Solution 3 - JavaKanjView Answer on Stackoverflow
Solution 4 - JavalemiorhanView Answer on Stackoverflow
Solution 5 - Javapriyanshu kumarView Answer on Stackoverflow
Solution 6 - JavamdevView Answer on Stackoverflow
Solution 7 - JavaAli WuView Answer on Stackoverflow
Solution 8 - JavaДенис ТимофеевView Answer on Stackoverflow
Solution 9 - JavaConstantinView Answer on Stackoverflow
Solution 10 - JavaMujahedView Answer on Stackoverflow
Solution 11 - Javadev001View Answer on Stackoverflow
Solution 12 - JavalogbasexView Answer on Stackoverflow