How to determine program name in static main

What code can I execute in static main to get the name of the class provided as an argument to the java interpreter on the command line (since args doesn't include it)?
Or is this simply not possible in Java?
Why do I need this? I'm subclassing the class that defines static main, using the subclass as the program class, and want to instantiate it reflectively in main. Currently, I'm passing in the subclass name as an argument, so it appears on the command line twice, which seems awfully silly.

JoachimSauer wrote:
shdanfo wrote:
The question is very simple: In Java, is it possible to execute code in static main that returns the name of the program class provided to the java interpreter?Let me get that straight.
You have something similar to this:
public class Foo {
public static void main(String[] args) {
String programName = ...;
System.out.println(programName);
}And you want to know what your have to replace "..." with so that the program outputs "Foo". Is that correct?
I'd suggest either Foo.class.getName() or even simpler "Foo".I don't know if I'm getting this wrong now or not. It also sounds like the OP wants to know the name so that he can use reflection to create an instance. But all of that code could in that case be replaced with:
public class Foo {
    public static void main(String[] args) {
        Foo foo = new Foo();
}    Since he knows that this implementation of main is located in the class Foo.
Kaj

Similar Messages

  • How to find Program Name by Recording name

    Hi,
    How o find program name ? for example i have recording(SHDB) name is:ZVA01REC.
    i want to find the respective porgram for that recoring?
    Thanks and Regards,
    Anu.

    Hi Anitha,
    "No it's showing standard program name like:SAPMM06E
    but actual program name is:ZBDCME22."
    SAPMM06E is the program the recording runs
    ZBDCME22 must be an additional program that someone must have created for running the recording.
    There is no way for u to find a program for a given recording (this is only a one way trafic; recording -> program create; not visa versa)
    your best bet would be that search in se38 for programs starting with ZBDC* and then check the short text. may be the person who made it was kind enough to update the short text with teh recording name.
    Hope this was of some help.
    Regards,
    Sagar.
    Edited by: Sagar Mehta on Nov 12, 2008 10:00 AM

  • How to determine domain name in db_link?

    Hi all,
    when executing:
    create database link TST connect to myuser identified by pippo using 'MYTNS';I obtain the db link name with a suffixed domain, for example:
    TST.DOMAIN.COM
    Where does that domain come out from?
    How to determine it before db link creation?
    thanks a lot
    aldo

    solution found in thread
    REGRESS.RDBMS.DEV.US.ORACLE.COM  concates to every databaselink name.

  • How to find programs' names those were created by me in a specific period?

    for example
    the input parameters are:
    programmer: sy-uname
    begda: 2007.01.01
    endda: 2007.02.01
    the outcome will list all the programs' names including webdynpro component which was created by me.
    is there a table have those entries in the system?
    thanks a lot.

    Hi,
    Use the Below logic, Enter the required fields it will diplay all the programs and web dynpro components that are created.
    TABLES: trdir,
       wdy_component.
    SELECT-OPTIONS:p_name FOR trdir-name,
             p_wname FOR wdy_component-component_name,
             p_cdat FOR trdir-cdat.
    PARAMETERS:
                p_author TYPE trdir-unam OBLIGATORY,
                p_udat TYPE trdir-udat,
                p_subc TYPE trdir-subc OBLIGATORY.
    DATA: t_trdir LIKE STANDARD TABLE OF trdir.
    DATA: t_wcomponent LIKE STANDARD TABLE OF wdy_component.
    *SELECT * FROM trdir UP TO 5 ROWS INTO TABLE t_trdir*
      WHERE cnam = p_author AND
            subc = p_subc AND
            name IN p_name AND
           cdat BETWEEN p_cdat-low AND p_cdat-high .
    *SELECT * FROM wdy_component UP TO 5 ROWS INTO TABLE t_wcomponent*
      WHERE author = p_author
      AND component_name IN p_wname
      AND createdon BETWEEN p_cdat-low AND p_cdat-high.
    LOOP AT t_trdir INTO trdir .
      WRITE:/   trdir-name,
             30 trdir-cdat,
             45 trdir-unam,
             55 trdir-udat,
             67 trdir-subc.
    ENDLOOP.
    ULINE.
    LOOP AT t_wcomponent INTO wdy_component.
      WRITE: / wdy_component-component_name,
            30 wdy_component-createdon,
            45 wdy_component-author,
            55 wdy_component-changedby.
    ENDLOOP.

  • How to find the name of the main program in the SM35

    Hi all,
    I have problems to find which program a batch input belongs to: may I explain myself...I can see in transaction SM35 several session names but no trace of the name of the program which is being used...I tried to find it with table APQI but no results so far. Does anyone know how can I get this information?
    Thanks a lot!

    Check table TBTCP
    Regards,
    Rich Heilman

  • How to determine the name or type of a control in a existed VI?

    I got a couple of VIs other engineers created before. There are a couple of controls I can not tell the type or name of that control.
    I used LabVIEW ctrl-H to try to figure out what control was used but failed. I also tried to use "Edit\Customize Control" to determine that control, still could not find it.
    Please advise how can I figure out what kind of controls were used in some existed VI. Thanks,
    RY

    The name of the control is its label. It may have an empty label, meaning no name. It's also possible its label is invisible. Right click it and go to Visible Items to find out.
    As for the type, the color and shape of the icon is usually the best way to tell.
    Right click the diagram terminal of the control and select View as Icon. This might help you. If it doesn't, I suggest you post the 2 controls in an empty VI, and I'm sure someone can figure it out.
    Try to take over the world!

  • "Who ran me" - how to determine the name of the dbms_scheduler job that ran me

    Hi Community
    I can see plenty of examples out on the interweb which shows how you can use dbms_utility.format_call_stack to find the hierarchy of procs, functions and packages that got me to a particular point in my code.
    For example, if proc (procedure) A calls proc B, which in turn calls proc C, in the code for proc C, I can query the call stack to find out that proc C was called by proc B which in turn was called by proc A
    However, I want to extend this further.
    For example, using the example above, if proc A in turn was started by a dbms_scheduler job, I want to determine (within proc C) the name of the dbms_scheduler job which started the whole process off.
    The reason I want to do this is that I have inherited a (massive) system which is undocumented. In many places within the code, email alerts are sent out using a custom "MAIL" package to designated users (now including me) when certain long-running processes reach certain milestones and/or complete.
    I have added to the custom "MAIL" package a trailer on the mails to show the call stack. I also want to show the name of the dbms_scheduler job which started it all.
    Over time, this info may help me in building the "map" of how the whole undocumented system hangs together and in the meantime, to assist in troubleshooting problems
    Looking forward to hearing from you
    Alan

    Use USER_SCHEDULER_RUNNING_JOBS or DBA_SCHEDULER_RUNNING_JOBS there is column SESSION_ID and when you know your session ID build query is very simple.
    select owner, job_name
    into ...
    from dba_scheduler_runnig_jobs
    where session_id=sys_context('USERENV','SESSIONID');
    You must declare local variables in PL/SQL procedure to read owner and job_name into them. Second thing, you must handle possible exception no_data_found than can be raised when procedure is not run from job.

  • How to determine database name I am connected to ?

    I would like as simply and fast as possible to determine the database name, which I am currently connected to. Maybe the property jbo.sql92.JdbcDriverClass would do, but how to get its value ? Thanks for any suggestions.

    Ricky,
    don't understand that, why you don't use the session, when you are in BC4J (AM.getSession()) - which will give you at least the URL you connect too (in case you use a datasource - bad luck, as it is defined within the container ..)
    thx clemens

  • How to determine allowed names?

    Using Labview and an IVI-COM driver to talk to an oscilloscope. How can I determine the allowed names that I can use?

    You should have received this information from the vendor that sold you the IVI-COM driver.
    You might also consider using a native LabVIEW driver for your scope. If NI has one, I think it will be easier to use. Look at ni.com/idnet to see the available drivers.
    Brian

  • How to determine InfoCube name within the update rule start routine?

    We are attempting to delete all the records where all key figure values are zeroes. We have about 15% of such records and we really don't need them.
    We have yearly InfoCubes. We copy the InfoCube and update rules at the end of every year. So, we don't want to hard code any field names within the update rules.
    If I could determine the target InfoCube name within the update rule start routine, I can find out all the key figures dynamically. But, I don't see a way of finding out the InfoCube name.
    If you would share any ideas, I would really appreciate.
    Thanks.
    Sudhi Karkada.

    Hi Sudhi,
    I dont know if this is what you are looking for.
    if you want to delete a record from being inserted when all the Key figure values are ZERO then you can use a Update Routine for some characteristic in the below way
    If looking for the InfoCube:
    if COMM_STRUCTURE-KF1 = 0 and COMM_STRUCTURE-KF2 AND....
      RETURNCODE = 4.
    else
      RESULT = COMM_STRUCTURE-ChanracteristicObject.
    endif.
    If it is to an ODS / InfoCube in the start routine.
      DELETE DATAPACKAGE where KF1=0 and kf2=0 and .....
    Hope it helps.
    Regards,
    Praveen.
    ENDLOOP.
    Message was edited by: Praveen

  • How to determine ip address as static or dynamic

    hi, im trying to figure out ways of testing incoming ip connections to my mail server as dynamic or static, would a simple get canonical name tell me this?
    any adivce would be greatly appreciated
    thanks

    Whether an IP is static or dynamic, it is just a decision of the IP administrator / owner. There is no technological measure in finding out such a human decision.

  • How to determine method name at runtime

    hello,
    i try to get method name at runtime..i have a logger and i need this info for logger
    private void method(){
    myLogger.debug( "exception in " + getExecutedMethod() ); /* output should be: exception in method */
    }best regards
    cem

    bcem wrote:
    what i needed was
    [http://today.java.net/pub/a/today/2008/04/24/add-logging-at-class-load-time-with-instrumentation.html|http://today.java.net/pub/a/today/2008/04/24/add-logging-at-class-load-time-with-instrumentation.html]
    regards
    cemYou could also use AOP to add logging. But really, any sort of injected logging is going to be of limited value, since it's very generic and "this method was called with these parameters"-esque. Explicit logging is a lot more descriptive and useful, particularly to support staff who probably won't know what any particular method does

  • How to "hover" over a smiley / emoticon to determine its name

    I have recently been transitioned from my Torch to the Z30.  I'll spare my comments on the various frustrations.  However, one minor item I haven't found an answer to is how to determine the name of a smiley / emoticon in BBM before inserting it.  Previously, with the torch, I could scroll through the emoticons before selecting one.  While scrolling, the name of the current emoticon would display without it having to be selected.
    I can't figure out how to determine the name of an emoticon on my Z30, whether or not I have selected it.  I can hit the backspace once I've selected/inserted it, which will give me the text representation, but that doesn't tell me, for example, what "=]Y" means.  How do I determine the name of a smiley before inserting it so that I don't inadvertently pick the wrong one?

    If I understood the question, you are talking about migrating Active Directory. After checking your event viewer and keep your old "primary" DC running without problems, all you need is to:
    1. Promote the new server as additional server
    http://social.technet.microsoft.com/wiki/contents/articles/20098.setting-up-additional-active-directory-domain-controller-with-windows-server-2012.aspx
    2. Transfer FSMO rules to the new one
    http://blogs.technet.com/b/canitpro/archive/2014/04/02/step-by-step-active-directory-migration-from-windows-server-2003-to-windows-server-2012.aspx
    3. Install DHCP on the additional server and configure the scope
    http://blogs.technet.com/b/teamdhcp/archive/2012/08/31/installing-and-configuring-dhcp-role-on-windows-server-2012.aspx
    4. Demote the old server
    http://technet.microsoft.com/en-us/library/jj574104.aspx
    and voila...
    I recommend to keep your network infrastructure connected to a UPS instead of the nature to avoid failure by lightning.
    Regards,
    If you found this post helpful, please give it a "Helpful" vote. If it answered your question, remember to mark it as an "Answer". This posting is provided "AS IS" with no warranties and confers no rights! Always test ANY
    suggestion in a test environment before implementing!

  • Re:Finding Program name

    Hi,,,
    Can anybody tell me How to find program name with its respective Tcode.. I searched inside its package..that showing Screen numbers only.. So any other ways welcome
    Regards
    Karthik.T

    Hi
    Go to SE93.
    Enter the TCODE and press display.
    Here you can see the program name.
    OR
    Go to the TCODE (for which u want prog name)
    Follow Menu path: System --> Status..
    Check the Program field in SAP data.
    Hope it helps
    Regards
    Gaurav

  • How to determine main program name?

    Hello Forums,
    I am working on a customer exit that is called by a function module and I would like to have a condition in my include that states
    if program_name =   SAPLV56K .
    do logic in here.
    Endif.
    is it possible to determine the program name?
    thanks

    Hi,
    Do following step,
    1 declare global Variable of type sy-repid. eg data g_repid like sy-repid.
    2 assign program name to variable at Initialization stmt.
         INITIALIZATION
         g_repid = sy-repid.
    3 Use this variable.
    other wise use sy-cprog.
    Difference between sy-repid and sy-cprog
    Sy-repid --- It contains the name of current program.
    Sy-cprog---Contains the name of calling program.
    Thanks & Regards,
    ShreeMohan

Maybe you are looking for

  • WebTools Creating multiple users for the same User

    I had to make a few changes to a BP in SAP which will synch back into WebTools but now I am getting multiple users for the same contact. For example my user is cspehar_1 now in Webtools there are cspehar_1, cspehar_2, cspehar_3 and so on up to _8. Th

  • How to print (save) pages as PDF in Safari?

    I´m running Lion, we´re getting better acquainted. However, with Safari I´m having problems when I try to save a web page as a PDF using the Print-Save PDF options. It tells me the file cannot be saved. I try duplicating, exporting, etc, and the only

  • Initial inventory upload using LSMW,BDC

    Dear Friends, I am trying to upload data for Initial inventory capturing of valuation type for t.code MB1C using LSMW,BDC BECAUSE of valuation type it is not capturing please guide me.I am using SAP Ecc 5 version. Thanks in advance. Rafeeq ahmed

  • Execute command line from Java

    I have an easy one for you! I would like to know how I can execute a command line from my java code. The only thing I want to do is to launch a html page with the default browser in my computer when I press one button of my java application but I don

  • AirPlay Mirroring not available on my new macbook pro

    My Macbook Pro is two days old and does not support mirroring to my ATV2??? My iPAD1, my iPhone 4's all do...whats up? Am I missing something? Mountain Lion, Intel 2.9 Ghz, 8 Gb RAM? Please help.