Get runtime class and cast object to it?

Hi,
public interface Msg
Msg msg=msgLib.get(msgType);
Msg msg2=msg.clone(); //problem! cannot find clone in  x.y.Msg!
...Shouldn't msg be resolved to the implementing class (MsgReply for example) and use the "clone()" method, that i have declared in that class -which overrides the one of Object class?
If no, is there a way to find the runtime class -probably use "getClass"- and cast to it? How?
Thanks

There are many implementing classes; i want to get the runtime class. Something like:
(msg.getClass())msg.clone();
Message was edited by:
uig

Similar Messages

  • Help with Runtime class and timeout of Process

    Hi,
    Question regarding using Runtime class, and yes I have looked at the javadocs, but I am still confused and frustrated.
    Here is part of my code.
    Process p;
    Runtime runtime = Runtime.getRuntime();
    p = runtime.exec("rsh localhost ls");
    if you are not familiar with rsh all it does is remote shell into the computer localhost and executes the command ls.
    Now, I dont have rsh running on my computer so it will hang at that line for about 40 sec and eventually time out on its own. Is there anyway I can specify a timeout argument like there is for the ping command? Like if there is no response from localhost after 3 sec, then just kill the process?
    I looked at the Runtime javadoc and Process javadoc and the closest thing I could come to with is something to do with envp (environment parameters), but I dont know what that is.
    Thanks guys.

    You can't timeout the "runtime.exec("rsh localhost ls");" call but if you execute the call in a seperate thread you can "timeout" and continue executing on the original thread (while letting the "runtime" thread to timeout on its own).
    Check the following class that I created for cases like this:
    abstract public class TimeoutHelper implements Runnable
        private Throwable error;
        private boolean running = true;
        private Object retValue;
        protected String name;
        private long waitTime;
        private Thread thread;
         * Creates a new helper. Use {@link #start} to run the code.
         * @param name A name that will be used in the helper thread name
         * @param waitTime The time (in msec) to wait before timeout.
        public TimeoutHelper(String name, long waitTime)
            this.name = name;
            this.waitTime = waitTime;
        public Object start() throws Throwable
            return asyncExecute();
        abstract protected Object execute() throws Throwable;
        private synchronized Object asyncExecute() throws Throwable
            createThread().start();
            if (running)
                try
                    wait(waitTime);
                    if (running)
                        // Timeout!!
                        abortThread();
                        throw new TimeOutException("Timeout for: " + name);
                catch (InterruptedException ie)
                    // Ignore
            if (error != null)
                throw error;
            return retValue;
        private void abortThread()
            if (thread != null)
                thread.interrupt();
        protected Thread createThread()
            thread = new Thread(this, name);
            return thread;
        public void run()
            try
                retValue = execute();
            catch (Throwable th)
                error = th;
            synchronized (this)
                running = false;
                notifyAll();
    }You use the class by extending it and implementing "execute". For example:
            TimeoutHelper helper = new TimeoutHelper("Runner", 5000)
                protected Object execute() throws Throwable
                    Runtime runtime = Runtime.getRuntime();
                    return runtime.exec("rsh localhost ls");
            try
                Process p = (Process)helper.start();
            catch (TimeOutException e)
                // Handle timeout here
            catch (Exception e)
                // Handle other errors here.
            }

  • Is it possible to create web services for classes and bol objects?

    i am new to crm web channel,can any one  please ,help me....
    thank u in advance,
    kiran.

    Hi Kiran,
    Here, when you are talking about classes and BOL objects together, I assume you are talking about the BOL layer for CRM. If that is the case, and you have no dependency on WCEM for these objects, I would suggest you use the NW gateway to expose Odata web services from the CRM box itself. If you would like to expose the Odata web services from WCEM, please have a look at Ch 7 Dev & Extension Guide available in help.sap.com/wec301.
    Good luck!
    Regards
    Pranshu

  • While installing latest update I lost ability to open Itunes.  Getting "runtime error" and then next box says error 1114.  Tried uninstalling and reinstalling and does not work.  Getting same error.  Very frustrating.

    Cannot open Itunes after trying to install latest update.  Getting runtime error and then error 1114.  Tried uninstalling and reinstalling and still getting same error.  How do I fix this.  Very frustrating!

    Hi there,
    Earlier iTunes (and supporting applications) need to be completely uninstalled before you can install the new version. Here's the complete Apple info on this: http://support.apple.com/kb/HT1923
    Mobile device application will most likely fail to uninstall, so you would need to visit its location(s) and manually delete the files then folder(s). The location of the folders is documented in this link from Apple.
    It's a pain, but it should work.

  • How to get subject text and Reference Object both Screens at the Header lev

    Dear Experts ,
                    I am getting only Notification Header Screen ( Subject Text, Notification system and User Status) at the Header of Notification and different Tabs under that screen.
                    I want Subject Text and Reference Object screens at header Level so that any screen Tab selected at a time I can see the Subject and Reference Object of the Notification.
                    Pls tell me is there any way so I can Include 2 screens( Subject and Reference Object at the Header Level.)
    With best regards,
    Narendra

    Narendra,
    You can't in the standard system.
    Only the tabs are configurable.
    PeteA

  • Getting text ID and Text object  associated with item texts in PO...

    Hi,
    To print standard text on smartform for a given item in purchase order, I need to find the text ID and object associated with it.
    There are various texts like item text, Info record PO text, Material PO Text, Delievry Text, etc...
    Now when I go to ME22N, and select item detail for any item -> Texts , how do I get text ID, and object associated with it ?

    Hi ,
        Use table stxh,stxl
        FM read_text.
        you can view the text id by following
        this link
         me23->header-text-double click on text->menu goto->
         header        
    Regards
    Amole

  • Class and detail object description Change in Web Intelligence

    Hi,
    I need to display the same detail object (which is coming from Universe) with different names in multiple WEBI reports, how can I change the description of class or detail object in WEBI reports instead of Universe?
    Regards,
    Preetham

    Hi Preetham,
    Where do you want to do this. If it is is just in the table header then you simply need to click on the header item, click the Fx toolbar button. It displays the edit toolbar with the formula
    =NameOf([My Object])
    You can change this to be
    ="My New Name"
    Hope helps
    If you want to change the name of the variable in the data panel, then I am afraid this is not possible.
    Regards
    Alan

  • Java Runtime class and CloneNotSupportedException

    I'm trying to execute an operating system command via a Java Stored Procedure but it fails with the following message:
    Exception caught executing command.
    java.lang.CloneNotSupportedException
    at java.lang.Object.clone(Object.java)
    at java.lang.Runtime.exec(Runtime.java)
    at java.lang.Runtime.exec(Runtime.java)
    at java.lang.Runtime.exec(Runtime.java)
    at Host.Execute(Host.java:10)
    Why? Here is my java source:
    public class Host {
    public static int Execute(String[] aCommand) throws IOException {
    int rtnVal;
    try {
    Process pid = Runtime.getRuntime().exec(aCommand);
    rtnVal = pid.waitFor();
    catch (Exception e) {
    e.printStackTrace();
    rtnVal = -1;
    return rtnVal;

    John,
    I don't have an answer for you, just some suggestions.
    The problem may be related to the command you are trying to execute. Does your code not work for any command you try?
    Also, your java method takes a "String[]" parameter. There is no standard mapping between a java "String[]" and a PL/SQL type. What is your (PL/SQL) call spec for this method?
    According to the code you have posted, the "Execute()" method swallows all "Exception"s -- since your code catches them and merely prints out the stack trace. So is the stack trace you posted from the printed out stack trace (from your "catch" block) -- or is it an "uncaught" exception? Since "CloneNotSupportedException" is a subclass of "Exception", I guess the former is correct, right?
    Also, since your code catches "Exception"s, and since "IOException" is a subclass of "Exception", there's not much point in declaring that your method "throws IOException". So what's the point of the declaration?
    By the way, I couldn't find any mention in your post of the database version you are using. Posting that detail may be helpful (in getting you an answer to your question).
    Good Luck,
    Avi.

  • Parent class and Casting

    Hi all,
    I need to store different classes in a Vector. The classes have in common that they are all different views (MVC!). If I make a common parent, can I cast to that parent without problems?
    Background:
    I'm programming on a mobile, which uses different screens (choice screen, data screen and help screen). Depending on an event, be it a button pressed, or data comming in from another mobile, the view the player gets needs to be changed. The Model will call an update () method on the view. If I make the update method abstract, the update method of the child class will be used?
    Maik

    I need to store different classes in a Vector. The
    classes have in common that they are all different
    views (MVC!). If I make a common parent, can I cast
    to that parent without problems?Yes.
    If I make the update
    method abstract, the update method of the child class
    will be used? Is there any other? It will always use the method the instance implements.

  • Is it possible to create Webservice for Classes and BOL Objects?

    hi all ,
    i am new to  sap crm please help me out.
    thanks and regards,
    Ahmad

    Hi Narayana,
    Use BDC's for better maintainance of relationship. which worked fine for me.
    thanks,
    vasu.

  • Classes and Objects

    I am new to object oriented programing. Now I think I am in little bit confusion with the concept of Basic building blocks of Object oriented programing. My doubt is;-
    1) "What Actually a class is ? Is it a user defined Data Type ?"
    2) "What actually an Object is ? Is an Object another format of a class ? Or an object is just a piece of Class, I mean is a group of Objects going to construct a class ?"
    3) "Is an object going to contain the reference of the data members only or both the data members and functions as well ? If It is going to contain both of these two then what is the Difference between a class and an object ?"
    4) "Is Constructor simply a function or something else ?"

    929663 wrote:
    I am new to object oriented programing. Now I think I am in little bit confusion with the concept of Basic building blocks of Object oriented programing. My doubt is;-
    1) "What Actually a class is ? Is it a user defined Data Type ?"More or less. You can find a more complete definition in any text or tutorial, or with a simple google search.
    2) "What actually an Object is ? Is an Object another format of a class ? Or an object is just a piece of Class, I mean is a group of Objects going to construct a class ?"Again: text, tutorial, google, or any combination.
    3) "Is an object going to contain the reference of the data members only or both the data members and functions as well ? If It is going to contain both of these two then what is the Difference between a class and an object ?"Data only. But the object also knows what class it is and where to find its class definition that tells it what methods it has.
    4) "Is Constructor simply a function or something else ?"It's not a method. It' similar to a method, in that it's a named grouping of operations, but it doesn't have a return type, and it can only be called at certain points in your code. It's job is specifically to get a newly created object into a valid initial state.
    http://docs.oracle.com/javase/tutorial/ --> http://docs.oracle.com/javase/tutorial/java/index.html --> http://docs.oracle.com/javase/tutorial/java/javaOO/index.html

  • Associations and extended objects

    Hi,
    I'm just beginning to look at bc4j so bear with me if I ask a stupid question :-)
    The thing is that I'm experimenting with simple inheritance and I cant seem to get the associations to work like I would expect. I have 3 classes (business components). Customer, Account (which in my model is an abstract superclass) and SavingsAccount. And there is an association between Account and Customer in my model implying of cause that there is an assosiation between all subclasses of Account (SavingsAccount) and Customer.
    Account and SavingsAccount are in seperate tables - mabye thats where my problems lie ?
    But no such associations are created automatically by the 'create database objects' command.
    Is this also the experience of others here ? What it means is that my model gets 'abused' when I create the associations and I'm not too happy about that.

    Well, then I'm stumped as to why that won't work for me. If I have the following code:
    import java.util.*;
    public class Test1
        private ArrayList<E extends Integer> aList;
        public Test1()
            aList = new ArrayList<Integer>();
        public void run()
            for (byte i = 0; i < 10; i++)
                Integer o = new Integer(i);
                aList.add(o);
        public ArrayList<E extends Integer> getResults()
            return aList;
    }I get "> expected".
    Your last piece of code shows what I will probably end up doing, as this just can't seem to work, i.e. getting each Object1 and casting it to an Object2.
    What I need, is to initially build an ArrayList containing Object1s. Then my Object2 class is an extension of Object1, and therefore I else want to have that ArrayList returned, but the info I need now are Object2s. So basically build an ArrayList of Object1s, needed in that particular class, make a method that returns it, invoke that method in another class, but have that ArrayList contain Object2s instead.
    While I could iterate through the elements, I will also need to return the ArrayList with Object2 elements in it from the other class, so I prefer being able to do it in one swoop, using generics, if at all possible. Which it seems not to be.
    Edited by: ThemePark on May 21, 2008 2:14 PM

  • Runtime class

    i am trying to execute an exe file made from a c++ program from my java code....
    i am using the runtime class and the exec method....
    but since c++ programs dont run in JRE environment....the exe file is not getting executed...
    what shud i do?
    plz help.....

    What do you make after this lines.
    Could be useful to wait for that process:
    p.waitFor();
    By default the process uses the null device to print out message.
    That means you get no message output.
    Use the getInputStream() and getErrorStream() to pipe the output into your application and to print out
    the message to System.out or System.error
    Why do you think that your c-application is not running?
    Do you get an exception?
    It also possible that you have to make the Porcess object more global, so that the garbage collector
    doesn't destory the object while executing c-application.
    regards
    Andy

  • Vectors - Saving Reference to a Class and calling it's Methods ?

    Hi,
    How can I do this ? trying to execute a method from a class reference stored in a Vector.... something like this...
    Vector v = new Vector();
    v.addElement( new MyJPanel1());
    v.addElement( new MyJPanel2());
    for (int i=0; i<v.size();i++) {
    // How can i execute the methods contained within say MyPanel1()
    // from the vector c ?
    // ie) MyPanel1().closwWindow();
    }Thanks
    Rob

    You have to get the element and cast it to the appropriate type. Then do what you want.
    JPanel panel = (JPanel) v.elementAt(i);And then there is generics but from you have posted you don't seem to have those...

  • Help required: Classes and class values for Func Loc

    Dear All,
    I have a requirement to get the classes and values associated with a functional location.
    Any idea how to get this data, as in IL03.
    Thanks,
    nsp.

    Hello nsp,
    You can try to check out the Function module ALM_ME_TOB_CLASSES to see how they fetched class, characteristics and their values.
    You can keep a break-point in this module and run MAM30_031_GETDETAIL and check how we can pass the appropriate values.
    However, above FMs are available from PI 2004.1 SP 14 of release 4.6c, 4.7 and 5.0.
    If you are in ERP 6.0, the FM's are available.
    Hope this helps
    Best Regards,
    Subhakanth

