4

I was trying to open a program I made before but for some reason the following error always appeared: Must declare a named package because this compilation unit is associated to the named module '********'

enter image description here

ernest_k
  • 44,416
  • 5
  • 53
  • 99
chawks312
  • 51
  • 1
  • 1
  • 4
  • 1
    I understand the message as "you must use a non-default package for your classes". Create a package, move classes to it, and declare a package in the file – ernest_k Aug 11 '18 at 20:26
  • 4
    @ernest_k Thanks so much! It finally works now! – chawks312 Aug 11 '18 at 20:32

2 Answers2

2

An easy solution to this problem is to delete the module-info.java file present on your Project Explorer tab. Eclipse created this by default, and also, removing this will not affect any functionality of your program. So, go for it...

0

I created a new package, and moved the error classes from the default package to new one, then the error disappeared !

Source: @ernest_k's comment

Eric Aya
  • 69,473
  • 35
  • 181
  • 253