Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Error message run I tried to run the hello world in java(Error message)
Error message run I tried to run the hello world in java [message #1809203] Thu, 11 July 2019 12:47 Go to next message
Sergeant Smiley is currently offline Sergeant SmileyFriend
Messages: 1
Registered: July 2019
Junior Member
Why do I get this message when I tried to run a java program? What do I need to do so this won't continue to happen when I'm trying to run my Java program in Eclipse?

error occurred during initialization of boot layerjava.lang.module.findexception: error reading module: c:\coderepository\myproject\bincaused by: java.lang.module.invalidmoduledescriptorexception: myclass.class found in top-level directory (unnamed package not allowed in module)
Re: Error message run I tried to run the hello world in java [message #1809213 is a reply to message #1809203] Thu, 11 July 2019 16:47 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

Declare your class as being in a package, using the package keyword, or don't have a module-info.java and cause it to be treated like a Java module.

_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: Error message run I tried to run the hello world in java [message #1814019 is a reply to message #1809213] Sun, 01 September 2019 19:15 Go to previous messageGo to next message
MICHAEL DAVIS is currently offline MICHAEL DAVISFriend
Messages: 1
Registered: September 2019
Junior Member
while trying to run eclipse hello world I got the error

java.lang.module.InvalidModuleDescriptorException:

I saw an answer on the forum but I am new to eclipse and haven't programed in Java in a couple of years (BlueJ), in other words I didn't understand the answer. I need baby steps please.

Re: Error message run I tried to run the hello world in java [message #1814050 is a reply to message #1814019] Mon, 02 September 2019 10:13 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
No one can do anything with an attached .class file. Did you try declaring your class to have a package? This is a good reference:

https://www.vogella.com/tutorials/Eclipse/article.html


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Error message run I tried to run the hello world in java [message #1855082 is a reply to message #1814050] Wed, 28 September 2022 03:42 Go to previous messageGo to next message
Nicolae FIERARU is currently offline Nicolae FIERARUFriend
Messages: 1
Registered: September 2022
Junior Member
I faced the same problem when I created the HelloWorld application for the second time (first time it worked, then I installed some other java IDE's). I run into errors while following step by step the instructions. I didn't know what to do and I reinstalled Eclipse. This did not help. I tried to reset to default most of the options and it also didn't help. Then I found this forum and I understood what was wrong. But it would be useful for the step by step instructions to include additional advice, such as what to type in the Package area in case it remains empty.

index.php/fa/42538/0/
Re: Error message run I tried to run the hello world in java [message #1855102 is a reply to message #1855082] Wed, 28 September 2022 15:08 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
I would be best to open an issue here with your observations and suggestions:

https://github.com/eclipse-jdt/eclipse.jdt.ui



Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Error message run I tried to run the hello world in java [message #1855105 is a reply to message #1855082] Wed, 28 September 2022 17:06 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
It sems that the cheat sheet is out of date. There should be a step for package creation after project creation and before class creation.

However, at least my 2022-09 JDT complains of missing package declaration as soon as the source is opened in the editor, see the red error mark at top left.

index.php/fa/42543/0/


--

Tauno Voipio
Re: Error message run I tried to run the hello world in java [message #1860928 is a reply to message #1809213] Sat, 09 September 2023 19:39 Go to previous messageGo to next message
THOMAS DOWNES is currently offline THOMAS DOWNESFriend
Messages: 4
Registered: September 2023
Junior Member
Thank you, however...
As a Java newbie, I find your answer challenging to understand operationally.
In other words, I am unclear of the implementation.
What are the concrete steps you are recommending?
Re: Error message run I tried to run the hello world in java [message #1860930 is a reply to message #1809203] Sat, 09 September 2023 20:05 Go to previous messageGo to next message
THOMAS DOWNES is currently offline THOMAS DOWNESFriend
Messages: 4
Registered: September 2023
Junior Member
It's likely your project contains a file called module-info.java.
(This is a default file, but I don't know how to change the setting to not have it be automatically included in your project.)
Solution, right-click & delete the file ("module-info.java").
(See attached image.)
(Credit to Nitin Dahyabhai for his helpful suggestion!!)
Re: Error message run I tried to run the hello world in java [message #1860931 is a reply to message #1809213] Sat, 09 September 2023 20:07 Go to previous messageGo to next message
THOMAS DOWNES is currently offline THOMAS DOWNESFriend
Messages: 4
Registered: September 2023
Junior Member
Thank you!! I deleted the file called "module-info.java", and it worked!!
(See attached image.)
Re: Error message run I tried to run the hello world in java [message #1860932 is a reply to message #1855082] Sat, 09 September 2023 20:35 Go to previous message
THOMAS DOWNES is currently offline THOMAS DOWNESFriend
Messages: 4
Registered: September 2023
Junior Member
Dear fellow newbie,
You are looking at the "Create New Class" dialog. Let's take a look at the "Create New Project" dialog instead. See image. As I mention in the image, the Create New Project dialog probably has "Create Module Info" (?) automatically checked.
Having "Create Module Info" checked seems to create extra work for the programmer. It seems to cause the compiler to expect that a "package" (whatever that means!) will be specified by the programmer (you & me).
When the new project is created, you'll see a file called "module-info.java" has been automatically added under the "src" folder.
That file ("module-info.java") is the problem. It puts the compiler into a "check package" mode (just a guess, as I don't really know what's going on).
Comment out the one-line command in that file, or right-click the file (from within the Project Explorer (?) and select "Delete" (to remove the module-info.java file from the project).
This worked for me, just within the last 20 minutes when I tried it out. Good luck!!

Previous Topic:Dark Theme XSLT / XPath color
Next Topic:Eclipse will not install. Debian 12
Goto Forum:
  


Current Time: Wed Apr 24 14:19:00 GMT 2024

Powered by FUDForum. Page generated in 0.08733 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top