Get the method name

hi
can anyone know how to get the name of method from its catch block.
For example
i have a class called Hello.java
and inside that a method called display();
and i have a written the code inside a try catch block.so when an exception occurs i want to create a log file
i got the class name using this.getClass().getSimpleName()
so is there any way to get the method name , where the catch is written. (here in example i should get it as "display")
plz help me
im in great need.
hope u understood my doubt.
rgds

Use a logging framework, and name the loggers well & use meaningful messages?
Or create a Throwable, [fill in|http://java.sun.com/javase/6/docs/api/java/lang/Throwable.html#fillInStackTrace()] the stack trace, get the required StackTraceElement and [get the method|http://java.sun.com/javase/6/docs/api/java/lang/StackTraceElement.html#getMethodName()] from this.

Similar Messages

  • 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 to get the method names in a class

    hi  friends,
    Could any of you tell me the report or function module  to display all the method names in a given class.
    thanks in advance.
    regards,
    kumar

    Hi Kumar ,
    Open ur class in SE24 transaction ,there is a tab for methods ..
    u'll get the list of methods form there ... n in source u'll get their operative details
    Regards
    Renu

  • Where will i get the method code and method name in Bpc

    Dear Experts,
    Thanks for watching this thread at the time of creating Consolidation methods they have
    NEW
    HOLDING
    GLOBAL
    PROPORTIONAL
    EQUITY
    lEAVING (END OF THE YEAR)
    LEAVING(DURING THE YEAR)
    Where will i get the method Code and method name.
    Can you please guide me.
    Regards,
    Srinivasan.

    The consolidation methods types you have listed are the standard ones  provided by BPC for Consolidation Method types.
    You can set the Consolidation Methods in the BPC Administration Console under Business Rules Library -> Consolidation Methods.
    There you can see some defaults - you can remove these and set your own if you prefer.
    You should read the BPC340 Training guide.

  • How to get the Class name of an API method?

    Like most of us, it's difficult to know where every method within a Java class is. Also, many of the same methods are scattered throughout Java Classes. I know of two methods that retreive this... getClass().getName(). But, you must have an object to use these. Is there a way to find out what Class contains a method or Class variable thru an Applet or Java Application?? Obviously, I can look at API Docs; but this takes time.
    Tks Randy

    RajEndiran wrote:
    Can anyone please let me know how we can get the class name of a page or region in oracle apex?What do you mean with class name? The name of the template (e.g. the css style class name)?
    I would also like to know how we get the DOM object ID for particular item.Use firebug or inspect the source code of the rendered page to see the object IDs. Other then then, the typical ID of page items is the name of the item. For regions you can set your own ID.

  • How to get the folder name of selected subitem in tree structure?

    Hi All,
               I created a tree structure like below.
             ->Folder1-- 1
                              2
                              3
            ->Folder2-----1
                               2
                               3
                    i.e i have two folders & each folder having the values like above.Now i want to perform some action by clicking on the any of the values.Suppose if i click value 2,i want to do some action.the actions need to perform is varies from floder to to folder.
            So How can i get the folder name of clicked Value?
    Regards,
    Ravi

    Hi Kumar ,
    the below code should help you.
    Register the below action for the leaf node for which u need the subfolder's name above it.
    Worked fine in my system ...hope it does in ur scenario too
    method ONACTIONGET_PATH .
      data : lr_element TYPE REF TO if_wd_context_element,
             lr_node TYPE REF TO if_wd_context_node,
             ls_path type string,
             ls_path_node TYPE string,
             lt_string type TABLE OF string,
             l_lines type i,
             l_lines_1 TYPE i.
      lr_element = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
    **-> getting the path of the node/leaf
    *which  u had clicked and from that getting the node above it
      ls_path = lr_element->get_path( ).
      SPLIT ls_path at '.' into table lt_string.
    -> remove the first 2 entries as they will contain the view name
      DELETE lt_string FROM 1 to 2.
      l_lines = LINES( lt_String ).
      l_lines_1 = l_lines - 1.
    -> remove the last 2 entries as they will contain the element in the path
      DELETE lt_string  from l_lines_1 to l_lines.
      LOOP AT lt_string into ls_path.
        CONCATENATE LINES OF LT_STRING into ls_path_node SEPARATED BY '.'.
      ENDLOOP.
    **-> getting access to the node above the leaf element
    LR_NODE = WD_CONTEXT->PATH_GET_NODE( path = ls_path_node ).
    lr_element = lr_node->get_element( ).
    **-> Getting the name of the folder...
    *here path is the attribute in my context which stores the name of the folder
    lr_element->get_attribute( EXPORTING name = 'PATH' IMPORTING value = ls_path ).
    endmethod.

  • How to get the shared name of a folder in my PC through java code.

    Hi,
    I have a shared folder in my PC adn its shared name is different. Is there any way to get the shared name of that folder from java code. I have the absolute path of that dir. Can I get the shared name from that path in java or is there any other method.
    Thanks.
    Edited by: pavanspecial on Nov 28, 2007 11:34 PM

    Hi, Thanks for your reply. I have even tried through 'net share' , but i could not the share name from the path i have. For the 'net share' i need to give the share name itself.

  • How is it posible to get the File name, size and type from a File out the H

    How is it posible to get the File name, size and type from a File out the HttpServletRequest. I want to upload a File from a client and save it on a server with the client name. I want to conrole before saving the name, type and size of the file.How is it posible to get the File name, size and type from a File out the HttpServletRequest.
    form JSP
    <form name="form" method="post" action="procesuploading.jsp" ENCTYPE="multipart/form-data">
    File: <input type="file" name="filename"/
    Path: <input type="text" readonly="" name="path" value="c:"/
    Saveas: <input type="text" name="saveas"/>
    <input name="submit" type="submit" value="Upload" />
    </form>
    proces JSP
    <%@ page language="java" %>
    <%@ page import="java.util.*" %>
    <%@ page import="FileUploadBean" %>
    <jsp:useBean id="TheBean" scope="page" class="FileUploadBean" />
    <%
    TheBean.doUpload(request);
    %>
    BEAN
    import java.io.*;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.ServletInputStream;
    public class FileUploadBean {
    public void doUpload(HttpServletRequest request) throws IOException
              String melding = "";
              String filename = request.getParameter("saveas");
              String path = request.getParameter("path");
              PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("test.java")));
              ServletInputStream in = request.getInputStream();
              int i = in.read();
              System.out.println("filename:"+filename);
              System.out.println("path:"+path);
              while (i != -1)
                   pw.print((char) i);
                   i = in.read();
              pw.close();
    }

    Thanks it works great.
    Here an excample from my code
    import org.apache.commons.fileupload.*;
    public class FileUploadBean extends Object implements java.io.Serializable{
    String foutmelding = "geen";
    String path;
    String filename;
    public boolean doUpload(HttpServletRequest request) throws IOException
         try
         // Create a new file upload handler
         FileUpload upload = new FileUpload();
         // Set upload parameters
         upload.setSizeMax(100000);
         upload.setSizeThreshold(100000000);
         upload.setRepositoryPath("/");
         // Parse the request
         List items = upload.parseRequest(request);
         // Process the uploaded fields
         Iterator iter = items.iterator();
         while (iter.hasNext())
         FileItem item = (FileItem) iter.next();
              if (item.isFormField())
                   String stringitem = item.getString();
         else
              String filename = "";
                   int temp = item.getName().lastIndexOf("\\");
                   filename = item.getName().substring(temp,item.getName().length());
                   File bestand = new File(path+filename);
                   if(item.getSize() > SizeMax && SizeMax != -1){foutmelding = "bestand is te groot.";return false;}
                   if(bestand.exists()){foutmelding ="bestand bestaat al";return false;}
                   FileOutputStream fOut = new FileOutputStream(bestand);     
                   BufferedOutputStream bOut = new BufferedOutputStream(fOut);
                   int bytesRead =0;
                   byte[] data = item.get();
                   bOut.write(data, 0 , data.length);     
                   bOut.close();
         catch(Exception e)
              System.out.println("er is een foutontstaan bij het opslaan de een bestand "+e);
              foutmelding = "Bestand opsturen is fout gegaan";
         return true;
         }

  • LabVIEW 8.0:: How to get the group name of a user logged to a NI Security Domain?

    Hello all,
    I am using LabVIEW 8.0 PDS.
    I created a new local domain called "MyDomain" in the "NI Domain Account Manager" . I added a new User called "MyUser" and a new group called "Maintenance". I set "MyUser" to be a member of the "Maintenance" group. Then, I configured LabVIEW to invoke the login dialog at start-up in order to log "MyUser" with the correct password.
    I would like to get the group name of the current user logged programmatically in a VI. I tried with the VI Server >> Application >> Security properties and methods and also with the properties and methods of the NI Security Class but it seems to be not so simple as I believed at start.
    I do not find any informations or KB on this (all the documents I found deal with LV DSC or TestStand).
     The final goal is to be able to manage a list of user for my application. Each user is a member of a group ("Administrator", "Operator", "Maintenance") and depending on the group, the user can or cannot access to some parts of the application.
    Thanks for your help.
    Matthieu
    Eurilogic

    Re,
    Here is a screenshot of this functions...
    If you really own LV DSC 8.2 the best thing to do is to reinstall it.
    Regards, 
    Message Edité par Richard K. le 04-02-2007 04:00 AM
    Richard Keromen
    National Instruments France
    #adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
    >> Découvrez, en vidéo, les innovations technologiques réalisées en éco-conception
    Attachments:
    security.jpg ‏3841 KB

  • To get the Application name

    Hai experts,
    I have a requirement as follows:
    I have a component named as ZComponent which has 3 view.
    i am creating 2 applications for the component named as zappl1 and zappl2.
    zappl1 starts from first view itsef where as zappl2 starts from second view.
    I have an ALV table in the second screen.
    it shud not be editable for ZAPPL1 and shud be editable for ZAPPl2.
    Inorder to that i need to get the application name at runtime in the WDDOINIT METHOD of the second view.
    Is there any method to get the application name.
    If so plz help me as soon as possible.
    IF any doubts revert back to me ASAP.
    Cheers,
    Madhu

    Hi Madhu,
    You do not need the application name for this. The following would work:
    1. Create one more inbound plug to your window (interface view), other than the existing plug (default). The second plug should also be an interface plug of type "startup".
    2. Create a node in your component controller with an attribute denoting the editable property.
    3. Map this node in the window's context.
    4. Your window will have 2 plug handlers, for each startup plug. Inside one handler, set the editable attribute to true and in the other, set the same to false.
    5. Map the same node in the view controller also, and in your view layout, bind the "read only" attribute of your table to the node attribute.
    6. Create a new application, zappl2 and in the default plug, specify the name of the second plug.
    Launch both applications, your control should be editable in one and read only in the other.
    Regards,
    Nithya

  • Using JCom for getting the user name

    I am using jcom610-win.exe and weblogic610sp2_win.exe .I need to use the Jcom for getting the user name of the NT Iser Logged in.I have got the process for this on the page at http://e-docs.bea.com/wls/docs61/jcomreference/Security.html .But this page uses a method isCallerAuthenticated() from a class file called jcom .I looked into the whole bea directory but there was no class like in the server dir.Can you tell where to get this class from.And if this has not been provided into the jar files that come along with the installable then why is it mentioned in the page @ http://e-docs.bea.com/wls/docs61/jcomreference/Security.html

    Hi.
    You might have better luck posting this in teh jcom newsgroup.
    Regards,
    Michael
    Manoj Gupta wrote:
    I am using jcom610-win.exe and weblogic610sp2_win.exe .I need to use the Jcom for getting the user name of the NT Iser Logged in.I have got the process for this on the page at http://e-docs.bea.com/wls/docs61/jcomreference/Security.html .But this page uses a method isCallerAuthenticated() from a class file called jcom .I looked into the whole bea directory but there was no class like in the server dir.Can you tell where to get this class from.And if this has not been provided into the jar files that come along with the installable then why is it mentioned in the page @ http://e-docs.bea.com/wls/docs61/jcomreference/Security.html
    Michael Young
    Developer Relations Engineer
    BEA Support

  • How to get the function name in controller class

    Hi experts ,
    I am new to the OAF framework.
    i have created the two functions and bot he the function have the same controller class .i want to capture the function name or function id in the controller class.
    can you please let me know how to get the function id or function name in the controller class.

    Hi apurba,
    Thanks for the quick reply.
    i am trying to get the function name from the FunctionSecurity class,
    However in FunctionSecurity class there is no such method defined as getFunctionName();
    my requirement is ,i have two functions functionA and functionB defined.
    both the function has the same controller class.in controller class ,i need to get the function name ,based on the function name
    i will redirect the page to respective page.
    looking forward for you response.
    appreciate your help
    Thanks,
    KT

  • IDM : How to get the Resource name in Exclude Rule during Reconciliation?

    Hi
    Problem Statement => How to get the Resource name in Exclude Rule during Reconciliation.
    Problem Description => Apparently, we use exclude rule for not consider some account during reconciliation.
    I need the resource name in exculde rule during reconciliation. I tried with getResources() method which is an inbuilt method.But it gives all the resources are aviablable in the repository (IDM). I need only the current reconcilied resource name instead of fetching all the resouce.
    Can any one please help how to get the resource name in exclude rule during reconciliation?
    Thanks in advance for you help.
    Thanks,
    Chellappan

    Hi,
    Thanks for your reply.
    I have 50 resouces and these resouces using the same kind of exclude rules. In the exclude rule, i am using resource name to do some work. If i get the resouce name in exclude rule, then i can use the same exculde rule for 50 resources. This will minimise the rule count from 50 to 1. For that, i need resouce name.
    Thanks,
    Chellappan Sampath.

  • Get the region name

    Hi all,
    i need to get the region name for a selected page, but i don't know how to do it.
    Does it exist a method called 'GetRegionName' or 'GetRegionId'?
    Thanks
    bye,
    Simona

    i have a page with 2 tabs and i need to get the unique name or the unique id of every tab. According to their values i have to show some information...

  • How can I get the query name/aggregationslevel in my planning function?

    Hi,
    is it possiable to get the query name/aggregationslevel in a planning fuction?
    thanks for your idea.
    hongwei

    Hi,
    The interface IF_RSPLFA_INFOPROV_DESC
    provides methods for retrieving the most important properties of an InfoProvider from the point of view of the implementation class of a planning function type.
    Methods GET_T_CHARNM and GET_T_KEYFNM return the names of the characteristics and key figures in the InfoProvider.
    You can get the properties of the InfoObjects and compound information by calling method GET_TAB_IOBJ_PRO and GET_TAB_IOBJ_CMP .
    Does this help?
    Best Regards
    Shyam

Maybe you are looking for

  • Is it possible to use more than one WRE54G? Is it a good idea?

    I live in a four-story building.  The cable modem is on the 4th floor - it can't be moved (just accept that).  I have a WRE54G connected and on the first floor - the signal is sporadic.  For example, it is ok with the laptop most of the time but fluc

  • To upload a excel file to dB table through webdynpro ABAP

    HI,     I am unable to upload a excel file directly by using  func module   "HR_KR_XSTRING_TO_STRING".     If file is in tab delimited then only, I am able to upload.     Suggest me if there are any other options to upload a excel file.

  • Windows 7 and Elements 2.0?

    Hello there! I'm running Windows 7 Home Premium and I'm dying to get my Elements 2.0 on this laptop, but it won't let me. Autoplay doesn't autoplay, which is fine, because when I go in and open it, it welcomes me, asks my language, then gives me an o

  • Email to postmaster goes to root - can this be changed?

    email to postmaster goes to root - can this be changed? TIA! BP

  • Adobe Acrobat 7 - unable to save as JPEG

    Hi. I have a customer that has Adobe Acrobat 7 and has a LOT of pdf's. They like to save the PDF's as JPEG so they can attach them to other documents. I just reinstalled their computer and now the feature doesn't work. You click file, save as, choose