|
I wonder if there is a way to load an external .class file such that its members are available from within the code one is executing. I am looking for JAVA’s approach encapsulation and reusable code.
I am thinking to make code in small executable bundles that can be independently loaded and offer their functionality to the main application. Is that possible?
I am not looking to build a system for doing this. I want JAVA to do this. If it does not do this already I should look for another solution.
Thanks
|
|
|
Some options: .class files in the current directory or anywhere on the class path are loaded as needed by the virtual machine (vm).
You can use the -cp switch to specify a class path for classes that you want to load or you can set/add to the classpath with the set command at the prompt.
You can import a class, classes or a package from outside the classpath with import statements.
You can write a custom ClassLoader to have more control over the class loading process.
|
|
|
|
|
|
|
// |