Where is the running JAVA file is located

Hey,
lets say my java file would be in C:\package1\whereIam.java
if I run this program, how can I ask (command ?),
in which directory the running java file is located.
i.e. I would like to get C:\package1
Aykut
Advertisement
Reply

It's actually more complicated than that. The class could be in a jar file... would you want the directory the jar file is in? Well, I'll let you deal with those issues. You can get a URL to your class like this, I think:URL me = this.getClass().getResource("/" + this.getClass().getName());