|
-
April 2nd, 1999, 01:17 PM
#1
getCodeBase() equivalent for application?
Hi:
Is there an equivalent form of getCodeBase() I can use in an application to find the directory the application is running from?
Thanks,
Derek
-
April 6th, 1999, 12:32 PM
#2
Re: getCodeBase() equivalent for application?
Try
public static Properties getProperties().
It should provide you with a set of properties consisting of for example:
java.version
java.vendor
java.home (java installation directory)
java.class.path (could come in handy for you)
os.name
os.version
user.name (user account name!)
user.home (user's home directory)
user.dir (user's current working directory.
Probably what you're looking for)
-
April 15th, 1999, 11:39 AM
#3
Re: getCodeBase() equivalent for application?
Yep, there's a way:
String classDirectory = getClass().getResource("ClassName.class").toString();
This line of code gives you the string representation of the directory where the class is.
Hope that helps.
Matty
-
October 8th, 1999, 04:08 PM
#4
Re: getCodeBase() equivalent for application?
When I use the following:
t = new Test();
String classDirectory = t.getClass().getResource("Test.class").toString();
I get 'systemresource:/FILE0/+/com/xxx/yyy/Test.class' (without the quotes) ? What does /FILE0/+/ mean ? I was expecting drive and directory info (Window NT)?
-
October 8th, 1999, 04:54 PM
#5
Re: getCodeBase() equivalent for application?
One simple solution is :
public String getClassDirectory() throws IOException {
File f = new File(".");
return f.getCanonicalPath();
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|