I just downloaded eclipse for Java Yesterday but when I was trying to get make my first program, I kept on getting this error:
must declare a named package eclipse because this compilation unit is associated to the named module x.
How do I fix this?
To Solve must declare a named package eclipse because this compilation unit is associated to the named module x Error Package name left blank while creating a class. This make use of default package. Thus causes this error. So You just need to delete module-info.
A package name is the full name of the package, which is defined via the NAME parameter in the pkginfo file. Because system administrators often use package names to determine whether or not a package needs to be installed, it is important to write clear, concise, and complete package names.
Click on the root package and start typing the name of the package you are looking for. Show activity on this post. Ctrl + Shift + T works for packages too: Just type the package name and then a dot and it will show all classes in matching packages.
Just delete module-info.java at your Project Explorer tab.
The "delete module-info.java at your Project Explorer tab" answer is the easiest and most straightforward answer, but
for those who would want a little more understanding or control of what's happening, the following alternate methods may be desirable;
or
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With