4

The title said it all. I can't import neither java.awt.* nor java.swing.* in Intellij Idea. This is my project structure.

project structure

java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
m.d
  • 169
  • 2
  • 9
  • 3
    Your module `requires java.desktop` in the directives for that. Have you ensured it? Or could you better explain what is your current project structure and definition? – Naman Mar 07 '18 at 17:34
  • Could your better explain what is your project structure? if you define explicity your project as module (`module-info` present) you will have to add `requires java.desktop` as @nullpointer suggested, but if not than you shoudn't this may help you https://stackoverflow.com/questions/46288170/is-it-possible-to-mix-class-path-and-module-path-in-javac-jdk-9/46289257#46289257 – Andrew Sasha Mar 08 '18 at 11:21

1 Answers1

8

This is how i done it. It seems that i need to include a module-info.java file

module-info.java

and inside that put the follwoings.

module project.name {
    requires java.datatransfer;
    requires java.desktop;
}

I can't come up with a better answer right now. but this solved the initial problem.

m.d
  • 169
  • 2
  • 9