Deserialize works fine. Now I cannot create my class instance

When I deserialize my object a can get the object. Ok.
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(fichero));     
               aux = ois.readObject();                
               System.out.println(aux);
And I see :
mypackage.myclass (This class is a Jpanel based and some references to another classes)
Now I have 3 questiosn - problems:
1.- I dont know the class name (or I want that my code works with every kind of object) ,so... Is it neccesary to CAST the object?
2.- In this case.... it can be done by mean of string name ? aux = (the_cast) .... ( when the_cast = "MYclass")
3.- Finally I dont know how to create an instance of my new class
((MY_CAST) aux.getclass()).newinstance(); throws an error of "java.lang.Class cannot be cast ..."
Any help?

tonnot wrote:
Now I have 3 questiosn - problems:
1.- I dont know the class name (or I want that my code works with every kind of object) ,so... Is it neccesary to CAST the object? No, it's not necessary usually and when you don't know the type at compile time, then it's not possible either.
2.- In this case.... it can be done by mean of string name ? aux = (the_cast) .... ( when the_cast = "MYclass")No, that's not possible. Since casting doesn't change anything about the object but only about the reference, casting "to a dynamic type" is meaningless, since you couldn't have a reference variable "of a dynamic type" to hold the newly-cast object anyway.
3.- Finally I dont know how to create an instance of my new class
((MY_CAST) aux.getclass()).newinstance(); throws an error of "java.lang.Class cannot be cast ..."The problem is that you're trying to cast the Class object to MY_CAST (which I assume is your class), while it should in fact be a Class<? extends MY_CAST>.
I'm unclear what you want to achieve here and what you know about the object: Why do you want to create a new instance of an object you know nothing about?

