Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Java Dummies Book : EchoLine(Runtime error)
Java Dummies Book : EchoLine [message #1795239] Wed, 19 September 2018 02:35 Go to next message
Henrick Leow is currently offline Henrick LeowFriend
Messages: 5
Registered: September 2018
Junior Member
I follow the dummies book and i written :

import java.util.Scanner;

class EchoLine {

public static void main(String args[]) {
Scanner keyboard = new Scanner(System.in);
System.out.println(keyboard.nextLine());
keyboard.close();
}
}

The error shown :

Must declare a named package because this compilation unit is associated to the named module 'MyNewProject'

The console tab shown :
Error occurred during initialization of boot layer
java.lang.module.FindException: Error reading module: C:\Users\Leow\myfirst-eclipse-workspace\MyNewProject\bin
Caused by: java.lang.module.InvalidModuleDescriptorException: EchoLine.class found in top-level directory (unnamed package not allowed in module)

Anyone can advise what wrong ?

Thanks
Re: Java Dummies Book : EchoLine [message #1795241 is a reply to message #1795239] Wed, 19 September 2018 02:51 Go to previous messageGo to next message
Sarika Sinha is currently offline Sarika SinhaFriend
Messages: 132
Registered: February 2010
Location: Bangalore, India
Senior Member
Yes, You need to place your class file in a package, default package does not work with modular projects.

Sarika Sinha
JDT Programmer
Re: Java Dummies Book : EchoLine [message #1795252 is a reply to message #1795241] Wed, 19 September 2018 10:32 Go to previous message
Henrick Leow is currently offline Henrick LeowFriend
Messages: 5
Registered: September 2018
Junior Member
Thanks for advice.

FYI, i created the first one it work as below :

public class MyFirstJavaClass {

public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Chocolate, royalties, sleep");

}

}

Thanks
Previous Topic:Java Dummies Book : EchoLine
Next Topic:How can I help someone resolve "Plugin execution not covered by lifecycle configuration"?
Goto Forum:
  


Current Time: Tue Sep 24 03:10:55 GMT 2024

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

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

Back to the top