I have WINDOWS XP at my system.I set the path in this way.From start manu i entered in to Control Panel then to Performane & Maintenance then I clicked on System & then Advanced & then Environment Variables.Then in side System Varibles i wrote the following line in to "path" starting from it's right end "c:\program files\java\jdk1.5.0_<version>\bin". have i done make some mistake?Please correct me.Waiting for reply .
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Joined: Jun 16, 2006
I can now compile the program. but when I try to run the program by typing java classname say java Add .It throws me an exception message "Exception in thread "main" java.lang.NoClassDefFoundError:Add". why am i getting this message ?what should I do?
You can find out about run time error messages here. That message means one of many things described on that website, most of which are unlikely in this instance.
The most likely explanations are that you haven't actually compiled the Add class (use the dir command on command prompt to find the Add.class file) OR that the Add class doesn't have a public static void main(String args) method in. Remember that is the bit the JVM is looking for; if it doesn't find it, the NoClassDefFoundError is how it responds.
First, if you've compiled successfully, then you should have a .class file in the directory. Have you verified that Add.class exists?
Second, when you enter java Add on the command line, your working directory should probably be the directory that contains the Add.class file. (This is not always the case. But I'm making an assumption because it appears this is one of your first programs after getting the Java compiler installed.) You change directories by typing cd followed by a space and then the path of the desired directory.
Third, I'm also hoping that you have not set a system CLASSPATH variable (which is different than a PATH variable). If you have set a system CLASSPATH without knowing exactly why, then I suggest you remove it completely. If you have set a system CLASSPATH and you really do need to keep it, then make sure it includes a dot (.) to indicate the current directory. [ June 17, 2006: Message edited by: marc weber ]
Joined: Jun 16, 2006
I can successfully compile and run the program.Thanks for help. I'm planning to take scjp5.0.What should I do to score good percentage?
I have Windows Xp Home Edition in my Home Computer.I installed Java 1.5 in C:\Program Files\Java\Jdk1.5.0_06 path.I am trying to execute example.java in C:\Java path.it is giving "javac" is not recoginsed as an internal or external command,operable pragram or batch file" comes each time when i try to compile the program.
Please help me to solve this Problem. Thanks, Bama
Joined: Oct 13, 2005
Bama Sabapathi: Go to Marc Weber's first post in this thread, and follow the installation instructions quoted, to the letter. A single spellign mistake and nothing will work.