Finding path of running class  
Author Message
tom.cowdery





PostPosted: 2003-11-20 6:28:00 Top

java-programmer, Finding path of running class File currentDir = new File(System.getProperty("user.dir"));

I need to know the path to a class that is running and have had
partial success. The code shown above finds the folder where the JVM
is running.

If I start my app from a terminal window or a native executable IDE,
the JVM will run in the folder where my class is located and
currentDir points to the folder that I need. But if I start the app
from an IDE written in Java, I get the folder where the IDE is located
rather than the folder where the app that I was running is located.

My app will be used in a classroom setting by people who will NOT have
command prompt permissions. They will have to run it from an IDE.
I'd really like to stick with the one that we're currently using
(written in Java).

Apparently, both the IDE and my application are running in the same
JVM. Is there any way to get the application to run in its own JVM so
user.dir points to that folder?

If not, any other suggestions?

TIA

tom
 
Jonas Kongslund





PostPosted: 2003-11-20 9:14:00 Top

java-programmer >> Finding path of running class Tom wrote:
> I need to know the path to a class that is running and have had
> partial success.
[snip]

Read <http://www.javaworld.com/javatips/jw-javatip105_p.html>. Then modify
the code mentioned in the article so it suits your needs.

--
Jonas Kongslund
 
tom.cowdery





PostPosted: 2003-11-20 22:04:00 Top

java-programmer >> Finding path of running class Jonas Kongslund <email***@***.com> wrote in message news:<4zUub.7462$email***@***.com>...
> Tom wrote:
> > I need to know the path to a class that is running and have had
> > partial success.
> [snip]
>
> Read <http://www.javaworld.com/javatips/jw-javatip105_p.html>. Then modify
> the code mentioned in the article so it suits your needs.

Thanks for the info. I'm not sure this will help with my current
problem since I have no way of knowing the name of the class that is
running, but it may solve some other problem.
 
 
Jonas Kongslund





PostPosted: 2003-11-21 0:19:00 Top

java-programmer >> Finding path of running class Tom wrote:
> Thanks for the info. I'm not sure this will help with my current
> problem since I have no way of knowing the name of the class that is
> running, but it may solve some other problem.

Ok, then I have misunderstood you. Please add some context to your problem,
i.e. what do you know about the class?

--
Jonas Kongslund