Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Can't get started (HelloWorld tutorial)(following HelloWorld tutorial)
Can't get started (HelloWorld tutorial) [message #1866057] Tue, 21 May 2024 03:52 Go to next message
Maple Syruper is currently offline Maple SyruperFriend
Messages: 2
Registered: May 2024
Junior Member
I'm totally new to Java and Eclipse, but trying to help my kids with a beginner Java course. We installed the latest version of Eclipse (May 20, 2024), and followed the Hello World tutorial that came up, but we're getting an error we don't understand. Here is my program and the error, but see attached screenshots also.

public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}

Error: Could not find or load main class test2.Test2
Caused by: java.lang.ClassNotFoundException: test2.Test2

There was originally a module-type thing showing up under HelloWorld, but I right-click-deleted it based on reading some other posts here, but it didn't help.

The funny thing is, I tried 3 different computers. This error is from a PC with Windows 10. I got the same error on a PC with Windows 7. But on a different PC with Windows 10 the same program ran fine .

Thank you!
Re: Can't get started (HelloWorld tutorial) [message #1866132 is a reply to message #1866057] Tue, 21 May 2024 22:51 Go to previous messageGo to next message
Maple Syruper is currently offline Maple SyruperFriend
Messages: 2
Registered: May 2024
Junior Member
Here's more info. I reinstalled Eclipse and started over from the beginning of the HelloWorld tutorial. I'm still getting the same error; see attached image.

There are red x's next to lines 1,2,4, and 5. They are hard to capture with a snip, but here's what they say:

X on line 1:
Multiple markers at this line
- The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
- Must declare a named package because this compilation unit is associated to the named module 'HelloWorld'
- The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files

X on line 2:
Implicit super constructor Object() is undefined for default constructor. Must define an explicit constructor

X on line 4;
String cannot be resolved to a type

X on line 5:
System cannot be resolved
Re: Can't get started (HelloWorld tutorial) [message #1866195 is a reply to message #1866132] Wed, 22 May 2024 14:40 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33163
Registered: July 2009
Senior Member
You cannot define a class without a package in a project with a module because Java doesn't allow modules to contain unnamed packages. You must delete the module-info.java or create the class with a package.

Ed Merks
Professional Support: https://www.macromodeling.com/

[Updated on: Wed, 22 May 2024 14:44]

Report message to a moderator

Previous Topic:sql libraries not accessible
Next Topic:External Tool / File in Editor
Goto Forum:
  


Current Time: Sun Jun 16 11:20:30 GMT 2024

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

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

Back to the top