Eclipse java.lang.module.FindException and java.lang.ClassNotFoundException

Viewed 5058

I recently installed Eclipse 2020-06 and am using JDK 10.0.2. I wanted to test Eclipse using a simple Hello world program:

    package eclispeTest;
    
    public class eclipseTest {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            System.out.println("Hello");
        }
    
    }

But I get the error: Error occurred during initialization of boot layer java.lang.module.FindException: Module eclispeTest not found

One quick fix I see for this to delete the module-info.java file but when I do this I get the error: Error: Could not find or load main class eclispeTest.eclipseTest Caused by: java.lang.ClassNotFoundException: eclispeTest.eclipseTest

I saw one potential fix that told me to go to "Check your project build-path and enable specific output folders for each folder. Go one by one though each source-folder of your project and set the output folder that maven would use." from: Eclipse - java.lang.ClassNotFoundException

But I am new to Eclipse and have no idea what they are talking about.

I have also noticed that when I open the problems tab at the bottom of Eclipse there is one problem that is repeated about 8 times: Description Resource Path Location Type The project was not built due to "Failed to init ct.sym for C:\Program Files\Java\jre-10.0.2\lib\jrt-fs.jar". Fix the problem, then try refreshing this project and building it since it may be inconsistent eclispeTest Unknown Java Problem

Could someone help me figure out what I should try, with baby steps for how I should do it.

Thank you in advance.

PS in case it helps here is a picture of my Eclipse window after I try to run my code:

EDIT: I made a new java project and below is my java project cration window java project cration window (I still got the same error)

1 Answers

Fist of all, In order to work the line " System.out.println("Hello");"

you will require two classes

1)java.lang.System

2)java.io.PrintStream

using above two classes the code runs.you don't have to import these class,because JRE(Java Runtime Environment) automatically does for you.

If you are gettting this error

Error occurred during initialization of boot layer java.lang.module.FindException: Module eclispeTest not found

Which means You didn't setup your "Java project" properly with "JRE"


Let create new project to solve this problem

1)Open Eclipse IDE

2)click FILE (top left most)

3)New

4)java project

5)give you project name (make sure that- "use default location checkbox" clicked)

6)IN JRE section - select use an execution environment JRE(edition as required)

7)Then click finish

This would have solved your problem , go create a Class do your eclipseTest. This time it should work.

java project creation should look like this

Related