
Error: Could not find or load main class SOLVED in Java vs code
Error: Could not find or load main class SOLVED in Java vs code
How to solve error could not find or load main class in java in visual studio code is shown
Content
0.12 -> hi everyone in this video I will be showing you
how to solve the error could not find or load main
5.88 -> class in Java and I am using visual studio code
over here so I'll be showing you four possible
10.62 -> reasons why this error is occurring alright so
the first reason is that you need to have your
15.6 -> class name as the exact same name as your file
name so here you can see so check and try doing
21.36 -> that and the second reason is going to be the jdk
path so you need to go to the location where you
26.82 -> have installed your Java jdk so by default it
will be in C program files Java and you need to
32.52 -> go to bin in that and need to copy this path and
then you need to go to environmental variables
41.04 -> and open it and in the system properties you will
be having this environmental variables and in the
47.28 -> path just click edit and here you can see I have
just pasted the path over here so you have to just
51.84 -> like click on new and paste that particular
path and click ok so this is that particular
56.64 -> path so try doing this as well so this is the
second reason and third reason is Java compile
62.46 -> oh that's the reason why I'm getting this error
now I am trying to run the program without even
66.78 -> compelling it so I need to just at first compile
this program yeah so it's Javac your file name
74.04 -> dot Java and then only I can view the output so
then only I need to run this particular command
79.68 -> so this is the reason why I am getting this error
so if I just now run it yeah I'll be getting the
85.32 -> output well and good so this is the third reason
and another reason maybe you would have forgotten
89.76 -> to save your file so do control plus s save
the file and try running it again and the final
94.68 -> reason is the folder location so in case when
we are using visual studio code you are terminal
100.08 -> folder location should be the same location
as this particular dot Java file is present so
105.48 -> both this terminal location and your dot Java file
location should be same otherwise this won't work
111.72 -> so these are the four reasons I think this error
is occurring in Visual Studio code and if you know
117.42 -> any other way to solve this you can comment this
down so I hope you have found this video useful
122.16 -> mine is a programming Channel by the way I've
done many videos in C C plus plus Java python
126.6 -> node.js mongodb MySQL so do check other videos
of my channel subscribe me thanks for watching
Source: https://www.youtube.com/watch?v=LejHJheMnYI