簡體   English   中英

Eclipse java.lang.module.FindException 和 java.lang.ClassNotFoundException

[英]Eclipse java.lang.module.FindException and java.lang.ClassNotFoundException

我最近安裝了 Eclipse 2020-06 並且正在使用 JDK 10.0.2。 我想使用一個簡單的 Hello world 程序測試 Eclipse:

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

但我收到錯誤: 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." 來自: Eclipse - java.lang.ClassNotFoundException

但我是 Eclipse 的新手,不知道他們在說什么。

我還注意到,當我打開 Eclipse 底部的問題選項卡時,有一個問題重復了大約 8 次: 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 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

有人可以幫我弄清楚我應該嘗試什么,以及我應該如何做的小步驟。

先感謝您。

PS如果它有幫助,這里是我嘗試運行我的代碼后我的 Eclipse window 的圖片:

編輯:我做了一個新的 java 項目,下面是我的 java 項目包裝 window java項目創建窗口 (我仍然遇到同樣的錯誤)

首先,為了使“System.out.println("Hello");”行工作

你需要兩節課

1)java.lang.System

2)java.io.PrintStream

使用以上兩個類代碼運行。你不必導入這些 class,因為 JRE(Java 運行時環境)會自動為你做。

如果您收到此錯誤

啟動層初始化時出錯 java.lang.module.FindException: Module eclispeTest not found

這意味着您沒有使用“JRE”正確設置“Java 項目”


讓我們創建一個新項目來解決這個問題

1)打開 Eclipse IDE

2)單擊文件(最左上角)

3)新

4)java項目

5)給你項目名稱(確保 - “使用默認位置復選框”點擊)

6)在JRE部分-select使用執行環境JRE (根據需要編輯)

7)然后點擊完成

這將解決你的問題,go 創建一個 Class 做你的 eclipseTest。 這次應該可以了。

java 項目創建應如下所示

我最近安裝了 Eclipse 2020-06 並且正在使用 JDK 10.0.2。 我想使用一個簡單的 Hello world 程序測試 Eclipse:

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

但我收到錯誤: 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." 來自: Eclipse - java.lang.ClassNotFoundException

但我是 Eclipse 的新手,不知道他們在說什么。

我還注意到,當我打開 Eclipse 底部的問題選項卡時,有一個問題重復了大約 8 次: 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 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

有人可以幫我弄清楚我應該嘗試什么,以及我應該如何做的小步驟。

先感謝您。

PS如果它有幫助,這里是我嘗試運行我的代碼后我的 Eclipse window 的圖片:

編輯:我做了一個新的 java 項目,下面是我的 java 項目包裝 window java項目創建窗口 (我仍然遇到同樣的錯誤)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM