Jump to content

Program doesn't know where it runs from !

- - - - -

  • Please log in to reply
3 replies to this topic

#1
Bat0u89

Bat0u89

    Newbie

  • Members
  • PipPip
  • 25 posts
Is there some kind of function in the standard library that will return the folder from where my compiled class file is running? I've searched but can't find anything...

#2
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
I think this is the cleanest way to do so:

getClass().getProtectionDomain().getCodeSource().getLocation();



#3
Bat0u89

Bat0u89

    Newbie

  • Members
  • PipPip
  • 25 posts
Could you explain that piece of code? What's the runtime class of an object ?(that's what is returned by getClass() right?), What's a protection domain? From what I see from the java docs it's some kind of way to define permissions, but I don't understand much more...

#4
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java

Bat0u89 said:

Could you explain that piece of code?
No I can't, all I could tell is the same as the Javadoc.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users