This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
linking of classes
Posted by tejinder singh on May 15, 2001 at 11:07 AM
hi java is a interpreted and compiled language.the compiled code is in the form of bytecodes which are interpreted by the interpreter and then executed.when you create a class with a main method which creates objects of two different classes ,the classloader class dynamically links these classes with your class containing the main method.by classes i mean the class objects i.e classname.class .when you change the source file i.e. .java but do not compile it ,the class file remains the original so there is no change.also changing the directory of the class file does not change the output as long as there is no change in it .but the classpath should be appropriately set so that the system can find the class file. hope this solves your problem .if not do write again tejinder > I am first year student at south bank university in london. i had an assignment to write a small propram that simulates softaware for creating key cards for key card locks. in writing this program i have writen three classes. two classes are used only to create objects while the third class is a class that has the main method and will use those two methods to instanciate the objects that are to be used. while testing the classes i heve realised that by compiling the class with the main method ather two clasess ser being compiled. how did i realise this. i made some changes to one of the class more precise i changed the value of the string variable called status from own to withdrawn and did not compile that class but compiled the class with the main method but wen run the class the variable status had the value withdrawn. all the classes wer in the same directory so i changed the variable status back to own and moved the source with extension java to ather directory and than compiled the class with the main method but this time the variable status was still withdrawn. does this mean that javac will check the date of the files if the class was resantky modified and if the source code has more resent date than the class file it will be compiled automatically.sory for my spelling mistakes.
Replies:
|