How to typecast an object, if the target class name is stored in a str var

Hi,
I have a method, in which i will receive an object as an attribute. I need to typecast it to another class, and that class name is stored in a string variable.
public void printContent(Object obj)
/* Here i have a variable strClassName - in which a class name is stored.
I need to create a variable for that class and type cast the object obj into that class. */
Please kindly help me to find out a way to do this.
Thanks in advance

Typecasting does one thing: it enables you to store an object in a reference variable of the target type (if it is of a type which is allowed to be in that variable). It doesn't alter the object in any way.
Therefore it simply isn't meaningful to talk about typecasting to a type name known only at run time. The whole point of typecasting is to tell the compiler to treat a reference as being of a specified type.
I don't know what you're trying to do but I think you should probably be looking at the reflection api, getting field an method information from the object's Class object.

Similar Messages

  • How to create an object within the same class???

    hi im just a newbie
    i v been always creating an object from the main class..
    but how to create an object inside the same class??
    i got main and students class
    the main got an array
    Students[] stu = new Students[]
    and i got
    stu[i] = new Students(id,name);
    i++;
    but i wanna do these things inside the Students class..
    i tried ..but i got errors.....
    how to do this
    .

    javaexpert, :)
    I really have no idea what you are trying to do since you say you've always been creating an object from the main class, yet you always want to create an object inside the same class.
    I'll assume that you have an object in the main class that you are trying to access from the Students class.
    If you are trying to access objects that are contained within the main class FROM the Students class, then know that there are two ways of doing so, one being static, and the other dynamic (look up definitions if unclear):
    1.) make the objects in the main class both static and public and access the the objects using a convention similiar to: Main.object; It's important to note that Main is the name of your main class, and object is a static object. There are better ways of doing this by using gettter/setter methods, but I'll omit that tutorial.
    2.) Create a new instance of the main class and access the objects using a similiar fashion: Main myInstance = new Main(); myInstance.myObject;
    You should really use getter and setter methods but I'll omit the code. In terms of which approach is better, step one is by far.
    I don't mean to be condecending, but you should really brush up on your programming skills before posting to this forum. This is a fundamenetal concept that you will encounter time and time again.

  • How to remove unused objects from the webcatalog In OBIEE11g

    Hi,
    I want to delete unused objects from obiee11g catalog, i know in obiee10g it's working fine (i.e: we can do it via manage catalog then delete the unused objects) is there any way to do it automatically like RPD utility --->removing unused objects from Physical layer in RPD
    fyi: I don't want to delete manualy. i need somethink like button/link to find unused objects(report,filter,folder..etc) from my obiee11g catalog.
    Thanks
    Deva
    Edited by: Devarasu on Nov 29, 2011 12:06 PM
    Edited by: Devarasu on Nov 29, 2011 3:15 PM

    Hi,
    Checked with Oracle Support team and confirmed below points
    --> incorporated into the Current product and consider as BUG it may resolve future release
    --> Currently there isnt any automatic method to remove the unused objects like reports, filters,folder etc from catalog.
    Treated as Bug
    Bug 13440888 - AUTOMATICALLY REMOVE OF UNUSED CATALOG OBJECTS FROM WEBCATALOG
    FYI:
    SR 3-4984291131: How to remove unused objects from the webcatalog in obiee11g
    Thanks
    Deva

  • Replication issues: Operations Master shows ERROR and attempting to connect to server shares gets "the target account name is incorrect"

    I think this should be easily resolved, but I need some guidance.
    I have a client with 2 Server 2003 R2 x64 DCs: BORIS & NATASHA. Last year I upgraded both of them from x86 to x64 one at a time, allowing replication to occur between the upgrades. BORIS is the FSMO roles holder as it is currently the production server,
    while NATASHA is a backup DC. One thing that puzzles me though is that if I look at the NS record in DNS on the SOA tab, it says NATASHA is the Primary server.
    While doing some routine maintenance I noticed an error in the File Replication Service events about a 'Tombstone' situation (Event ID 2042). I looked at article cc757610 in the Technet Library and opted for remedy #3 as I did not want to demote NATASHA
    and I got confused looking at the help about using "repadmin /removelingeringobjects". I have no idea how to determine which DC has the good copy of the directory.
    Now, in running "repadmin /showrepl" I get
    "DC=CPA,DC=local
        Default-First-Site-Name\BORIS via RPC
            DC object GUID: 0267a090-1890-40e2-9a15-ea928cabd425
            Last attempt @ 2012-12-27 08:28:55 failed, result -2146893022 (0x80090322):
                The target principal name is incorrect.
            1179 consecutive failure(s).        Last success @ 2012-12-21 23:30:15." <-- THIS IS WEIRD SINCE THIS IS THE DATE THAT I DISCOVERED THE TOMBSTONE EVENT AND MADE THE REGISTRY CHANGE
    (I THINK).
    When I try to look at the FSMO roles on NATASHA, it shows ERROR for RID, PDC & Infrastructure and says "The current Operations Master is offline. The role cannot be transferred." The other issue I'm having is that client PCs are intermittently having
    trouble reconnecting to necessary server shares.
    TIA
    Wayne S. CompTIA A+ CompTIA Network+ Microsoft MCP

    Hello Sandesh,
    I spent a lot of time trying to understand using NETDOM to reset machine account passwords (don't understand it yet), but I see that you're saying that won't work anyway.
    I'm not really sure how to tell which DC is the broken one, but I'm assuming it's BORIS since that's the one users are unable to connect to. Since it is the FSMO role holder and GC I want to make sure I understand the steps correctly:
    1.Use dcpromo to forcefully demote BORIS
    2.Do metadata cleanup on NATASHA (using ntdsutil?)
    3.Promote BORIS again to DC
    Should I leave NATASHA as the FSMO role holder and GC? BORIS is the better (more resources/faster processor) machine and it's the file server. Or should the better machine be the FSMO role holder and GC as well as the file server. NATASHA is meant to be
    a backup in case BORIS dies.
    Thanks,
    Wayne S. CompTIA A+ CompTIA Network+ Microsoft MCP www.InfoTek831.com
    Hi,
    The step you are performing is correct but you also need to seize the FSMO role on other DC if BORIS is FSMO role holder and configure authorative time server role.You can later move the famo role to  BORIS server the choice is your however if you are
    moveing the role then you need configure authorative time server on BORIS server.
    Configuring the time service on the PDC Emulator FSMO role holder
    http://msmvps.com/blogs/acefekay/archive/2009/09/18/configuring-the-windows-time-service-for-windows-server.aspx
    Domain Replication has exceeded the tombstone lifetime
    http://pmeijden.wordpress.com/2011/01/12/domain-replication-has-exceeded-the-tombstone-lifetime/
    Forcefull removal of DC:
    http://support.microsoft.com/kb/332199
    How to transfer or seize FSMO roles
    http://sandeshdubey.wordpress.com/2011/10/07/how-to-transfer-or-seize-fsmo-roles/
    Metadata Cleanup of a Domain controller
    http://sandeshdubey.wordpress.com/2011/10/12/metadata-cleanup-of-a-domain-controller/
    Once both server is online check the health of DC by running dcdiag /q and repadmin /replsum.Ensure that DNS/GC role is configured on both DC's
    Hope this helps
    Best Regards,
    Sandesh Dubey.
    MCSE|MCSA:Messaging|MCTS|MCITP:Enterprise Adminitrator |
    My Blog
    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

  • How to create an object of our own class by using Class.forName()??

    how to create an object of our own class by using Class.forName()??
    plzz anser my qustion soon..

    Class.forName does not create an object. It returns a reference to the Class object that describes the metadata for the class in question--what methods and fields it has, etc.
    To create an object--regardless of whether it's your class or some other class--you could call newInstance on the Class object returned from Class.forName, BUT only if that class has a no-arg constructor that you want to call.
    Class<MyClass> clazz = Class.forName("com.mycompany.MyClass");
    MyClass mine = clazz.newInstance();If you want to use a constructor that takes parameters, you'll have to use java.lang.reflect.Constructor.
    Google for java reflection tutorial for more details.
    BUT reflection is often abused, and often employe when not needed. Why is it that you think you need this?

  • The Target Principle Name is Incorrect

    The Advanced Page cannot be opened because of following error: The Target Principle Name is incorrect.
    I have a 3 sites Site A (HeadOffice contains Two DCs), Site B (contains One DC), Site B (contains One DC).
    While trying to joining a Domain from machine at Site B and C when I try to join a domain from NetBIOS name it fails and when try it with Domain FQDN it passes.
    Site B and C has some support engineers who were previously able to join the domain but now they are unable to jaoin domain as well.
    When I try to add user to local admin group of their machines and I logon to my domain admin ID I am getting below error.
    If anyone could help me how I start troubleshooting or is there any way if I create new fresh DC(ADC) on those sites,
    Please Note All the fsmo are on one DC at Site A and domain consist of single forest single domain model. 
    SYED WASIL UDDIN Infrastructure Consultant/System Engineer Premier Systems (Pvt.) Ltd.

    Fixing Replication DNS Lookup Problems (Event IDs 1925, 2087, 2088)
    Fixing Replication Security Problems
    Fixing Replication Connectivity Problems (Event ID 1925)
    Regards,
    Biswajit
    MCTS, MCP 2003,MCSA 2003, MCSA:M 2003, CCNA, Enterprise Admin, ITIL F 2011
    Blog:
      Script Gallary:
      LinkedIn:
    Note: Disclaimer: This posting is provided & with no warranties or guarantees and confers no rights..

  • Demote Server and Remove AD DS Role fails with "the target principal name is incorrect"

    Hi all, 
    I am attempting to demote a domain controller so i can remove the AD DS role and have the server just its own workstation.
    This domain controller has never replicated the domain and DS services were/are not working.  We didnt discover this until the other domain controller died and has since been rebuilt with a brand new domain.  The old domain no longer exists whatsoever.
    So as said, I'm trying to demote this server, there is no domain to tidy up afterwards.  However even with force removal option I'm getting the DFS Replication error: "the target principal name is incorrect".  I do not exactly require
    it do this myself, there is nothing to replicate anymore, i just need the DC demoted or role completely removed.  There are no other DC's to transfer FSMO's or anything like that as its to be completely stand-alone.
    Does anyone have any ideas how this role can be forcibly removed other than using the " force removal option " in ADDS config wizard?  
    Any help will be gratefully appreciated.
    Thanks in advance
    Phill

    Hi Phill,
    You can try to use Ntdsutil.exe to perform metadata cleanup.
    If this doesn’t work, then I agree with Ed that you would need to reinstall the machine.
    More information for you:
    Clean Up Server Metadata
    http://technet.microsoft.com/en-us/library/cc816907(v=WS.10).aspx#bkmk_commandline
    Best Regards,
    Amy

  • How to get maximal value from the data/class for show in Map legend

    I make WAD report that using Map Web Item.
    I devide to four (4) classes for legend (Generate_Breaks).
    I want to change default value for the class by javascript and for this,
    I need to get maximal value from the class.
    How to get maximal value from the data/class.
    please give me solution for my problem.
    Many Thx
    Eddy Utomo

    use this to get the following End_date
    <?following-sibling::../END_DATE?>
    Try this
    <?for-each:/ROOT/ROW?>
    ==================
    Current StartDate <?START_DATE?>
    Current End Date <?END_DATE?>
    Next Start Date <?following-sibling::ROW/END_DATE?>
    Previous End Date <?preceding-sibling::ROW[1]/END_DATE?>
    ================
    <?end for-each?>
    o/p
    ==================
    Current StartDate 01-01-1980
    Current End Date 01-01-1988
    Next Start Date 01-01-1990
    Previous End Date
    ================
    ==================
    Current StartDate 01-01-1988
    Current End Date 01-01-1990
    Next Start Date 01-01-2005
    Previous End Date 01-01-1988
    ================
    ==================
    Current StartDate 01-01-2000
    Current End Date 01-01-2005
    Next Start Date
    Previous End Date 01

  • How to find workarea ID for the work area name.

    Hi Experts..
    How to find workarea ID for the work area name.(Work area name CCIHT_WAH-WAID and I want to fetch characteristic data from table AUSP matching the OBJEK field,but I only have Work area name).Can anybody help me to find tables or relationship between Workarea ID and Workarea name for the same.I am using TCODE - CHIB02.Once I select a workarea and click on IHS Data button,I get data for that workarea.I need to find where this data comes from and How is this fetched.
    Points would be rewarded for helpful answers..
    Thanks
    Kunal Halarnakar

    U want to fetch the workarea description ?
    we can fetch it from CCIHT_WALD table with the RECN value.
    The informations are stored in AUSP table with the characterstic(ATINN) value.

  • Authentication failed. (Microsoft.AnalysisServices.AdomdClient). The target principal name is incorrect (Microsoft.AnalysisServices.AdomdClient)

    Hi Experts,
    We had a task to  migrate SQL Server all the components to another server, the migration went well and had no issues at all. but We can login to SSAS service locally wihtout any issues. when we are connecting the analysis services from the other machines(servers)
    it is givng the below error.
    Authentication failed. (Microsoft.AnalysisServices.AdomdClient)
    The target principal name is incorrect (Microsoft.AnalysisServices.AdomdClient)
    1) it is a stand alone server
    2) it is connecting to default instance but not to a named instance
    3) SPN's were set correctly. Double checked with the tool(MS Kerberos configuration Tool).
    4) The SQL server analysis start account has domain admin privileges.
    5) we can connect to Database services from the other machine remotely.
    6) none of the analysis services are  connecting.
    Thank you in advance.

    Hi Ramu,
    According to your description, you migrated SQL Server to another server, everything works fine except that cannot connect to SSAS remotely with the error, right?
    Authentication failed. (Microsoft.AnalysisServices.AdomdClient)
    The target principal name is incorrect (Microsoft.AnalysisServices.AdomdClient)
    Based on my research, this issue is caused by that the SPN for account that run the Analysis Services is corrupt. You said that the SPN were set correctly, however the error message indicate that the problem is related to SPN. So in your scenario, you can
    delete the SPN under the service account, and register SPN for Analysis Services instance. Please refer to the link below to see the details.
    http://msdn.microsoft.com/en-IN/library/dn194200.aspx
    Besides, here is a blog which describe the similar issue.
    http://www.wolfsoftwaresystems.com/code/sql/the-target-principal-name-is-incorrect-microsoft-analysisservices-adomdclient/
    Regards,
    Charlie Liao
    TechNet Community Support

  • Accessing object of the main class from the thread

    Hi, I'm having problem accessing object of the main class from the thread. I have only one Thread and I'm calling log.append() from the Thread. Object log is defined and inicialized in the main class like this:
    public Text log;  // Text is SWT component
    log = new Text(...);Here is a Thread code:
    ...while((line = br.readLine())!=null) {
         try {
              log.append(line + "\r\n");
         } catch (SWTException swte) {
              ErrorMsg("SWT error: "+swte.getMessage());
    }Error is: org.eclipse.swt.SWTException: Invalid thread access
    When I replace log.append(...) with System.out.println(..) it works just fine, so my question is do the log.append(..) the right way.

    This is NOT a Java problem but a SWT specific issue.
    It is listed on the SWT FAQ page http://www.eclipse.org/swt/faq.php#uithread
    For more help with this you need to ask your question on a SWT specific forum, there is not a thing in these forums. This advice isn't just about SWT by the way but for all specific API exceptions/problems. You should take those questions to the forum or mailing list for that API. This forum is for general problems and exceptions arising from using the "core" Java libraries.

  • Can anyone tell me how to post videos taken on the iPhone that are now stored on the Air on Facebook?

    Can anyone tell me how to post videos taken on the iPhone that are now stored on the Air on Facebook?

    Hi
    Yeah got onto that but it won't load up anything readable. It just produces a little annimation of 35mm film strip and when you click on it - nothing. All you end up doing is clicking on the X in the top right hand corner of the annimation and deleting it. Really frustrating because uploading from the iPhone is simple, but I've deleted it off that and can't get it back from the Mac to the iPone either. Seem to be trapped no matter what i do.
    Thanks for your help though

  • How to get the current class name in static method?

    Hi,
    I'd like to get the current class name in a static method. This class is intended to be extended. So I would expect that the subclass need not to override this method and at the runtime, the method can get the subclass name.
    getClass() doesn't work, because it is not a static method.
    I would suggest Java to make getClass() static. It makes sense.
    But in the mean time, does anybody give an idea to work around it?
    Thank you,
    Bill

    Why not create an instance in a static method and use getClass() of the instance?
    public class Test {
       public static Class getClassName() {
          return new Test().getClass();

  • Why File Name is Same Name as The Public Class Name

    Hi Friends,
    What is the reason for Naming the File Name is puvlic class name??
    thanks in advance.

    konstkaras wrote:
    What could be reason to give it other name?
    It's as much better as we have less distinct names.
    When I was a schoolboy, I programmed Turbo Pascal. Each program there had a name (declared in file's beginning). The name was never used, but: it has no such restriction of length (as MS-DOS file names had) and it could clash with other identifiers described in code.
    So why those names should be distinct?Java was invented after MSDOS was obsolete, so 8.3 limits were not a consideration.
    Java is designed for larger programs than were attempted in the MSDOS era, so supports compilation of programs which are created from many source files. Turbo Pascal 4 also supported separate compilation units, and did use the name you mention for exactly that purpose, but I can't remember how it dealt with dependencies between compilation units.
    Having the public class' name and package as component in the source file path and the class file path simplifies the dependency problem between the compilation units - all the compiler has to do to determine whether the foo.bar.Baz class needs updating is to look whether foo/bar/Baz.class exists, and if it is less recently modified than foo/bar/Baz.java.

  • What's the WMI class name to get Client Approval status

    What's the WMI class name to get Client Approval status.
    Unfortunately the below example with class "SMS_R_System" does not have the approval status
    Get-WmiObject -Namespace "root\sms\site_LAB" -Class SMS_R_System | fl *
    I listed all the available classes and... yeah It's going to take along time to go though all the possibilities.
    Note: I'm running this in powershell on the primary first
    If anyone knows it... I'd appreciate your help

    This is all still in the testing phase so I'm not sure this is the best solution... but here's my problem and idea to resolve it.
    Currently in our environment OSD can only be run against unknown computers and approved clients.
    I currently automatically approve all clients in a trusted domain. So all systems that succeed OSD and auto join the domain are approved and I can always run OSD against those machines in the future.
    Problem is with the systems that fail OSD for any reason and therefore do not automatically join the domain. They end up getting a SCCM record by the name of "Unknown" and therefore cannot run OSD again until the "Unknown" record
    is deleted. "Unknown" records happen too frequently to manually delete and I'm not too comfortable with just deleting ALL of them on a scheduled basis.
    Additionally there are way too many OU's in my environment to automatically join our OSD'd systems to the domain. So I have a script that checks using a prestart command to see if the system is already in AD, and if so then OSD continues and simply
    joins the machine to the domain in it's current OU. If not the tech is given a nasty error message telling them to add the computer object in AD in the proper OU first.
    I intend to check , with a Prestart Command if the current system already has a record in SCCM and delete it if found AND is not approved yet. This should resolve the "There are no task sequences available" error I get with
    systems that have an "Unknown" SCCM record.
    In this way the system will be essentially approved if the system was already prestaged in AD manually by a technician and any "unknown" record for that system will simply be deleted at the point of OSD.
    Note: Although I can easily use the new SCCM Powershell cmdlettts and get the "Approved" status, I need to do all of this in WinPE without the cmdletts. If this property is not available via WMI, then I'm guessing this will not work.

Maybe you are looking for

  • System Fonts Deletion

    system/library/fonts contents were accidently deleted. now the powerbook won't start up. after the initial apple logo, screen goes blue and remains that way. tried to reset back to factory settings. also tried option-command-P-R upon startup. please

  • Can't sync palm m505 with isync

    I seem to be having difficulties establishing a connection. Can someone please walk me through the steps of syncing my palme with isync. I can see the device and begin the process but can not seem to establish a connection. Thanks Cheryl

  • Creative Cloud: Photoshop only includes Lightroom?

    Heyo! There is no option available to buy a CC-Lightroom license separately, only Photoshop is available. There is no info, that Lightroom is separately bookable. So, my question: If i buy a license for Photoshop, will Lightroom be included? Regards,

  • Read a file in WS

    hi all, i have some configuration files into a ws jar. these files are txt. how can i read them? i don't know the path of these file in the jar. tnk all.

  • Record Audio in Captivate 4 for PP Slide with multiple mouse click animation

    I have a power point presentation imported into  Captivate 4.  Several of the slides have custom animation that ocurr's on mouse click. What is the best way to record the audio for these slides and have the audio sync to the right portion of the slid