+ 1
Having trouble running java programm
when I Type java C:\Users\and the location, I get Error: Could not find or load main class C:\Users\and the location
7 Réponses
+ 1
What do you want exactly to do ?
+ 1
you have to compile first more than likely. In command prompt use javac C:\Users\Hello.java then use the java command like so java C:\Users\Hello this is an example replace with your actual location and application name respectively
+ 1
I compiled it and it worked fine but when I want to run it I type java and the location but it doesn't work
+ 1
when you navigate to the location there should be your .class file which shows you successfully compiled make sure when you use the java command that you dont include .java it should be java C:\Users\Hello if this stilll doesn't work your path to java might not be set correctly
+ 1
Actually my path to java is correct and I tried to open the .class file with java and it still doesn't work
+ 1
yeah you dont open the .class that answer below mine is incorrect, the java command is used on the .java file you just don't include. java when you run so if you have a program called hello.java you would type java hello also the prudent thing would be to ask if it has a main in your program as its not required to compile a file just to run.
0
Run a .class File