SOLVED - Error: Could not find or load main class Main (FIXED 100%)

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ธ.ค. 2024

ความคิดเห็น • 66

  • @d.d5554
    @d.d5554 ปีที่แล้ว +9

    in my case there is no "code runner executor map" section in the code.Then i have to add it, yeah now it worked

    • @KUKUFMTUSHAR
      @KUKUFMTUSHAR 10 หลายเดือนก่อน +2

      How to add this map

    • @shekhargupta435
      @shekhargupta435 2 หลายเดือนก่อน

      @@KUKUFMTUSHAR +1

  • @OnstreamGaming
    @OnstreamGaming 5 หลายเดือนก่อน +2

    Oh man , You saved my life , I am facing this issue since more than a week and struggling to solve it , watched tons of youtube videos and stackoverflow solutions, and even after fighting with chatgpt , i was unable to figure out what actually is causing the error , somehow my code was running from "RUN AS JAVA CODE" but it was irritating too do it every time before run, also earlier everything was fine , suddenly after i played with some environment variables i got this issue, and was unable to resolve it . Really really thanks for this help .

    • @vikasz2
      @vikasz2  5 หลายเดือนก่อน

      Glad to help you. Keep coding.

  • @namratapatil8692
    @namratapatil8692 ปีที่แล้ว +4

    thank you so much i saw lot of videos but no one tell this approach . very helpful

  • @armonywhite680
    @armonywhite680 ปีที่แล้ว +2

    Thank u so much i watch a lot of videos expalaining that i have to chage the system variables but it didn't work for me. I'm glad i found your video

  • @gireeswar18
    @gireeswar18 5 หลายเดือนก่อน +1

    Best video! If you cant find the code runner executor map, install code runner and in the settings.json just type code-runner.executormap and the code wiil appear automatically then modify as mentioned in the video

    • @vikasz2
      @vikasz2  5 หลายเดือนก่อน +1

      Thanks for the appreciation.

  • @titlibasu3635
    @titlibasu3635 2 วันที่ผ่านมา

    Although the run button works after doing all these but in the terminal when I write javac filename.java and then java filename, I again shows the same error (couldn't find or load main class filename)

  • @eshalal3283
    @eshalal3283 ปีที่แล้ว +7

    I have done the same as you have done in the video still the problem persist even i used powershell as well

    • @shoebahmad6988
      @shoebahmad6988 5 หลายเดือนก่อน

      Same problem brother

  • @cristianrusso5749
    @cristianrusso5749 6 หลายเดือนก่อน

    Thank you for the video anyway, but...
    SOLVED ANOTHER WAY:
    No method solved it for me, either of those presented in this video or in others. The only way for me was:
    - when compiling, click on the "FIX" option
    - then click on the "clear cache" option
    ... and SOLVED !

    • @vikasz2
      @vikasz2  6 หลายเดือนก่อน

      Thanks for sharing

    • @titlibasu3635
      @titlibasu3635 2 วันที่ผ่านมา

      Where did you find the FIX option ?? @cristianrusso5749

  • @prajwalawari3144
    @prajwalawari3144 11 หลายเดือนก่อน +1

    when after opening settings when i press that icon in the corner i am not able to see code runner executor map. why?

    • @vikasz2
      @vikasz2  11 หลายเดือนก่อน +1

      You need to install the code runner from the extensions. If that setting isn't there, the copy the setting from here:
      "code-runner.executorMap": {
      "javascript": "node",
      "java": "cd $dir && javac $fileName && java -classpath . $fileNameWithoutExt",
      "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
      "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
      "objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
      "php": "php",
      "python": "python3 -u",
      "perl": "perl",
      "perl6": "perl6",
      "ruby": "ruby",
      "go": "go run",
      "lua": "lua",
      "groovy": "groovy",
      "powershell": "powershell -ExecutionPolicy ByPass -File",
      "bat": "cmd /c",
      "shellscript": "bash",
      "fsharp": "fsi",
      "csharp": "scriptcs",
      "vbscript": "cscript //Nologo",
      "typescript": "ts-node",
      "coffeescript": "coffee",
      "scala": "scala",
      "swift": "swift",
      "julia": "julia",
      "crystal": "crystal",
      "ocaml": "ocaml",
      "r": "Rscript",
      "applescript": "osascript",
      "clojure": "lein exec",
      "haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
      "rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
      "racket": "racket",
      "scheme": "csi -script",
      "ahk": "autohotkey",
      "autoit": "autoit3",
      "dart": "dart",
      "pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
      "d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
      "haskell": "runhaskell",
      "nim": "nim compile --verbosity:0 --hints:off --run",
      "lisp": "sbcl --script",
      "kit": "kitc --run",
      "v": "v run",
      "sass": "sass --style expanded",
      "scss": "scss --style expanded",
      "less": "cd $dir && lessc $fileName $fileNameWithoutExt.css",
      "FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
      "fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
      "fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
      "fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
      },

    • @manojkr2362
      @manojkr2362 8 หลายเดือนก่อน

      @@vikasz2 above code gives error give the correct code please

  • @yafirizkykurniawan327
    @yafirizkykurniawan327 9 หลายเดือนก่อน +1

    mine still error after java -classpath . Pemahaman
    PS D:\Belajar.java> java -classpath . Pemahaman
    Error: Could not find or load main class Pemahaman
    Caused by: java.lang.ClassNotFoundException: Pemahaman
    please help me l suffer from this

    • @vikasz2
      @vikasz2  9 หลายเดือนก่อน

      It usually happens when you code in vscode. Change your filename to something else and then compile and run the bytecode. Hope it helps.

  • @sajalchitlangia3033
    @sajalchitlangia3033 ปีที่แล้ว +1

    code:
    package Assignment1;
    public class Greeting {
    public static void main(String[] args) {
    System.out.println("Hello
    World");
    }
    }
    Error:
    Error: Could not find or load main class Greeting
    Caused by: java.lang.NoClassDefFoundError: Assignment1/Greeting (wrong name: Greeting)
    I tried all the steps but still getting the same error

    • @maanas_sehgal
      @maanas_sehgal ปีที่แล้ว +2

      sammeeee please help me, whenever i add the package, it shows error everytime

    • @Spedmuel
      @Spedmuel ปีที่แล้ว +1

      Did you find a solution?

    • @sajalchitlangia3033
      @sajalchitlangia3033 ปีที่แล้ว +1

      @@Spedmuel yeah! Instead of adding the package folder, I just open my vs code in another window with that assignment1 folder!

    • @maanas_sehgal
      @maanas_sehgal ปีที่แล้ว +1

      @@sajalchitlangia3033 can you please elaborate, like how to do that, idk how but after some time the error doesnt appear anymore but still it's annoying

    • @VishalMishra-dc7mr
      @VishalMishra-dc7mr 11 หลายเดือนก่อน

      ​@@maanas_sehgalcan you find the solution plzz help

  • @Prince-9871
    @Prince-9871 4 หลายเดือนก่อน

    Wow sir thank you.. 😭😭
    Finally chal gya.. 🤧😭😭

  • @rajatsharmayo
    @rajatsharmayo 3 หลายเดือนก่อน

    Bro bro bro I was struggling to get this fixed and thanks to your video it's solved now

  • @dollyprajapati7649
    @dollyprajapati7649 5 หลายเดือนก่อน

    Thankyou it's very helpful 😊😊

    • @vikasz2
      @vikasz2  5 หลายเดือนก่อน

      Happy to help

  • @Henschel-yl2fl
    @Henschel-yl2fl 4 หลายเดือนก่อน

    My file name is Autocomplete.java but when I initiate javac Autocomplete.jave It keeps popping an error telling me the file is not found. Please what can I do?

    • @vikasz2
      @vikasz2  4 หลายเดือนก่อน

      Make sure your file is saved in the current folder where you are executing your javac command.

  • @ganeshreddy6598
    @ganeshreddy6598 2 หลายเดือนก่อน

    After using java -classpath . Demo
    I got output but is there any alternative bcoz i have to do it every time when ever i run java file

    • @vikasz2
      @vikasz2  2 หลายเดือนก่อน

      Watch the full video, I have explained how to do the same.

  • @shubhamsahu492
    @shubhamsahu492 2 ปีที่แล้ว

    i don't have written code runner executer map in my vs code..... what should I do ? plzz tell

    • @vikasz2
      @vikasz2  2 ปีที่แล้ว

      You need to install code runner extension from vscode marketplace.

  • @aniruddahpaul5537
    @aniruddahpaul5537 7 หลายเดือนก่อน

    Thanks Man, The first method worked for me

  • @anshumangupta7820
    @anshumangupta7820 ปีที่แล้ว

    + ~
    Missing argument in parameter list.
    + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingArgument
    aapne bola vo krne ke baad ye error dikha raha hai please help

  • @ceae69
    @ceae69 5 หลายเดือนก่อน

    thanks, the saving method worked for me

    • @vikasz2
      @vikasz2  5 หลายเดือนก่อน +1

      Glad I could help

  • @iamharsha8679
    @iamharsha8679 ปีที่แล้ว

    nice one it worked in vs code but when i try to run in cmd it shows the same error , how to solve this?

  • @alphonse7133
    @alphonse7133 6 หลายเดือนก่อน

    Very helpful brother..... thanks you

  • @harsh4037
    @harsh4037 ปีที่แล้ว

    very helpful video but still showing error
    Error: Could not find or load main class loopHollowSquare
    Caused by: java.lang.NoClassDefFoundError: loopHollowSquare (wrong name: LOOPS/loopHollowSquare)
    plzz help me sir🙏🙏🙏🙏

    • @vikasz2
      @vikasz2  11 หลายเดือนก่อน

      NoClassDefFoundError In Java
      Reasons:
      Java Virtual Machine is not able to find a particular class at runtime which was available at compile time.
      If a class was present during compile time but not available in java classpath during runtime.
      Read the 4th answer in this thread:
      stackoverflow.com/questions/34413/why-am-i-getting-a-noclassdeffounderror-in-java
      Hope it helps!

  • @pokemonfanbeast393
    @pokemonfanbeast393 2 ปีที่แล้ว +3

    Thanku so much very helpful

  • @ashwinchandurkar-x8p
    @ashwinchandurkar-x8p 10 หลายเดือนก่อน

    thank you brother...just liked and sus,,,,,

  • @ti7an68
    @ti7an68 26 วันที่ผ่านมา

    Thank you my boiii...

  • @mohanmadini1239
    @mohanmadini1239 3 หลายเดือนก่อน

    Thank You so much Sir

  • @manhwa_monster
    @manhwa_monster 10 หลายเดือนก่อน

    Thank you so much bro 😊

  • @porchheng1320
    @porchheng1320 ปีที่แล้ว

    thank you very much, it works

  • @bandaruharsha2978
    @bandaruharsha2978 ปีที่แล้ว

    I have the problem even after updating json settings.

    • @vikasz2
      @vikasz2  ปีที่แล้ว

      try using powershell instead of traditional cmd prompt

  • @sasmitapallai40325
    @sasmitapallai40325 ปีที่แล้ว

    Thank you thank you thank you so much bhaiyaa

  • @nightmare2411
    @nightmare2411 8 หลายเดือนก่อน

    W vid thank you sm
    👍

  • @clashervatsal7305
    @clashervatsal7305 5 หลายเดือนก่อน

    Thanks!

  • @GARVITRAKHECHA-uy7rp
    @GARVITRAKHECHA-uy7rp 8 หลายเดือนก่อน

    nice one thanks

  • @ashishkoge9325
    @ashishkoge9325 10 หลายเดือนก่อน

    thank you so much

  • @tejassurse9475
    @tejassurse9475 8 หลายเดือนก่อน

    thanks

  • @djprago1970
    @djprago1970 7 หลายเดือนก่อน

    worked tnks

    • @vikasz2
      @vikasz2  7 หลายเดือนก่อน

      Good to hear

  • @abhisheksingh-uh9fc
    @abhisheksingh-uh9fc ปีที่แล้ว

    thnkx

  • @rakshitajaju9868
    @rakshitajaju9868 2 ปีที่แล้ว

    Java.lang.Classnot found exception: com.mysql.cj.jdbc.Driver
    Could you solve this error using jdk19 and vs code

    • @vikasz2
      @vikasz2  2 ปีที่แล้ว +1

      Please look for solution here....
      stackoverflow.com/questions/17484764/java-lang-classnotfoundexception-com-mysql-jdbc-driver-in-eclipse
      Otherwise I'd have to look at your project. You can share your github repo link here.

  • @hiranmai8478
    @hiranmai8478 6 หลายเดือนก่อน

    thankyou