we know that we can place this file anywhere on the system...and if we compile if using javac Scjp it wont create a directory structure com/javaranch.www
what i want to ask is whenever there is a use of package in the exam...will the java file be placed in the directory strcutre as given by the package? or will the class file be always placed in some directory with the same directory as given by the package name?
i hope am clear what i want to ask
scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
I don't think it will matter in any question where the .java file is placed. Most of the questions start from line no 5 or 10, so actually you won't see any package or import statement in many questions. And I don't think there would be any question whose behavior will depend on where a .java or .class file is placed. If there are any question from objective 7 (10th chapter of K&B book i.e. Development), then you would be told where the .class file is placed...
but when the class file is put in suppose a directory raju...should i assume that the class file will be stored in directory structure according to the package? because we can compile the file from the current directory and still put the class file there itself without asking the compiler to create the directory structure for us
Class files need to be placed in directories based on how they are packaged. And the classpath specifies the roots, and not the exact directory where the class files are located. The location is determined by the root plus the package definition. If you don't do this correctly, things may not work.
after compilation Test.class file will be created and it is known by its binary name.
It's binary name always be com.name.Test so class file should be in the directory structure as com/name/Test.class.
You should invoke it using java nokia.A not only A (because its binary name is nokia.A) and your classpath is set to direcoty which contains nokia directory that is root of your package as Henry already explained to you.
Do you have nokia directory in your current directory having A.class file in nokia directory? and Do you set your classpath to current directory ? current directory in classpath is indicated by '.'