+ 3
Need help running my java program
I am trying to run my program to test it in my PC's cmd. I used javac command to compile it and it made a .class file in my folder. When I type, "java program" it says, "Error: Could not find or load main class program."
12 Respostas
+ 7
Try dir command in the folder where you called your program. Does it show the compiled program.class file?
If not check which package you declared on top of your java file and move to that folder to run the .class file.
(Alternatively you can add this folder to the CLASSPATH as mentioned by Rishi Anand)
+ 2
Then you must be doing typo while typing class name.
I guess the first letter of your class name is in uppercase
javac Program.java
java Program
+ 2
Then the problem must be in Environment Variables
Check whether you had properly specified PATH and CLASSPATH or not.
At last if this also won't work then better re-install java in your system
+ 1
Yes, and yes, my class is Program. Same as the name. And what do you mean with the third one?
+ 1
I'm a beginner
+ 1
I typed that in
+ 1
That's when I got that error
+ 1
I dont have any typos. I'll post the code, just a sec.
+ 1
I updated the Path with the directories to jdk and jre. But I wasnt told to update classpath
+ 1
So, I add the folder my .java and .class are in to classpath?
+ 1
Hello?