• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
a smoke
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And can you give me a way to get OS environment variable.thanks.
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way is this:

/Rene
[ July 17, 2002: Message edited by: Rene Larsen ]
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic