iT邦幫忙

0

Visual studio code 建置Java 環境 錯誤 "java.lang.Error: Unresolved compilation problem:

各位前輩 小弟想從Python轉行 入門Java
於是想在Visual studio code建置Java 開發環境 想Runtime一個hallo world
結果出現 "java.lang.Error: Unresolved compilation problem: 錯誤
剛剛有爬了很多文 好像是配置問題但我能做的都做了 版本是JDK . 15
有安裝 Jave extension pack 、 java test runner

https://ithelp.ithome.com.tw/upload/images/20210305/20126577G1ZuMFsZaj.jpg

public class Main {

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

https://ithelp.ithome.com.tw/upload/images/20210305/20126577Jvas6v6lTB.jpg
(手動新增路徑)
https://ithelp.ithome.com.tw/upload/images/20210305/20126577zZGwv6JzxH.jpg
此圖為JAVA環境變數設定完成
https://ithelp.ithome.com.tw/upload/images/20210305/201265779Olck9Jl5n.jpghttps://ithelp.ithome.com.tw/upload/images/20210305/20126577vIy3jVTY3h.jpg

請各位前輩指點可能是哪個環節出了錯。

############################################更新####################
https://ithelp.ithome.com.tw/upload/images/20210305/20126577aRXLAAlnzN.jpg
https://ithelp.ithome.com.tw/upload/images/20210306/20126577aRNB00XGxm.jpg

看更多先前的討論...收起先前的討論...
印象中,檔名和class要一樣。
Test.java那麼public class Test{...}
修正了 出現
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
剛翻了google網路好像沒有有關vscode的配置教學
奇怪的是 我按F5 執行 會出現這個錯誤代碼
但我案程式碼當中的RUN 可以正常印出HALLO WORLD
這是正常的嗎?
samshum iT邦新手 5 級 ‧ 2021-03-06 01:20:04 檢舉
是否要javac 先運行一次,才可java
1.class命名習慣首字大寫
2.通常不能直接改名,請重開檔案
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答