String to Object, then get the Class

hi I'm new in Java!
what I want to do is to convert a String and convert it to a Object then get the classname of the Object.
for example:
ExampleClass classObject = new ExampleClass();
String exampleString = "classObject";
I want to convert the string "classObject" into an Object, then get the Class name of the Object. (Let's just say I don't know what the Class name is)

static Class forName(String className)Please correct me if I'm wrong...
but what I have is an Object name (in string format),
not a Class Name.
So I'm kinda looking for something like...
static Object forName(String objectName)
Class.forName() returns a Class object. From this you can create an instance.
     String s = "java.awt.Frame";
     java.awt.Frame frame = (java.awt.Frame) (Class.forName(s)).newInstance();

Similar Messages

  • How to get the class name of a page in oracle apex

    Hi All,
    Can anyone please let me know how we can get the class name of a page or region in oracle apex? I would also like to know how we get the DOM object ID for particular item.
    I appreciate any help on this.
    Regards
    Raj

    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 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.

  • I need get the class container name (Urgent)

    My class contain another inside, declared as variable.
    In the class declared as variable, can I get the class name of class that contains it?
    Is it possible?
    Thanks
    Renato de Melo

    I can't think of a good way of doing this, but here is a really kludgy one!
    within FieldClass, use getClass().getName(). This will return the full name of the class, and since this is an inner class, it will be "packagename.Container$FieldClass". All you then need to do is to find the substring between the last full-stop (period if you're American), and the $:
    String className = getClass().getName();
    int start = className.lastIndexOf('.') + 1;
    String containerName = className.substring( start, className.indexOf('$', start);HTH (and HTW - this is off the top of my head!)
    Robin

  • Get the class file name of the JSP page

    Hi
    I'm wondering how I can get the class name associated with the current JSP page...
    I found on this forum how get the name of current JSP page, but it doesn't help me...
    Thanks

    Hi,
    Sometimes I can be really dumb; of course, the solution is to call the getClass() method on the this object, and eventually store the Class object returned in the SessionBean file if it's necessary (in a SessionBean field/property, or in a parameter of a SessionBean's method).
    Sorry for this thread without any interest. :(

  • How to i get the class name ? please help me

    hi friends
    i want to know how to get the class name from my java program
    public class sample
    public static void main(String args[])
    how to i get sample.
    please help me.
    thanks in advance                                                                                                                                                                                                                                                                                                                                                                                                                                           

    I can't recall which forum member gave the following solution, but it works
    in static contexts and it's copy-and-paste friendly -- you don't hard-code the
    name of the class, only a dummy class that you use to make this hack work:
    public class Foo {
        private static class Dummy{}
        public static void main(String[] args) {
            Class cls = Dummy.class.getEnclosingClass();
            String name = cls.getName();
            System.out.println(name);
    }

  • How to get the class name and field name dynamically

    Hi
    I have a class (ex: Contract) the fields (ex : a,b,c) .i need to get the class name and field name dynamically
    ex
    if( validation file for the field Contract.a){
    return contract.a;
    }else if(validation file for the field Contract.b){
    return contract.b;
    how to pass the field name and object dynamically
    Please help me .............
    Thanks in Advance..
    Edited by: 849614 on Aug 11, 2011 6:49 AM

    YoungWinston wrote:
    maheshguruswamy wrote:
    Agreed, but IMO, i still feel its best if there is no tie in between consumer class level details and the database it talks to. A service layer is needed in between them.Sounds like you've done a bit of this before. Me, I've either been a modeller/DBA, doling out data, or a nuts and bolts programmer (and actually more toolmaker than apps, but did a bit of that too).
    Do you know of a good book about the "middle ground" (ie, these service layers)? I understand it empirically, but haven't had a lot of exposure to it.
    Winston
    Edited by: YoungWinston on Aug 11, 2011 10:34 PM
    PS: Apologies. Edited my previous post, presumably while you were composing your reply, when I finally realized what '.filed' meant.Most of my work is in web development, never been a DBA :) . The biggest 'concern' in my shop is 'separation of concerns'. The UI group reports up to a different IT head, the DB group reports up to a different IT head and so on. The looser the coupling between these systems, the lesser the project costs (Integration, QA etc) are. Martin Fowler's books contain good information about separation of concerns in an enterprise environment. The two books which i recommend are
    [url http://www.amazon.com/Patterns-Enterprise-Application-Architecture-Martin/dp/0321127420]Enterprise Application Architecture and
    [url http://www.amazon.com/Enterprise-Integration-Patterns-Designing-Deploying/dp/0321200683/ref=pd_sim_b_1]Enterprise Integration Patterns

  • Get the Class of something i have in mind

    i found 2 ways of getting the class of a type
    1. return Class.forName("Boolean");
    2. static Boolean aBoolean = new Boolean(true);
    return aBoolean.getClass();
    the first one throws an exception and in the second one i have to create a random object. is there a nicer way to do this?

    You have to use the fully qualified class names with Class.forName... for Boolean it is java.lang.Boolean.
    Two ways that don't create unnecessary objects:
    1. return Class.forName("java.lang.Boolean");
    2. return Boolean.class;
    and if you wanted the class of the primitive type boolean you can use Boolean.TYPE or boolean.class...

  • Getting the class of a primitive type or void

    Hello,
    Class.forName cannot be used to get the class of a primitive type or void. What does then ???
    I thought of defining a class for each primitive type and override getClass() to return the required type, but getClass() is final ...
    Please help

    I don't understand what you mean e.g.I get the name of the primitive type at runtime and need to convert it to a class. For example, Class.forName("byte") returns byte.class. But, unfortunately, Class.forName() doesn't return classes of primitives or void.
    I already solved the problem through putting ptimitive classes in a hashtable. But I was wondering if there is a simpler solution !!!

  • When I turn on my iMac it comes up with the icon which I then log into. The password works and I then get the apple icon and the spinning wheel. After a minute it turns into a prohibited icon. If I log on the guest icon I get to Safari. Help!

    When I turn on my iMac it comes up with the login icons which I then choose and log into. The password works and I then get the apple icon and the spinning wheel. After about a minute the Apple icon turns into a prohibited icon. However, if I log in under the guest icon, I can access the wifi and get to Safari. I really don't know what to do next. Any help would be gratefully appreciated.

    Are you running any A-V? If it's an iMac 21.5, I don't think you're running Leopard, 10.5. Probably at least Snow Leopard, 10.6. This is the Leopard forum.
    This article says meant for 10.3.9 and eariler, but contains some still useful suggestions.
    http://support.apple.com/kb/TS1411
    Try a Safe Boot. Shift at the startup chime and expect a much longer time to boot. This will bring you to a login screen with "Safe Boot" in red.
    Look at this as well.
    http://support.apple.com/kb/TS1417

  • I'm new to Mac and the program/all called Numbers. I'm trying to use both Average and small in the same formula. What's I'm trying to do is take 20 cells, find the 10 lowest numbers, then get the average and after that multiply it by .96

    I'm new to Mac and the program/all called Numbers. I'm trying to use both Average and small in the same formula. What's I'm trying to do is take 20 cells in a column,  find the 10 lowest numbers, then get the average and after that multiply it by .96  I used to use Excel and the formula worked fine in that. Here is my Formula
    =(average(small(H201:H220,{1,2,3,4,5,6,7,8,9,10})))*.96
    This formula worked in Excel and when I converted my spreadsheet over to Numbers, this formula no longer works.
    The best that I have been able to do so far is use small in 10 different cells, then get the average of the 10 cells and finally multiply that average by .96  So instead of using 1 cell, I'm using 12 cells to get my answer.
    This is a formula that I will be using all the time. The next cell would be =(average(small(H202:H221,{1,2,3,4,5,6,7,8,9,10})))*.96
    Hoping I explain myself well enough and that someone can help me.
    Thanks

    You can still do it in one cell but it will be more unruly than the Excel array formula.
    =average(small(H201:H220,1),small(H201:H220,2),small(H201:H220,3),...,small(H201:H220,10))*0.96
    where you would, of course, replace the "..." with the remaining six SMALL functions.

  • Divide a string in order to get the distinct list level.

    Hi,
    I want to divide a string in order to get the distinct list level to relate this with a category table.
    The size of my list is dynamic and because of this I’m unable to find a way to do this!
    Here goes an example of what I need to do:
    Consider the following list:
    Category                Category_ID
    Age                     1
    Less than 3 months      1.1
    Less than 9 months      1.2
    Less than 1 year        1.3
    Risk                    2
    Danger                  2.1
    High                    2.1.1
    medium                  2.1.2
    low                     2.1.3
    If I have a row that has category_id "2.1.3" I want to present values as:
    "Risk.Danger.Low"
    If I have a row that has category_id "1.1" I want to present values as:
    "Age.Less than 3 months"Any hint on what I should search in order to accomplish this?
    This will be used to produce a report. This report will contain a few thousand rows and the categories will be around 100.
    Thanks,
    Ricardo

    Hello
    I think this is a job for sys_connect_by_path....
    with p as
    (   select 'Age'             descr  ,'1' cat from dual union all
       select 'Less than 3 months'      ,'1.1' cat from dual UNION ALL
       select 'Less than 9 months'      ,'1.2' cat from dual union all
       select 'Less than 1 year'        ,'1.3' cat from dual union all
       select 'Risk'                    ,'2' cat from dual union all
       select 'Danger'                  ,'2.1' cat from dual union all
       select 'High'                    ,'2.1.1' cat from dual union all
       select 'medium'                  ,'2.1.2' cat from dual union all
       select 'low'                     ,'2.1.3' cat from dual
    SELECT
        cat,
        LTRIM(SYS_CONNECT_BY_PATH(descr,'.'),'.') route
    FROM
            SELECT
                descr,
                cat,
                SUBSTR(cat,1,INSTR(cat,'.',-1)-1) parent
            FROM
                p
    START WITH
        parent IS NULL
    CONNECT BY
        PRIOR cat = parent
    SQL> with p as
      2  (   select 'Age'             descr  ,'1' cat from dual union all
      3     select 'Less than 3 months'      ,'1.1' cat from dual UNION ALL
      4     select 'Less than 9 months'      ,'1.2' cat from dual union all
      5     select 'Less than 1 year'        ,'1.3' cat from dual union all
      6     select 'Risk'                    ,'2' cat from dual union all
      7     select 'Danger'                  ,'2.1' cat from dual union all
      8     select 'High'                    ,'2.1.1' cat from dual union all
      9     select 'medium'                  ,'2.1.2' cat from dual union all
    10     select 'low'                     ,'2.1.3' cat from dual
    11  )
    12  SELECT
    13      cat,
    14      LTRIM(SYS_CONNECT_BY_PATH(descr,'.'),'.') route
    15  FROM
    16      (
    17          SELECT
    18              descr,
    19              cat,
    20              SUBSTR(cat,1,INSTR(cat,'.',-1)-1) parent
    21          FROM
    22              p
    23      )
    24  START WITH
    25      parent IS NULL
    26  CONNECT BY
    27      PRIOR cat = parent
    28  /
    CAT   ROUTE
    1     Age
    1.1   Age.Less than 3 months
    1.2   Age.Less than 9 months
    1.3   Age.Less than 1 year
    2     Risk
    2.1   Risk.Danger
    2.1.1 Risk.Danger.High
    2.1.2 Risk.Danger.medium
    2.1.3 Risk.Danger.lowHTH
    David
    Edited by: Bravid on Sep 2, 2011 2:50 PM

  • How to get the .class file for the extended Controller .java file

    Hi,
    I did the below steps.
    1. Created New OAWorkspace
    2. Created New project
    3. Imported the page .xml file
    4. Added new .java file by extending the controller class
    5. Added code in the .java file.
    6. Ran the .xml file
    As I copied all the folders from Unix box, the page was opened.
    But My question was where can I see the .class file the extended controller. It's a .java file. How to compile and get the .class file for this .java file. If I get this .class file, I can go to the page and click the personlize page. and change the Controller name to the new path by ftp ing the new class to the cust.oracle.apps.pos.changeorder.webiui.
    Please let me know how to create the .class file.
    Thanks,
    HP

    All are Java files are stored in JDEV_INSTALL_DIR:\jdevhome\jdev\myprojects\
    In your case the path java would be
    JDEV_INSTALL_DIR:\jdevhome\jdev\ myprojects \cust\oracle\apps\pos\changeorder\webui\
    AND
    Once you compile the java file in Jdeveloper, Class files get generated @ below path
    In your case the path of class would be
    JDEV_INSTALL_DIR:\jdevhome\jdev\ myclasses \cust\oracle\apps\pos\changeorder\webui\
    Duplicate Thread-
    Thanks
    --Anil
    http://oracleanil.blogspot.com/

  • How to get the class file of jar file

    hello all,
    is there any way to get the class file of jar file,as we have when we compile a java file we get class file
    same do we have any option to get the class file of jar file

    A jar file is a zip archive, so you can uznip it or extract the contents with the command "jar" - if it is what you need.

  • Am trying 2 download programs then getting the answer error 1009

    am trying 2 download programs then getting the answer error 1009

    Probably because your trying to download an app from a different country than what your billing info says.

Maybe you are looking for

  • Verity unstable and permissions errors

    Our scheduled task to purge/reindex stopped working. Verity deleted the collections that it was supposed to index. The ws folder filled up. I followed the instructions in the TechNote below to clear the ws. After recreating collections that Verity de

  • Movement type specific to Order Type

    HI I have created new movement type Z01 instead of 101 and I want to use this Z01 for specific order type and for Others system should take into account standard 101 movement. I have checked movement type setting in PP but it client level setting and

  • Load Balance & Fault Tolerance

    I need do design a solution for load balance the DLSw traffic between 4 central routers and, if this 4 routers fail (oe wan fail) all peers and circuits need to be restablished on other site with other 4 routers. To balance the traffic I will use the

  • Condition type not appearing

    Hi Expert, We are using sales org. 6000 for which pricing prcedure is Z60000. Now i have assigned same pricing procedure for sales org. 1500. I have done pricing procedure assignment in table T683V. But when i am creating sales order for sales org. 1

  • After upgrade the MDM 71 Sp3 to SP4 the MDS dos not startet

    Hello, I have an problme after a update from MDM 7.1 SP3 to SP4. The update was finished successful but my MDM Server (MDS) stopped after the starting wiht follow message Starting: /usr/sap/TBD/MDS10/exe/mds-r - Wed Mar  3 10:16:31 CET 2010 SunOS Q4D