This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Servlets and the fly likes how can  a running class get it's absolute path! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "how can  a running class get it Watch "how can  a running class get it New topic
Author

how can a running class get it's absolute path!

a smoke
Greenhorn

Joined: Jul 16, 2002
Posts: 1
And can you give me a way to get OS environment variable.thanks.
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

One way is this:

/Rene
[ July 17, 2002: Message edited by: Rene Larsen ]

Regards, Rene Larsen
Dropbox Invite
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Here are two samples to get OS environment variable.

To see witch properties you can get try this link:
http://java.sun.com/j2se/1.3/docs/api/java/lang/System.html
another way is:

/Rene
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
a smoke
Welcome to the Java Ranch, we hope you�ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!


Dave
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Rene Larsen wrote: [I][/I]
Note that this will throw a NullPointerException (because "path" is null) if the class was loaded from a jar. It probably won't make much sense if the class was loaded over the network.
In general, expecting getResource() to only refer to real files on the local filesystem is a dangerous asumption.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how can a running class get it's absolute path!