I am a newbie java dev using netbeans IDE 7.1.1 and im watching this tutorial and right off the bat i get an error in my program even after 5 retypes to make sure its exactly the same as in the video so anyways this is the error
Error: Could not find or load main class javagame.JavaGame Java Result: 1
and this is the code i have written
package JavaGame;
import javax.swing.JFrame;
public class JavaGame extends JFrame {
public JavaGame(){
setTitle("java game");
setSize(500, 500);
setResizable(false);
setVisible(true);
//setDefaultCloseOperation();
}
public static void main(String[] args){
}
}
You can find in this image how my project structure looks.
If that is an exactly copy-paste from your code, then your problem is with package name. Java is case sensitive and your package name is JavaGame
so the qualified name of your class is JavaGame.JavaGame
whilst the exception you get says that it can not find the class javagame.JavaGame
.
Rename your package using Netbeans from JavaGame
to javagame
. That should fix the problem.
javagame
and your class JavaGame
- Alonso Dominguez 2012-04-04 23:50
The problem is with your package name.. change the code at line1
package JavaGame;
package javagame;
NetBeans usually likes to use lower text for packages.
Hope this solves the problem. As the code runs on my machine.
Phil
Go to environmental variables and add path of JDK.
I got this error in past, and solved by setting classpath.