Sections
Navigation
Running the Sample Application
Sample Application Development
API Specification
Hosted By
Inspired By
Copyright © 2002
The Feynman Project
How does the Controller class know where to find the classes that were created in the sample application? Very simply it has a CLASSPATH that it searches through to find the classes that it is being told to use and create instances of. If you are new to Java and are not familiar with the classpath, then read about it on the Learning Java reference. It has a nice explanation in the first few chapters of the book. For Unix and C/C++ folks, think of it as comparable to the PATH environment variable in the Shell. It just a search path and if the class the compiler or JVM is looking for isn't in the path, then you will get all sorts of errors.
In Java, there are several ways of defining the classpath. The one that is relevant to the Framework is how to define a classpath for an executable Jar file. This is done by defining an attribute in what is called a Manifest file. When the Jar file was created for the Framework, it was packaged the following Manifest file.
Manifest-Version: 1.0 Created-By: Wes Bailey Main-Class: feynman.framework.controller.Controller Class-Path: ./ lib/ classes/ lib/jakarta-regexp-1.2.jarThe manifest file is similar in makeup to a properties file, but it is slightly different. The first 2 elements are self explanatory. The Main-Class element tells the JVM which class to use in order to run it. Here the Controller class has been specified. The last element is the Class-Path. Here it is easy to see the JVM will look in the current directory the Framework Controller is being executed based on the present of the dot (.) in the value. The lib/, classes/ directories are also searched by the JVM. Lastly, the lib/jakarta-regexp-1.2.jar is searched for all of the classes related to the regular expressions package that is used by the Controller.
Now it is clear why the sample application classes where placed in the classes directory of the application directory structure. Anywhere else and the application would not have been able to run. It has not been tested yet if you place a packaged jar file in the lib directory if the Framework will recognize the class files. This will certainly be tested soon with full results documented here.