How do I get the directory name that a class is located in?

How do I get the directory name that a class is located in? I have a class located under /com/dhcmc and I want to be able to retrieve the "/com/dhcmc" that the class is residing under so that I can then use this directoy name to build a relative path name for the other directories supporting the application such as the images directory etc i.e.
|---com
|   \---dhcmc       (my class resides here)
|       +---images  (supporting app dirs under the class dir)
|       +---config  (supporting app dirs under the class dir)

You can try the methods.
Class.getClassLoader()
Class.getResourceAsStream()
Class.getResource()
You probably wont get the complete directory path, but you might
be able to load the files relative to your classes directory.

Similar Messages

  • How do I get the directory name from my program?

    Hi,
    I want to indentify the directory name where my executable is running from the program.
    Is there any API similar to GetCurrentDirectory in Windows.
    Thanks,
    Ram

    I think you may be looking for the getcwd(3C) call.
    That call will get you the current working directory
    for your process. See the man page for details (man
    getcwd).
    Alan
    Sun Developer Technical Support
    http://www.sun.com/developers/support

  • Junit : How can I get the method name (say testMyAddress) that failed

    My code is below
              TestSuite masterSuite = new TestSuite(testClass);
              TestResult result = new TestResult();
              masterSuite.run(result);
                   Enumeration errors = result.errors();
                   while (errors.hasMoreElements())
                        TestFailure error = (TestFailure)errors.nextElement();
                        Test test = error.failedTest();
    /*will give me the class name but how can I get the method that threw the exception.
    I can get fName (that contains the method name) field to get the method,but being private I cannot hold of the field.
    Wondering if there is any easy way to get the method name that threw exception,without writing unneccessary code
                        Class c1 = test.getClass();
    thx
    m

    getting all methods is no good!
    My test class looks like this
    MyTestClass{
    testGoodData(){
    asserttrue(.....);
    testBadData(){
    asserttrue(.....);
    testNullData(){
    asserttrue(.....);
    someHelperMethod(){
    thx
    m

  • How can I get the directory(or folder) name?

    Hello. I want to get directory name using Labwindows CVI. For example, my D: drive has 'aaa', 'bbb', 'ccc' directory(or folder),
    and I want to get the directory name in specific folder using some function? Is there any function knowing the dirctory name?

    Yes !
    Thanks,  it worked !
    Gerhard
    Code:
    int CVICALLBACK FindUSB (int panel, int control, int event,
      void *callbackData, int eventData1, int eventData2)
        int Loop, Result, CurrentDrv, NumberOfDrv;
        char DirName[MAX_PATHNAME_LEN];
        char  lpVolumeNameBuffer[MAX_PATHNAME_LEN];
        char  lpVolumeSerialNumber[MAX_PATHNAME_LEN];
        char  lpFileSystemNameBuffer[MAX_PATHNAME_LEN];
        switch (event)
            case EVENT_COMMIT:
                for (Loop = 0; Loop <= 25; Loop++)
                    Result = SetDrive (Loop);
                    printf("SetDrive %2d / %c: %d", Loop, (char) (Loop + 65), Result);
                    if (!Result)
                        Result = GetDrive (&CurrentDrv, &NumberOfDrv);
                        printf("   GetDrive %c: %d  %d", (char) (CurrentDrv + 65), NumberOfDrv,  Result);
                        Result = GetDir (DirName);
                        if (!Result)
                            printf("   Dir: %s", DirName);
                            GetVolumeInformation(    NULL,                                // lpRootPathName,         
                                                                    lpVolumeNameBuffer,        // lpVolumeNameBuffer,     
                                                                    300,                                 // nVolumeNameSize,        
                                                                    NULL,                               // lpVolumeSerialNumber,   
                                                                    NULL,                               // lpMaximumComponentLength
                                                                    NULL,                               // lpFileSystemFlags,      
                                                                    lpFileSystemNameBuffer,  // lpFileSystemNameBuffer, 
                                                                    300);                              // nFileSystemNameSize)
                            printf("   VolumeName: %s", lpVolumeNameBuffer);
                    printf("\n");
             break;
        return 0;

  • How do I get the file name?

    I'm kind of new to javascript -- working with a colleague who has Adobe Acrobat Professional -- I've got an *old* version of Adobe Acrobat and most of the functions don't work -- but how do we get the file name -- we're trying to develop an application -- so if the user opens c:\something.pdf, we'd like to know the file name (something.pdf).
    If we get a fully qualified path, that's fine -- I think I can parse it.
    Thank you in advance.

    The 'paty' property of the 'doc' object has been available since version 3.01.
    Using the following in the JavaScript console when the Acobat JS API Refenece is open:
    this.path;
    returns:
    this.path;
    /C/Program Files/Adobe/Acrobat 8.0/Help/ENU/JS_api_reference.pdf

  • How do i get the value  of that field

    in JSP i have a field like below..
    <input type="hidden" id="grpId<%=Index%>" value="<bean:write name='GrpList' property='groupId'/>"/>
    In Action class , how do i get the value of that field (i.e id) ?
    String value =reques.getparameter (//what ??);

    i dont want to change the jsp.
    concern is , as the name of the id is dynamic .....so can i get the value in the Action class ?
    is there any trick exists ?
    I will try not to change any jsp code but will do changes in Action class
    Message was edited by:
    Unknown_Citizen

  • I just got a new macbook pro. How do I get the 900  songs that I took off of cds into iTunes on my computer from my iPhone. I had no problems syncing the music I had purchased from iTunes. I have tried to sync it using iTunes match, this did not work.

    I just got a new macbook pro. How do I get the 900+  songs that I took off of cds into iTunes on my computer from my iPhone. I had no problems syncing the music I had purchased from iTunes. I have tried to sync it using iTunes match, this did not work. I would like to have access to my full library without going into the user profile of my old computer, which is on my new computers hard drive. I would like to eventually delete the old profile so that I have more space on my hard drive.

    http://support.apple.com/kb/HT4527?viewlocale=en_US&locale=en_US

  • TS3988 How do I get the email account that was in icloud?

    Hello, my manager handed me his phone off to resolve it and I restored and updated the iphone without knowing who was the account that was set up iCloud, and now I can not activate the phone. How do I get the email account that was in icloud that was configured on the phone? Starting email already know who is the account

    No one can give you that.  Ask your manager to contact the previous owner of the device.  They are the only one who can help you with this, either by providing the correct ID and password, or erasing the phone and removing it from their account as explained here: http://support.apple.com/kb/TS4515.

  • How do I get the file names on a customized proof sheet?

    How do I get the file names on a customized proof sheet?

    Actually, I really don't know what you say.
    But when you see the properties of a file in Windows, you can see there are two file size. One is called "SIze" and the other one is called "Size on disk".
    Therefore, I would like to know the size on disk but not just the size.

  • One of the episodes that i had on my IPOD NANO 8GB was removed off when i put a new episode of that tv show that i bought and put it on my IPOD NANO 8GB. How do i get the first episode that i bought back on my Ipod Nano 8GB with the new episode on it?

    I had an episode of a tv show series on my IPOD NANO 8GB. I just bought a new episode of the tv show and I went to put it on my IPOD NANO 8GB and it removed the first episode off my IPOD NANO 8GB. Now, all I have is the new episode of the tv show on my ipod and I can't get the other back on there. How do I get the other episode that I had on there first back on to my IPOD NANO 8GB with the new episode on my ipod?  Please Help Soon.

    Hello Lisa,
    Double check your iPod's sync settings from under it's TV Shows tab in iTunes.  Make sure it is not set up to sync only unwatched episodes.
    B-rock

  • HT201272 My computer was acting up so i had to restore it and i lost everything. how do i get the songs back that i already paid for?

    My computer was acting up so i had to restore it and i lost everything. how do i get the songs back that i already paid for?

    The easiest way to get back missing items?  Restore your whole hard drive with all your irreplaceable things like photos in about 20 minutes from the backup clone you make on a regular basis.
    Downloading (using iOS or computer) past purchases from the App Store, iBookstore, and iTunes Store - http://support.apple.com/kb/ht2519 - enabled with iTunes 10.3 and newer; not all media formats are available in all countries (see: iTunes in the Cloud and iTunes Match Availability by Country - http://support.apple.com/kb/HT5085); apps, books (not audiobooks), music, t.v. shows, and movies (some - not all studios have permitted this).  Downloading previously purchased movies and TV shows requires iTunes 10.6 or later.  Discontinued items not available. For items not included in the iCloud list (e.g., ringtones), or locations or computer systems where iCloud is not (yet?) available, you only get one download per fee paid.  Apple notes it is your responsibility to back up your purchases.
    Select the store on the left side of iTunes.
    Click on Purchased on the right side under Quick Links.
    You can re-download your available previous purchases.

  • How can I get the frame option that diffuses the edges of a picture in pages 5.2

    I recently updated to Pages 5.2 and have discovered that my favorite and most used framing option is no longer a choice.  How can I get the frame option that allowed you to diffuse the edges to soften a picture edges on 5.2? 

    That is called the vignette, and yes Apple has removed it from Pages 5 along with 100 other features.
    Pages '08/'09 should still be in your Applications/iWork folder so use that.
    Be aware that Pages 5.2 is not only short of features it is also buggy and prone to leaving you with files that won't open.
    Peter

  • How do I get the weather application that is the same as the iphone application on my ipad mini?

    How do I get the weather application that is the same as the iphone application on my ipad mini?
    I don't want any other applications from the app store, I just want the regular weather app that comes with the iphones and other products.

    Apple hasn't made that particular App available for the iPad.

  • How can I get the infoset name by giving the name of a program of a query?

    How can I get the infoset name by giving the name of a program of a SAP Query?
    Regards,
    Subho

    Use FM RSAQ_DECODE_REPORT_NAME.
    You can also use AQLQCAT table.

  • How do I get the procedure name

    Hi,
    With help of our application we are updating one table (P_Balance) in this account status and date through some procedures.
    in some situation only account status column get proper value, but date column having NULL value.
    Now we decided to track this, through which procedure this date column get updated null value.
    For this I decided to write one trigger for the table "P_BALANCE" through which procedure this update is happening.
    How do I get the procedure name.

    You could use DBMS_UTILITY.FORMAT_CALL_STACK and do it. Something like this.
    SQL> create table track_call_stack
      2  (
      3     program_name varchar2(30),
      4     call_stack varchar2(4000)
      5  );
    Table created.
    SQL> create table t
      2  (
      3    no integer
      4  );
    Table created.
    SQL> create or replace trigger t_trig before insert on t for each row
      2  begin
      3    if :new.no is null then
      4       insert into track_call_stack
      5       (
      6          program_name,
      7          call_stack
      8       )
      9       values
    10       (
    11          'T_TRIG',
    12          dbms_utility.format_call_stack
    13       );
    14    end if;
    15  end;
    16  /
    Trigger created.
    SQL> insert into t values (null);
    1 row created.
    SQL> select * from track_call_stack;
    PROGRAM_NAME                   CALL_STACK
    T_TRIG                         ----- PL/SQL Call Stack -----
                                     object      line  object
                                     handle    number  name
                                   3a7ac0ea8         1  anonymous block
                                   3a2bb9d78         3  ARBORU.T_TRIG
    SQL> create or replace procedure p1
      2  as
      3  begin
      4      insert into t values (null);
      5  end;
      6  /
    Procedure created.
    SQL> create or replace procedure p2
      2  as
      3  begin
      4      insert into t values (1);
      5      p1;
      6  end;
      7  /
    Procedure created.
    SQL> exec p2;
    PL/SQL procedure successfully completed.
    SQL> select * from track_call_stack;
    PROGRAM_NAME                   CALL_STACK
    T_TRIG                         ----- PL/SQL Call Stack -----
                                     object      line  object
                                     handle    number  name
                                   3a7ac0ea8         1  anonymous block
                                   3a2bb9d78         3  ARBORU.T_TRIG
    T_TRIG                         ----- PL/SQL Call Stack -----
                                     object      line  object
                                     handle    number  name
                                   3a7ac0ea8         1  anonymous block
                                   3a2bb9d78         3  ARBORU.T_TRIG
                                   3a2b32a10         4  procedure ARBORU.P1
                                   3a61db6a8         5  procedure ARBORU.P2
                                   3a653c3a0         1  anonymous block

Maybe you are looking for

  • Finder shows incorrect hard disk size in status bar

    hey there, i just realised that my finder shows in the staus bar that i have 272gb available. the thing is my mac is only 199gb big? and if i go the apple symbol and than about this mac etc... it show me that i only have 117gb free space and that app

  • Is it Possible to do easy cost planning in network and acitivity level

    Hi, Is it possible to do easy cost planning in network and acitivity level Rgds Purna.M

  • Asynchronous logging

    Hi, I've developed an application which uses Java logging framework for logging. Lately I've thought to make logging asynchronous. So, log messages across the application should be posted to a queue and a thread should read each message, log it, and

  • Cannot open MXF XAVC files in quicktime or FCP7

    I am working with a new Sony FS7 video camera  that records in XAVC codec as mxf  files - Same as the F5 or F55. I have installed the new ProApps update that is supposed to  make it easy to use XAVC in Final Cut 7 which I still use and have also upda

  • Memory Used for Saving Files

    My IT person is giving me a hard time because I've used 5.5 gigabytes of memory in the 2.5 years that I've worked here design everything from brochures to ads, etc.  Does that sound like an unreasonable amount of memory for desktop publishing?  His s