Error:Could Not Find or Load Main Class
I can clearly see the .class file in my java folder.
I type in java (FILE NAME) in the windows command prompt, I get the error: Could not find or load main class.
I got the .class file from typing in, javac (FILE NAME)
Please tell me what is wrong. If you need a copy of my code please tell me.
Re: Error:Could Not Find or Load Main Class
Quote:
Originally Posted by
vickyv200
I type in java (FILE NAME) in the windows command prompt,
with file extension? if so, that's your fault
Quote:
Originally Posted by
vickyv200
I get the error: Could not find or load main class.
code?
full error message?
.....
Re: Error:Could Not Find or Load Main Class
Quote:
Originally Posted by
eRaaaa
with file extension? if so, that's your fault
code?
full error message?
.....
Yes, the file is a .java file, no I do not type .java. I am able to run the code when I use java -cp . FILENAME but not java. This applies to everything I have made, here is an example.
public class test{
public static void main(String[] args) {
System.out.println("test");
}
}
The full error message is Error:Could Not Find or Load Main Class test
Re: Error:Could Not Find or Load Main Class
Well, your code sample works for me.
Some notes:
1. Make sure your class names start with a capital letter, as java code convention dictates
2. Java is case sensitive, so the name of the class and the actual java file must be the same:
Code:
public class Test{
//...
and
Test.java
These must match exactly. Once you compile with javac, you should get Test.class. Run this with:
java Test
You also must make sure that when you run the file, you are in the same folder (or the top level of your package tree if using packages!)