Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

Where are the class files?

Thread view: 
kaopelt@gmail.com - 12 Apr 2007 18:11 GMT
How can I find out where the class files are installed in a
programmtic way?

Thanks,
Menlo
Oliver Wong - 12 Apr 2007 18:30 GMT
> How can I find out where the class files are installed in a
> programmtic way?

   Classes might not come from files: they may be loaded from the
network, or dynamically generated.

   - Oliver
Tom Hawtin - 12 Apr 2007 21:22 GMT
> How can I find out where the class files are installed in a
> programmtic way?

clazz.getProtectionDomain().getCodeSource().getLocation()

You might not get meaningful information from this.

Tom Hawtin
Andrew Thompson - 13 Apr 2007 02:22 GMT
>How can I find out where the class files are installed in a
>programmtic way?

Why (do you think you need to know)?  What ability
are you attempting to bring to the end user, by identifying
where the class files reside?

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Arne Vajhøj - 16 Apr 2007 02:42 GMT
> How can I find out where the class files are installed in a
> programmtic way?

Try something like:

    private String getPath(Class cls) {
        String cn = cls.getName();
        String rn = cn.replace('.', '/') + ".class";
        String path =
getClass().getClassLoader().getResource(rn).getPath();
        int ix = path.indexOf("!");
        if(ix >= 0) {
            return path.substring(0, ix);
        } else {
            return path;
        }
    }

Arne


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.