I figured the error was due to my Path or ClassPath being incorrect, but I used Java for months with no problem as I set the Paths when I downloaded Eclipse Neon. I also seen being in packages can cause it, so I created classes outside of packages and still got the error.
The weird thing is some classes I create run fine, but others won't, and they'll be the exact some code in the same package, but only have different names.
Here is the exact example, HelloWorld works, but parserpractice doesn't, and they are both in the exact same location:
package ParserPractice;
public class HelloWorld {
public HelloWorld() {
// TODO Auto-generated constructor stub
}
public static void main(String[] args) {
System.out.println("Hello");
}
}
package ParserPractice;
public class parserpractice {
public parserpractice() {
// TODO Auto-generated constructor stub
}
public static void main(String[] args) {
System.out.println("Hello");
}
}
My Path and ClassPath environment variables on Windows 7 are:
Path variable name: C:\Program Files\Java\jdk1.8.0_101\bin;C:\Program Files\Java\jre1.8.0_101\bin;
ClassPath variable name: C:\Program Files\Java\jdk1.8.0_101\bin
I changed those around constantly, but all my old code still runs, and some new classes still run. But for some reason some new classes will generate the error:
Error: Could not find or load main class.
How do I solve this error?