How can i get the name of a method

i have a method which is calling another method.
how can this submethod get the name from the main method?
Thanks
Thorsten

There was a post about this a while ago, but I can't find it.
Check out the getStackTrace method of Throwable (not the printStackTrace method). getStackTrace returns a StackTraceElement array. Each StackTraceElement has a getMethodName() method. In the returned array, the StackTraceElement at index 0 is the stack frame that the Throwable was created in, and the element at index 1 is the stack frame that your method was called from.
    public String getCurrentMethodName () {
        StackTraceElement[] st = (new Throwable()).getStackTrace();
        // Index 0 is the stack frame of "getCurrentMethodName"
        // Index 1 is the stack frame of the method that called this.
        // Index 2 is the stack frame of the method that called THAT.
        // Note that st[1] should always exist because this method
        // will always be called from another method (main, at very
        // least).  
        return st[1].getMethodName();
    public void myMethod () {
        System.out.println("The name of this method is " + getCurrentMethodName());
    };Hope that helps. I didn't test it, but it should work.
Jason

Similar Messages

  • How can I get the name of a output module template

    Hey guys,
         SDK newbie here.
         How can I get the name of every output module template?
         Thanks
    Zhiqiang Li

    Ok. Bravo
    Please mark this as 'Answered' - it will help others on the forum -

  • Network : How can I get  the name of all computers in the lan ?

    Hi.
    Network : How can I get the name or the IP of all computers in the lan ?

    Easiest way to find all IPs would be to scan the network. Ping every possible IP in the network and all IPs that replied to the ping exist.
    Since I don't know how to do a ping in Java, I would scan for some Ports used by OS Services.
    Since I don't know which ports are used by windows, I think you should look for a ping class (or library).
    Scanning all ports for every IP in a class C network shouldn't take too long. And after finding one port you don't have to try the other ports for that IP, since it has to be online ;)

  • How can I get the name of weblogic.Server

    Hi all,
    in my EJBs I want to know, on which server instance I´m running. I need this for
    logging info. How can I get the servers name?
    When I load the JNDI tree and select java:comp, an error occurs and a lot of information
    is printed. One is weblogic.Server and that is what I´m searching for.
    I use WLS 6.1 SP1
    Any ideas? Thanks,
    Nicole

    Use JMX. See http://dima.dhs.org.
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    Clustering Weblogic? You're either using Coherence, or you should be!
    Download a Tangosol Coherence eval today at http://www.tangosol.com/
    "Nicole" <[email protected]> wrote in message
    news:3c4d6daa$[email protected]..
    >
    Hi all,
    in my EJBs I want to know, on which server instance I´m running. I needthis for
    logging info. How can I get the servers name?
    When I load the JNDI tree and select java:comp, an error occurs and a lotof information
    is printed. One is weblogic.Server and that is what I´m searching for.
    I use WLS 6.1 SP1
    Any ideas? Thanks,
    Nicole

  • How can I get the name of the column in Cursor

    hi,
    how can i derive the name of the columns in cursor
    e.g
    suppose I have a cursor
    cursor c is select * from emp;
    c1 c%rowtype.
    for c1 in c
    I want to display the name of the column how can I do. i don't
    remember the name, but i need it to be displayed tooo.
    thanx in advance
    Sreekant

    You can only do this by DESCing the tables in the cursor and
    then coding eg. v_no := c1.empno;
    APC

  • How can I get the name of an internal table in a textfield?

    Hi,
    I have defined an internal table in a program. Now I need the name of thist table (<u>NOT</u> the components!!!) in a textfield.
    Example for Data-Definitions in my Program:
    data: begin of it_tab occurs 0,
            feld1  like icon-id,
            feld2  like icon-name,
          end of it_tab.
    data: tabname(30) type c.
    How can I transfer the name "IT_TAB" into the field tabname?
    Thanks in andvance!

    No, it has to by 'dynamic'. I don't want to transfer it hard, because it should work for any internal table name.
    The requirement is: There are many function modules that have an input field TABLENAME. I have to give the tablename in the Form 'IT_TAB'.
    But I look for a possibiltity not to write:
    tabname = 'IT_TAB'.
    For DDIC-Tables its not a problem, but I dont know a way for internal tables.

  • How can I get the name at webdb login to pass to reports?

    Where can I get the name of the user who has connected to webdb
    site to pass to some reports?
    the sql code:
    select * from table
    where name=user;
    isn't working !
    that returns WEBDB_SITE_PUBLIC
    It is something with DAD? I must change something?
    Thanks very much!

    Ok. Bravo
    Please mark this as 'Answered' - it will help others on the forum -

  • How can I get the InsertionPoint with FindText method.

    Hi All:
    In indesing script, I can find "abc text" with FindText method, and I want to insert a image here, but how can I get the insertionPoint(the FindText method return an object)? any help?
    Thanks in advance.

    What seems to be the problem?
    >app.findTextPreferences.findWhat = "text";
    >text = app.activeDocument.findText();
    >alert ("insertionpt "+text[0].insertionPoints[0].horizontalOffset);
    gives (as expected) the horizontal position of the first occurrance of "the".
    Note that findText returns an
    i array
    of found items; its length may be 0 (not found), 1 (only found once), or any other number.
    InsertionPoints is
    i also
    an array. Perhaps you expected it to be 'the' position of the found text -- it doesn't. It's an array of all insertion points in the found text.
    'The' position of the text (in its parent text) is something like text[0].index ("The index of the Text in the collection or parent object.")

  • How can I get the name of an Array Item in LabVIEW

    Hi,
    I would need to display the name of the items in the Step.Result.Measurement array in a VI. I can access these properties using the index, but I don't know how to get the name of them like Step.Result.Measurement[0] .
    Is there any suggestions to do it in an elegant way?
    Andras

    Hi Andras,
    look here.
    Regards, Guenter

  • How can I get the name of my songs in iTunes

    I imported the songs in my iTune without internet connect before, now I can connect to internet, how can I get my song's name?
    Thanks.

    If you imported them from CD, using iTunes, select all tracks of the album and choose 'Get CD Track Names' from the 'Advanced' menu.
    This does not work if you imported them from a playlist or imported them from CD with another application and then added them to the iTunes library.
    Hope this helps.
    M
    17' iMac 800 MHz, 768 MB RAM, 200 GB HD, DL burner   Mac OS X (10.4.8)   iTunes 7.0.1

  • How can i get the name of the next field

    Hi,
    I am doing a Module Pool Program having various text boxes. I want to know that how can I determine the value of the field on which I clicked.
    Basically I want to know the field name whenever a user presses enter on a particular field.
    Regards,
    Siddarth

    Hi Siddharth,
    1. GET CURSOR FIELD f.
       we can use the above command
      to trace the cursor.
      (Just see help on this command)
      It works fantastic.
    regards,
    amit m.

  • How can i get the name of the lan that the task is in from a bean

    I'm using jdeveloper ps6 and i wan to get the name of the lane that the my task now is on to display on a page and to disable and enable some
    user fields depending on the name of the lane, as i've 4 organizations and i want to know the name the current organization to disable some fields.

    did you try to get it from the task payload? In the task payload we will have swimlane role. I think, you can get it from the payload.
    Thank you,
    Keshav CH

  • How can i get the name of a symbol and pass to a variable?

    Hello! Is posible to get the name of a symbol and pass to a variable??
    Thanks
    Sonia

    Ok. Bravo
    Please mark this as 'Answered' - it will help others on the forum -

  • How can i get the name of form object

    hi
    can anybody tell me how we retrive the name of form on our webpage
    i try it
    document.form[0].name (i define a function in javascript for matching purpose and i want to get the form name in this function)

    Hi,
    The following example gives you an idea. Implement according to your needs
    <html>
    <body>
    <form name="testform">
    <input type="text" name="txt" value="tesg ">
    <input name="submit" type="button" value="click" onClick="this.form.txt.value=this.form.name">
    </form>
    </body>
    </html>bye for now
    sat

  • How can I get the name of the installed soundcards?

    I want to know, which soundcards are installed on a system. Can somebody tell me, how I can readout the name of the soundcards?
    Thank you for help, yocaba

    Take a look at BCEL, go to goolge and search for BCEL

Maybe you are looking for

  • Make Adobe PDF (Print) the default choice

    Just recently the default setting when exporting a .pdf from InDesign has switched from Adobe PDF (Print) to Adobe PDF (Interactive). Is there any way to switch the default to be Adobe PDF (Print)? This is a very annoying default if you frequently cr

  • IBooks Author (not responding)

    In Activity Monitor I see why my IBA is so slow; it is listed as "not responding" in red type. I don't know what causes this, but it spends more time NOT responding than working. Any clues? Thanks

  • How to input video files into IMAQ VIs

    I have existing mp2 video files (which I could easily convert to other formats) that I would like to input into IMAQ 6.0 VIs to analyze, one frame at a time. Is there a way to grab frames from a video file (without grabbing hardware) to analyze with

  • 10.4.9 Update, not safe yet?

    Hi, I'm using my PowerPC Xserve as mail server, so after having read some of the threads here: Is it safe to install the update or should I wait for another patch to come out?? I don't want to disable my mail server by applying the update ... Thanks,

  • Mozc stops working when I switch locales

    Hello, I have mozc and ibus installed on my system. When I have LANG="en_US.UTF-8" in my /etc/locale.conf, mozc works fine. However, when I set LANG="ja_JP.UTF-8", mozc stops working. Ibus starts fine, and I am able to type in Roman characters, but I