1

/home/nameuser/.myProject/conf実行時に構成ファイルをクラスパスに追加したいと考えています。

使用してみURLClassLoaderましたが、成功しませんでした。

URL[] url={new URL("file://foo")};
URLClassLoader loader = new URLClassLoader(url);

また

ClassLoader currentThreadClassLoader
 = Thread.currentThread().getContextClassLoader();

// Add the conf dir to the classpath
// Chain the current thread classloader
URLClassLoader urlClassLoader
 = new URLClassLoader(new URL[]{new File("mtFile").toURL()},
                      currentThreadClassLoader);

// Replace the thread classloader - assumes
// you have permissions to do so
Thread.currentThread().setContextClassLoader(urlClassLoader);
4

1 に答える 1

0

成功しました

Darcy Qiu に感謝しURL[] url={new URL("file:///home/nameuser/.myProject/conf/")};ますURL[] url={new URL("file:///home/nameuser/.myProject/conf/myfile")};

于 2013-02-22T09:46:26.373 に答える