This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: SystemClassLoader and current directory
- From: Andrew Haley <aph at redhat dot com>
- To: Thomas Hallgren <thomas at tada dot se>
- Cc: java at gcc dot gnu dot org
- Date: Thu, 9 Feb 2006 15:02:20 +0000
- Subject: Re: SystemClassLoader and current directory
- References: <dsfi37$4u4$1@sea.gmane.org>
Thomas Hallgren writes:
> Hi,
> I seems the SystemClassLoader is setup to search the current
> directory by default. Is there anything I can do to prevent this? I
> use GCJ embedded with the PostgreSQL backend and the VM is
> initialized using JNI.
>
> I provide a ClassLoader that will utilize the database and it's
> essential that the Java code is prevented from using the file
> system.
The standard trick here is to set your ClassLoader's parent to null
and use it to load your startup main class. All references from
classes referred to my main will use only your ClassLoader.
Andrew.