r/javahelp • u/superAA_ • Apr 02 '16
help?
I am new trying to learn java programming i started watching "thenew****" Tutorials, everything was fine untill i reached the second video where i reach the command prompt part to load my code. When i want to put ex " java Hello.java" It says Error: Could not find or load main class. DOnt even know if i have the right java or version anyway this is it . jre1.8.0_45 . Hope i get helped.
0
Upvotes
1
u/nutrecht Lead Software Engineer / EU / 20+ YXP Apr 03 '16
When you're starting out make sure that every class you create is public, is in their own .java file and it matches the name of the Java file. So "public class Hello" should be in Hello.java and public class apples should be in apples.java (mind the casing!).
Also: in Java we PascalCase class names so please follow those naming conventions. To get you started:
Paste this into Hello.java (make sure the names match!) and you can compile it with javac Hello.java and run it with java Hello.
Also: programming is precise because computers are incredibly stupid. If you make up your own naming and just randomly change stuff without understanding what you did you're just going to fail 99% of the time.
Last but not least: the new boston is a horrible learning source. This course is much better.