|
|
How do I find the directory containing my application |
public static File getApplicationDirectory( Class clas ) {
ProtectionDomain pd = clas.getProtectionDomain(); if ( pd == null ) return null;} This will return the directory that contains the JAR file that contains the specified class. If the class is in a directory tree, it will return the parent of the class root directory, so in a typical JBuilder configuration (with Classes under the project directory), you will get the project directory. Note that it is apparently possible for this to return null under some circumstances. I have heard of one person who got a null CodeSource, but I do not know under what circumstances that happens. It has always worked for me. 2002-Apr-27 6:02am JPMcGrath@JPMcGrath.net | |
| [Append to This Answer] | |
| 2002-Apr-27 11:54am |
| Previous: |
|
| Next: |
|
| ||||||||
|
Java Community
Java Tools |
Code Central JB OpenTools |
Community Recent Threads |
Borland Chat Chat FAQ |
||||||||||||||
|
Feature Matrices 3.0 | 3.5 | 4.0 5.0 | 6.0 | 7.0 |
Shop for JBuilder |
JBuilder Downloads and reg keys |
Report Piracy | ||||||||||||||
|
Online Manuals 4.0 | 5.0 | 6.0 7.0 |
Borland DevSupport's Bug/RFE Form Quality Central Client |
JB Patches & Updates |
JBuilder FAQs TIs | ||||||||||||||
|
JBuilder Newsgroups |
Tamaracka's News Archive |
Mr. Haki's JBuilder Machine |
JGuru's JBuilder FAQ |
||||||||||||||
|
Sun's Bug Parade |
|||||||||||||||||
|
|||||||||||||||||