Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't compile a java 9 project in IntelliJ IDEA with module-info

Can't compile a java 9 project in IntelliJ IDEA with module-info.

  1. Create a project
  2. Add module
  3. Create a class with with a main (without module-info.java it runs)
  4. Add Module-info.java
  5. Run Main Fails

Configuration

enter image description here

Module-info

module httpexample { }

Error

enter image description here

Error:(1, 1) java: file should be on source path, or on patch path for module

Intellij Version

IntelliJ IDEA 2017.1.2 Build #IU-171.4249.39, built on April 25, 2017 JRE: 1.8.0_112-release-736-b16 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Mac OS X 10.11.1

like image 691
Miguel Gomes Avatar asked May 01 '17 16:05

Miguel Gomes


People also ask

How to add Java 9 modules in IntelliJ IDE?

One way to add Java 9 modules in IntelliJ IDE is to use IntelliJ specific project modules. Intellij module is an independent and ordinary Java project. To use Java 9 modules, we need to use IntelliJ 1217.1 or later versions. The IDE added various support to develop Java 9 modules.

What is the difference between Java 9 and IntelliJ IDEA?

IntelliJ IDEA had already had a concept of modules: every IntelliJ IDEA module built its own classpath. With the introduction of the new Java platform module system, there appeared two systems of modularity: the IntelliJ IDEA modules, and the new Java 9 modules that are configured using module-info.java.

How do I compile a project in IntelliJ?

Select a module or a project you want to compile and from the main menu, select Build | Build Project (Ctrl+F9). IntelliJ IDEA displays the compilation results in the Review compilation and build output.

What is a module file in IntelliJ?

A module file (the .iml file) is used for keeping module configuration. Modules allow you to combine several technologies and frameworks in one application. In IntelliJ IDEA, you can create several modules for a project and each of them can be responsible for its own framework. For more information, refer to Add frameworks (facets).


2 Answers

It appears to be a new issue caused by Java 9 update 166, I've reported it in YouTrack, please follow for updates:

  • IDEA-172212 Compile Error under JDK9-167
like image 140
CrazyCoder Avatar answered Sep 30 '22 14:09

CrazyCoder


I am using IntelliJ EAP 2017.2 build 1909.2 and this is not an issue anymore

like image 35
jactor-rises Avatar answered Sep 30 '22 14:09

jactor-rises