Error: Could not find or load main class ExampleProgram | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

Error: Could not find or load main class ExampleProgram

I keep on getting that error after I was successfully able to run the java code, but now I cant run the class After I types javac "C:\Program Files (x86)\Notepad++\ExampleProgram.java" everything was fine, but when I typed java ExampleProgram I cannot get "Hello World" to appear

2nd Nov 2016, 5:26 AM
Tito Babatunde
Tito Babatunde - avatar
5 Réponses
+ 2
Did you compile the code and did you do everything without mistakes?
2nd Nov 2016, 5:56 AM
nedas
nedas - avatar
+ 1
Did you use the javac method in the console(cmd) as sololearn explained it?
2nd Nov 2016, 8:10 PM
nedas
nedas - avatar
0
yes I did I made sure but it keeps saying that it cannot find or load main class
2nd Nov 2016, 3:03 PM
Tito Babatunde
Tito Babatunde - avatar
0
public class Tito{ public static void main(String[] args){ System.out.println("Hello World"); } } I saved it as Tito.java
2nd Nov 2016, 3:05 PM
Tito Babatunde
Tito Babatunde - avatar
0
I realize that this is MEGGGAAAA late but... I was having this issue all morning, I figured it out using google ^~^ for me, I was able to get it to work by using "set CLASSPATH=" command on the cmd. For example, my practice file is located "E:\Practice\ExampleProgram.class" so on cmd, I had to enter "set CLASSPATH=E:\Practice" There is a way to set the CLASSPATH to the directory of your choosing but this particular method will only work for the currently opened cmd box. If you use this method, you will have to do it each time you open a new cmd promt. Good luck and happy coding!!
17th Apr 2017, 11:22 PM
dbex43302
dbex43302 - avatar