Re: Dynamically load laf
- From: Thomas Hawtin <usenet@xxxxxxxxxxxxxxxxx>
- Date: Wed, 30 Nov 2005 01:26:22 +0000
Daniel wrote:
Thus I would add that directory to my classpath and all would be peaches. Well not quite. It seems this is not really working.
You realise you have to put the jars file names in the classpath, not just the directory they are in. I seem to remember a feature in 1.6 for allowing specifying the directory only, but don't quote me on that.
So I wrote my own classloader trying to solve this problem. But my classLoader does not seem to work. (code included last) so i wonder if anyone has any good ideas on how to solve this. Not neccerily using a custom classloader, any other ideas are welcome.
URLClassLoader should do just as well. I'm not certain what your problem with the classpath was, but it is probably worthwhile sorting that one out first.
Perhaps it might help if we saw the code of how you are attempting to use the class loader to install the PL&F.
public Class findClass(String name) throws ClassNotFoundException {
File dir= new File("lib/LaF");
if(dir.exists()){
File[] lafs= dir.listFiles();
for(int i=0;i<lafs.length;i++){
if (lafs[i].getName().endsWith(".jar")) {
try{
ZipInputStream zin = new ZipInputStream(new
FileInputStream(lafs[i]));
ZipEntry entry;
while ( (entry = zin.getNextEntry()) != null) {
You want to do all this for every class loaded? For one thing, you are not closing your input streams, even in the normal case. Using a ZipFile would probably be better, too.
Tom Hawtin -- Unemployed English Java programmer http://jroller.com/page/tackline/ .
- Follow-Ups:
- Re: Dynamically load laf
- From: Daniel
- Re: Dynamically load laf
- References:
- Dynamically load laf
- From: Daniel
- Dynamically load laf
- Prev by Date: Re: moving (JTable) columns
- Next by Date: Re: Dynamically load laf
- Previous by thread: Re: Dynamically load laf
- Next by thread: Re: Dynamically load laf
- Index(es):
Relevant Pages
|