Hi I am getting the following error messages.ANy suggestions why?
Exception in thread "main" java.lang.NoClassDefFoundError: TicTacToeV1 (wrong name: mytictactoe/TicTacToeV1)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:637)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
Could not find the main class: TicTacToeV1. Program will exit.
Error messages
Started by svaidya, Feb 11 2009 07:52 AM
15 replies to this topic
#1
Posted 11 February 2009 - 07:52 AM
|
|
|
#2
Posted 11 February 2009 - 08:18 AM
Where is TicTacToeV1 located?
#3
Posted 11 February 2009 - 08:49 AM
I'm not sure what the error is referring to, but I can give you some general help that might solve your problem (and be a good check for future errors). Firstly, make sure you are spelling it correctly. If you are compiling from the command prompt, make sure that you have the spelling correct, and include .java on the end when compiling (for example, "javac TicTacToeV1.java"). Next, make sure your prompt is in the correct directory. If you are not looking in the correct folder, then it will not be able to find it.
Also, if your new to java in a whole, then it might be worthwhile to check out this site...
java.sun.com/docs/books/tutorial/getStarted/cupojava/win32
Cheers and Good Luck!
Jared.
Also, if your new to java in a whole, then it might be worthwhile to check out this site...
java.sun.com/docs/books/tutorial/getStarted/cupojava/win32
Cheers and Good Luck!
Jared.
#4
Posted 11 February 2009 - 08:59 AM
I am running it in the current folder.my helloWrldApp.java doenot give this error.
#5
Posted 11 February 2009 - 10:00 AM
I don't know much about compiling anymore (been a year or two since I started using IDE's). If you can, why not post the source in case there is something wrong with it that is causing it to not compile.
#6
Posted 11 February 2009 - 01:54 PM
Hey I have attached the file...
Attached Files
#7
Posted 11 February 2009 - 02:40 PM
Hmm...
To start, I'm not sure what format you saved that in, but when I loaded it, it was very mixed up and I needed to do some formatting to be able to read it. Anyways, From what I can tell you create an object, then in the constructor it runs the same as a method would normally. I don't think this is a particularly good idea from what I know of constructors and may be where the error is coming from. You should split your constructor into two methods (testing each in sequence to check for errors, or to see where this one is coming from.) Without going into depth testing myself I would just suggest you re-do the setup of the main method, and have it invoke a method other then the constructor. This way, you can see where it's going wrong.
Sorry I can't be of more help.
To start, I'm not sure what format you saved that in, but when I loaded it, it was very mixed up and I needed to do some formatting to be able to read it. Anyways, From what I can tell you create an object, then in the constructor it runs the same as a method would normally. I don't think this is a particularly good idea from what I know of constructors and may be where the error is coming from. You should split your constructor into two methods (testing each in sequence to check for errors, or to see where this one is coming from.) Without going into depth testing myself I would just suggest you re-do the setup of the main method, and have it invoke a method other then the constructor. This way, you can see where it's going wrong.
Sorry I can't be of more help.
#8
Posted 11 February 2009 - 03:06 PM
I compiled your program ant it ran fine. But looking at the stack trace it looks like you are not running from the command line. Are you running it as an applet?
#9
Posted 11 February 2009 - 03:07 PM
Also, you are implementing the actionlistener, but as far as I can tell you did not actually make a method for it.
#10
Posted 13 February 2009 - 08:40 AM
I wantt o call the class from Main function.How do I call it?I am using command line to run.Its not an applet.Ex:javac TicTacToeV1.java then java TicTacToeV1
#11
Posted 13 February 2009 - 10:46 AM
svaidya said:
I wantt o call the class from Main function.How do I call it?I am using command line to run.Its not an applet.Ex:javac TicTacToeV1.java then java TicTacToeV1
Could I see code?
If you mean it extends from another class or is the other class an object, then you need to create a new object of the object !
#12
Posted 13 February 2009 - 01:26 PM
The code is attached in the earlier post....


Sign In
Create Account

Back to top










