bsd5tu1 wrote:
>We have a test app that's an image viewer. The image viewer references an
>Images directory, which, with respect to its own base directory is
>"./Images".
[Oops, I sent my earlier reply too soon.]
To determine a class's jar-file, from which you can then determine the
jar's parent dir and other jar-relative items, use the 1.4 class
java.security.CodeSource, from which you can get the URL of the jar. With
the jar's URL, you can refer to other URLs, or use the URL's pathname to
refer to a File (assuming it's a file: URL).
Given an object that's an instance of any class in the desired jar:
import java.security.CodeSource;
Class whatClass = whatever.getClass();
CodeSource where = whatClass.getProtectionDomain().getCodeSource();
URL url = where.getLocation();
The URL will typically refer to a jar or directory.
The above code-fragment is from my Whence tool:
<http://lists.apple.com/archives/java-dev/2006/Apr/msg00609.html>
It shows how to "brute force" a location in the absence of CodeSource.
-- GG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden