I am writing some practical programs for my java certification this morning and noticed that I made a mistake in the name of the package, so it did not match the subdirectory in which the java file was located. I compiled the code waiting for an error, but the whole compiled file is even a warning.
I was looking for a little language, and most of the pages I read said that the package name should match the subdirectory. My experience shows that this is not the case.
When I tried to run the program, it did not work because the .class file was in the wrong directory. I moved it to the correct directory and received this error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/sample/directory /doesnt/even/exist/OtherPackageMemberModifiers (wrong name: com/sample/chap01/O therPackageMemberModifiers)
So, I think I see that Java code will compile if the package and subdirectory do not match, but there seems to be no way to run the code if you do this. It is right?
java package
jonny five
source share