Java Error - can't find main method in class

preview_player
Показать описание
In this video, I'll show you how to resolve a java error "can't find main method(String[]) in class" when you try to compile, this video will help you get up and running quickly.

If you encounter this error then you just forgot to include the .java suffix or extension when compiling your program

#javaforbeginners
#java
#tookootek
Рекомендации по теме
Комментарии
Автор

You won't believe. I was stuck on this simple error for 11 days.


It was a big relief.

diptoacharjee
Автор

thanks man, i was facing this problem for long time...appreciated

varunhsoni
Автор

Thank you so much. It was really a big problem for me. I was trying to solve this error. But I was unable, because i am beginner. thank you sir.

sristibiswas
Автор

thanks man you won my heart in 20 seeconds

Mallikarjunkuri-xute
Автор

luckily with java 22 you just need one command
"java className" will do the job

jskr
Автор

Sir thought i do this it is not running

ab
Автор

basic_pro.java

basic_pro
Error: Could not find or load main class basic_pro
Caused by: basic_pro (wrong name: DSA/recursion/basic_pro)

basic_pro.java
error: can't find main(String[]) method in class: DSA.recursion.Striver




and this is my code

package DSA.recursion;

class Striver {
int cut = 0;

public void yash() {
if (cut == 4) {

return; // Changed 'return 1;' to 'return;'
}
System.out.println(cut);
cut++;
yash();
}
}

public class basic_pro {
public static void main(String[] args) {
Striver a = new Striver();
a.yash();
}
}

yashkelh
Автор

bro still not working, i dont know why

yashkelh