Wake up! Don't let your smile be snatched away by anybody!
Joined: Dec 16, 2009
This was the error I got when I tried to run the program.
Exception in thread "main" java.lang.NoClassDefFoundError: FileDemo1 (wrong name: scjp/FileDemo1)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.security.AccessController.doPrivileged(Native Method)
Could not find the main class: FileDemo1. Program will exit.
I have analysed your code and found that all you want "to extract the name of file without '.' extension from system file path parsed".
correct me if I am wrong.........
I have run your code in my system but I am not getting any exception suggesting most possibly file doesn't exist.But it is not making things better for you further because I am not getting any output also...
Your code seems to have some structural as well as logical defects.
1.Why are you putting so many nested conditions.Try to put them in a single or two.
2."file.separator" would be loaded as a system property, for windows operating system it would be a backward slash, '\'.
i know for escaping "illegal escape character exception" you are using forward slash '/',but it would not solve your purpose any more.
You should use '\\' for the same.
I tried to modify your code and end up with code snippet given below.It may serve your purpose.
Also check the path you are providing exists or not.... .Try it-
Joined: May 02, 2010
I check your code.
Same error occur me. when i run this code, without compile the code.
here i give my command prompt output here :
First i check dir command :
I hope its help for you
Joined: Oct 17, 2009
Divya,Have you compiled the source code before running the proggram
you should respect the fact that FileDemo1 class lives inside the scjp package. So
0) Optionally, put the current directory into your class path
1) go to one directory above
2) javac scjp/FileDemo1.java (to compile)
3) java -cp "." scjp.FileDemo1 (to execute)
Joined: Dec 16, 2009
That was the mistake which I had done. I had left scjp package from the path.