Maybe you are looking for

  • Problems launching Full Screen QT7 in Windows... help?

    I have been testing full screen video over the web using QT7. It works awsome in Mac, but I am dealing with odd bugs in widnows - so here goes. This page: http://www.24frets.com/testing/ Works fine, but the controller that appears on full screen does

  • Why are pdf files opened automatically in iPad email. I need to save the pdf file itself.

    Why are pdf files opened automatically in iPad email?  I need to save the pdf file itself, so I can re-read them for later.  ANy fix.  Some pdf files I send are saved as pdf files unopened.

  • Automatic update of web.xml when running UIX application

    I moved my UIX project from 9.02 to 9.03. The UIX resource files have changed between the versions so I deleted the old cabo folder so that when I ran my applicaton for the first time it would rebuild it. When I ran my application my web.xml file was

  • Schedule shutdown stops working after putting the computer to sleep

    I had trouble scheduling the computer to shut down after upgrading from Mac OS 10.3.9 to Mac OS 10.4.6. I accidentally left my screen closed on my PowerBook G4 after scheduling it to startup. It startup with the scceen closed and in sleep mode. After

  • NAS and Time Machine

    I am looking at getting some type of NAS. What NAS would i need so that time machines would be able to backup to it? I would be backing up a number of different computers both PC's/Servers and Mac's to it (from what i remember, once time machine uses