Similar Messages

  • Itunes 6 works fine now, but cannot play music

    Hey Guys,
    I finally got my Itunes 6 to work, but now when i get in, i cannot get any of my music to play?
    I just updated the latest Ipod updater (2005-10-12)
    any ideas??

    Nick,
    I have cracked it on my machine.
    Now i'm not a techy so forgive the basic language but this is how I did it.
    My machine has Norton anti virus. For some reason the version of Quicktime that comes automatically with Itunes 6 is blocked by Norton and therefore messes up Itunes.
    I turned off my Antivirus, then downloaded this.
    http://www.apple.com/quicktime/download/standalone.html
    Once this is downloaded it seems to override the original Quicktime download and IS accepted by Norton. I then tried Itunes and it started to play.
    Then I switched back on the antivirus and it was all fine. I now have my music back.
    Good luck.

  • Installed Windows 8 on a late 2011 MacBook Air and was working fine now keyboard not working so cannot enter password? Caplocks key works but I am locked out on my own PC and cannot seem to get it to recognize built in keyboard,bluetooth,generic USB one.

    Installed Windows 8 on a late 2011 MacBook Air and was working fine now keyboard not working so cannot enter password? Caplocks key works but I am locked out on my own PC and cannot seem to get it to recognize built in keyboard,bluetooth,generic USB one.

    Use the trackpad to scroll, thats what it was designed for. The scroll bars automatically disappear when not being used and will appear if you scroll up or down using the trackpad.
    This is a user-to-user forum and most people will post on here if they have problems. You very rarely get people posting to say there update went smooth. The fact is the vast majority of Mountain Lion users will not be experiencing any major problems with the OS, or maybe with apps which are not compatible, but thats hardly Apple's fault if developers don't update their apps.

  • Installed Mac OS X v.10.6.7, and now we cannot create a PDF file

    Installed Mac OS X v.10.6.7, and now we cannot create a PDF file using Adobe Acrobat Professional.  This has been done on two computers, one an iMac and the other a MacBook Pro.  Assistance greatly appreciated.

    Yes, Adobe Acrobat X Pro is the same thing as Acrobat X Pro.
    Print to PDF is probably the most reliable way to create a PDF file.
    File > Create > PDF from File
    is shaky.  It works with some file types but not with others.
    Another issue is creating a multi-page PDF from a scanner.  If you neglect to check the box "Prompt for scanning more pages" and, instead, simply try to add a second page, the application crashes.

  • Airport express worked fine now shows only constant amber light ?

    airport express worked fine now shows only constant amber light ?

    A solid amber light indicates that the AirPort Express cannot get out of startup mode.....likely because of a power supply issue within the device.
    Try a Factory Default Reset as a last resort to see if that might help. To do this....
    Power off the AirPort Express and wait a minute or two
    Hold in the reset button on the Express first, and keep holding it for 9-10 seconds while you simultaneously plug the Express back into power
    Release the reset button after the hold period and allow a full minute for the Express to restart
    At this point, if the Express is operating correctly, the amber light will be blinking slowly and you can reconfigure the Express again.
    If the amber light remains solid after a few reset attempts, the internal power supply on the Express is faulty and the device will need to be replaced.

  • HT1351 Have downloaded one playlist in my ipod classic,works fine, now downloaded another, can't figure out how to access it??into playlist from there goes to On-the-Go. How do I access Playlist 2????

    Just got this Ipod classic,  little greek to me,      Have downloaded one playlist,   works fine,   now  tried to download a second , which  I believe it did, out of my Itunes library,  but how is it listed in my Ipod    , scoll down to playlist, then what?    seems to always go to On-the-Go then what ???    Thanks   Dan

    When you go into the Playlists menu of your iPod Classic, you should see a list of the Playlists you have downloaded from your iTunes Library - and the On-The-Go Playlist. If you can only see the On-The-Go Playlist, that suggests that you have not successfully downloaded any Playlists.
    Playlists are separate from the songs. The songs, albums etc. etc. will be listed under those menu headings on the Main Menu.
    The On-The-Go Playlist is a feature that allows you to create Playlists on the iPod. Initially, and after each Sync with iTunes, the On-The-Go should be empty. If you create one, you can save it on the iPod and it will be transferred back to the iPod at Sync time and renamed as On-The-Go X (X is the next available number). If you create and save one on your iPod, it will be named on the iPod as New Playlist X, but renamed as On-The-Go X when Synced with iTunes.

  • My macbook pro no longer connects to my TV with the mini dvi to hdmi adapter. It was working fine now I cant get it to output to the Tv. Any ideas?

    My Macbook pro no longer outputs to my vizio led tv. It was working fine now I cant get any picture. It just says no signal. It is not the hdmi or the adapter because it works fine with my other tv. Any ideas on how to resolve this would be greatly appreciated. Please be as specific as possible. Thanks. BTW--I am using the mini dvi to hdmi adapter in case that was unclear.

    Since you say that the same connectors work on your other TV is suggests that the fault is not in the connectors but your Vizio TV.  I would check the settings on the Vizio TV.  Verify that is is set to receive HDMI input.  Perhaps you or some one else has inadvertently changed them.  Pressing the wrong buttons on a remote control device can do that.  (I am assuming no changes were made in SYSTEM PREFERENCES>DISPLAYS)
    Ciao.

  • My ipod 4th gen screen kept jumping this morning. Had to do a restore on it and it is working fine now. However, when I did the restore it did not load the Nike   app that was factory installed on my ipod. I use this app daily. Any idea how to get it back

    My ipod 4th gen screen kept jumping this morning. Had to do a restore to factory conditions and it is working fine now. However, it originally had a factory installed Nike+ app on it and it did not install with the restore. I use this app daily with the running chip to log my workouts. Anyone know how to get this app back from Apple? Loading the Nike app from the app store is not the same thing as you need gps running continually for it to work (as with an iphone). Can't have that with my ipod unless I'm connected to wifi. Help?? Thanks.

    If you go to Settings do you see an entry for the Nike app? There is no way to delete or hide that app?
    Have you tired using the Spotlight search? Maybe you just can't find it.
    Next would be to restore a gain. First from backup then next to factory settings/new iPod.
    The Nike app you can download/install
    Nike+ Running for iPhone 3GS, iPhone 4, iPhone 4S, iPhone 5, iPod touch (3rd generation), iPod touch (4th generation), iPod touch (5th generation) and iPad on the iTunes App Store
    Does work on the iPOd. You just do not get all the information that GPS/cellular connection can get. You will still be able to get distance/footstrikes like the installed app an you do not need the shoe sensor.. It uses the built-in sensors on the iPod

  • My camera is working fine now

    My 54gca is working fine now with all browsers. How? I don't know except I had some email exchanges with someone at TZO and he wanted my domain name.
    My camera was logging off after a period of time and I couldn't view it outside of my LAN because of the ActiveX issue, I think.
    I was in IT for a while and that taught me not to believe in coincidence. Mine works now.

    You could try to ad your camera url to trusted sites in internet explorer. You can download the following zip file extract it and open the extracted mht file in internet explorer. There you will see a short tutorial with screenshots on how todo this. trusted site.zip
    I agree with you that linksys-cisco should update there certificate. Those workarounds shouldn't be needed.
    Maurice 

  • Gvox Encore was working fine, now it stops loading.

    Why does a program that was working fine now suddenly stops loading properly or just freezes?
    I use Encore Music Notation program from GVOX. I was working perfectly and now it stalls upon loadup. Please help me someone

    the matter is taken care of

  • HT5577 i bought  recently a second hand apple i phone 4s but now i cannot creat new apple id

    i bought  recently a second hand apple i phone 4s but now i cannot creat new apple id .

    I suspect you're referring to the 3 free iCloud account limit on an iOS device. If so, there's no way around this. Once that limit is reached, you'll have to create the iCloud account on another iOS device or computer, then setup that account on your phone.

  • PowerPivot - SP2013 - Cannot create the service instance because the parent Service does not exist

    Unable to setup PowerPivot using PowerPivot configuration tool.
    I have One server which has SQL 2012 SP1 and SP2013.
    The farm is configured with all service applications.
    SQL has default instance with DB Engine and SSAS Tabular. Reporting Services has been configured using SharePoint mode and has a service application.
    The Power Pivot instance is set up with DB Engine and the SSAS.
    I keep getting this error. Ive tried so many times uninstalling, making sure features removed, rebuilding the farm (thank god for autospinstaller..)
    11/07/13 12:06:17:6858 Verbose: CreateSystemServiceInstance.NeedsExecute
    11/07/13 12:06:17:6858 Verbose: Running function IsFarmConfigured to check whether SharePoint is configured regardless of availability
    11/07/13 12:06:17:6858 Verbose: Farm is configured
    11/07/13 12:06:17:6858 Verbose: Entering function GetService(Guid)
    11/07/13 12:06:17:6868 Verbose: Service is not installed.
    11/07/13 12:06:17:6868 Verbose: Service instance not found in local server.
    11/07/13 12:06:17:6868 Verbose: CreateSystemServiceInstance.NeedsExecute(True)
    11/07/13 12:06:17:6868 Verbose: CreateSystemServiceInstance.CanExecute
    11/07/13 12:06:17:6868 Verbose: CreateSystemServiceInstance.CanExecute(True)
    11/07/13 12:07:41:5662 Verbose: CreateSystemServiceInstance.Execute
    11/07/13 12:07:41:5682 Verbose: Entering function GetService(Guid)
    11/07/13 12:07:41:5702 Verbose: Service is not installed.
    11/07/13 12:07:41:5702 Verbose: CreateSystemServiceInstance.Execute(Skipped)
    11/07/13 12:07:41:5702 High: Cannot create the service instance because the parent Service does not exist.
    11/07/13 12:07:41:5702 High: Prerequisites check for execution failed. Farm is not in a valid state.

    Did you install the PowerPivot add-in for SharePoint? There are 2 parts to this - the SQL Server Power Pivot for SharePoint which is the Analysis Services instance running in Tabular Mode and the PowerPivot Add-in. The last line in your error message seems
    to tell you that you have a missing component in the farm, possibly the PowerPivot Add-in
    Edwin Sarmiento SQL Server MVP | Microsoft Certified Master
    Blog |
    Twitter | LinkedIn
    SQL Server High Availability and Disaster Recover Deep Dive Course

  • I changed my apple id email address to try jumpstart my account to send me a verification email for iCloud activation.  It worked but now I cannot change back to my original email address.  It says its in use.

    Hi Guys
    I am writing this on behalf of a friend of mine.  To understand my issue let me explain how it started.  My friend has a apple ID with email address (lets call it) [email protected]  when activating iCloud on her iPhone a email was sent to verify her account.  This was not done and rendered the iCloud feature disabled due to not being activated.  [email protected] is the correct email address and works.  A form of troubleshooting I used the iForgot service to test if the email address was correct and mail flow from apple was working and it worked fine.
    I logged into apple id to manage account and resend activation email for iCloud.  this did not send the mail.  I waited 48hrs but to no avail.
    I decided to kickstart the account to force it to send to another email address by changing the primary email address from [email protected] to [email protected]  it worked and I verified the address and iCloud is now active.  However now I cannot change the primary email address back to [email protected] as it says its being used by another apple ID. 
    I then tried iForgot with the [email protected] email address, it says it sent a email to [email protected] but nothing arrived in [email protected] or [email protected]
    I have this feeling the [email protected] is stuck I'm memory on my apple ID some how but can't get it to forget [email protected] so that I can use it as my primary email address again.
    I have tried to log into iTunes with my original details [email protected] and password but says its incorrect.
    any advices in this would be greatly appreciated.

    The idea to jumpstart by change was not the smartest one, but gives you an opportunity to use that "temporary" account as permanent. You do not have a choice cause obviously despite you thinking that old account is no more -it does exist on Apple servers. And if you are unwilling to share your [email protected] with friend, just create one extra [email protected] for your friend. One suggestion - do not use gmail.

  • Itunes wont start in Windows7 Professional 64-bit, it used to work fine now it won't start!

    OK, So my itunes use to work fine until yesterday when I went to open it. It wont start and I tried many different things. Unistalled, re-installed, removed everything apple related (one of the apple support articles told me to try that) and that didn't work either. I know this question may have been posted earlier but I can't find anything for this specific issue (win7 pro, 64bit).
    Anyhelp would be greatly appreciated.

    Before you go knocking a much better OS than you'd wish to believe, I'm having the SAME problem in XP.
    And now, instead of showing up as one Multimedia Audio Controller...
    It shows up as like... 20-30 of themMessage Edited by ouT-Phaze on 03-03-200809:02 PM

  • Yesterday I download Firefox 4. When I tried to open it I got message that Firefox was "working offline" How can I change this back to on-line when I can't get any farther? All other programs work fine, I just cannot access the internet.

    Computer is a desktop running Windows Vista. IE will not open either saying "there is a problem and shutting down". My laptop with Firefox 3.6 works fine.

    See https://support.mozilla.com/en-US/kb/Firefox+cannot+load+websites+but+other+programs+can

Maybe you are looking for

  • Videos in some iPhotos Albums do not show up on Apple TV.

    Videos in some iPhotos Albums do not show up on Apple TV. Videos in other folders are there. For instance, one album has 43 videos and 1600 photos. Apple TV only shows the 1600 photos. Is there an issue with albums that have both photos and videos?

  • How do I get Facetime to connect on my Macbook Pro?

    Hi guys, For some reason Facetime is not connecting to anyone anymore. I cannot receive incoming calls and when I dial out, it just rings and rings and other party will tell me that they are not getting anything from me. I've read the Facetime Troubl

  • Suggestions for new features and improvements for Garageband

    Hi, I posted this to iCompositions but don't know who would be exposed to it as far as Apple goes. Just thought I would list a sort of wish list for GB that would make a huge difference for me. Most are just basic interface improvements and changes.

  • Undeploy an sda file through command-line

    Hi All,       I want to undeploy an .sda file through command-line,what is the procedure to undeploy an sda file through command-line and send me the procedure for this Thanks & Regards, guru

  • Java code to check system of another PC

    i would like to check the system (i.e. CPU name, CPU speed, etc) of another PC from my PC. How will I do it? Currently, I can check the system of a PC if I launched my java application on that PC. But now, I want it to be checked via network. Can you