Convert instance of generic class in byte[]  ?

Hello i need the method for convert instance of a generic class in byte[]
I have already tried this method but it does not work with all the classes
often the execption class not serializzabile is generated.
ByteArrayOutputStream regStore = new ByteArrayOutputStream();
ObjectOutputStream regObjectStream = new
ObjectOutputStream(regStore);
regObjectStream.writeObject(myGenericClass );
byte[] bbyte = regStore.toByteArray();

I have needs to convert in byte[ ] the istance class present in memory
the is javax.media.Buffer
in tried this method but not function ( exception not serialize is generated)
frameGrabber = (FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");
Buffer buf = frameGrabber.grabFrame();
ByteArrayOutputStream regStore = new ByteArrayOutputStream();
ObjectOutputStream regObjectStream = new ObjectOutputStream(regStore);
regObjectStream.writeObject( buf.getClass() );
byte[] bbyte = regStore.toByteArray();

Similar Messages

  • How do I create an genericized instance of this class?

    Hi, I'm having trouble creating a proper generic instance of this class that I wrote. The class type is cyclic dependant on itself.
    public class MyClass<T extends MyClass<T>>
    I can create an instance like this:
    MyClass<?> class = new MyClass();But I would be mixing raw types and generic types.
    Is there anyway to create a proper generic instance of MyClass?
    Thanks a lot
    -Cuppo

    Ah thanks georgemc,
    your solution will certainly work.
    If i may ask your opinion of something...
    MyClass is designed such that the type parameter should always be the same as the class itself. It's kinda a hack to get the subclass type from the superclass.
    so a hierarchy looks something like this:
    class MyClass<T extends MyClass<T> >
    class SubClass<T extends SubClass<T>> extends MyClass<T>
    class FinalSubClass extends SubClass<FinalSubClass>So ideally i would want something like:
    MyClass m = new MyClass<MyClass>();
    (which is not possible)
    is there a way to get around this?
    -Cuppo

  • Generic instance maker and class definition in separate files - problem

    file: genericinstantiator.java
    package testGenericInstantiator;
    public final class GenericInstantiator {
         public <T> T makeInstance(Class<T> c) {
              T instance = null;
              try {
                   instance = c.newInstance();
              } catch (IllegalAccessException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (InstantiationException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              return instance;
    file: genericinstantiatorusage.java
    package testGenericInstantiator.usage;
    import testGenericInstantiator.GenericInstantiator;
    final class SillyClass {
         public void sayBoo() {
              System.out.println("boo");
    public final class GenericInstantiatorUsage {
         public static void main(String[] args) {
              GenericInstantiator gi = new GenericInstantiator();
              SillyClass sc = gi.makeInstance(SillyClass.class);
              sc.sayBoo();
              System.exit(0);
    thrown exception:
    java.lang.IllegalAccessException
    on the line 'instance = c.newInstance();' in instantiator
    reason in jdk:
    if the class or its nullary constructor is not accessible.
    question:
    how to avoid this? (in my situation, the place of making instance and its class MUST be separated in another files)
    Edited by: gizmo640 on Mar 27, 2008 11:39 AM

    package testGenericInstantiator;
    import java.lang.reflect.Constructor;
    import java.lang.reflect.InvocationTargetException;
    public final class GenericInstantiator {
         public <T> T makeInstance(Class<T> c) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException {
              T instance = null;     
              Class[] emptyParams = {};
              Constructor<T> con = c.getDeclaredConstructor(emptyParams);
              con.setAccessible(true);
              instance = con.newInstance();
              return instance;
    }setting constructor to accessible works well too

  • How to get the parameter name of a generic class?

    Is it possible to get the name of generic class parameter type without having an instance of that type?
    e.g.
    class MyClass<T> {
      public MyClass() {
      // get the name here
    }

    I need to get a string containing "Object" (or "java.lang.Object") if the class would be used like this:
    MyClass<Object> mc = new MyClass<Object>()

  • Creating an instance of a class at runtime?

    Does anyone know how to create an instance of a class at RunTime? For example, I want to load classes from a JAR file at RunTime, and then create instances of certain classes of each JAR. I ask this because I do not see how to create an instance of one of those classes the traditional way, SomeClass var = new SomeClass(). I am pretty sure that someone out there has done this and succeeded in doing it. All of the post on this stuff only talk about loading the class from a JAR file, but I have already loaded them using URLClassLoader�s findClass() method. I have also created an instance of the class that findClass() returns using newInstance(), but newInstance() returns an object of type Object. How can I convert this object to an object of type SomeClass? You cannot cast it because the compiler will complain due to the import statement issue. So if you cannot include the import statement because that classpath does not exist, then how the heck would you cast the newInstance() object into a SomeClass object?

    You can cast the returned object to the type you need...that is what I do in my applet. The trick is that you must get the instance of the applets class loader (or you get a classCastException). Pay attention to this line below - that's the real key here.
    "// Get a reference to the applets own classloader"
    protected CBaseQuestionnaireFile m_BaseObject = null;// declared up front
    m_BaseObject = loadAndRunClass("com.cpm.dataentry.questionnaire.CQuestionnaireFile");// fully qualified base object
    Here is the load and run method:
       CBaseQuestionnaireFile loadAndRunClass(String classname)
          com.cpm.common.base.CBaseQuestionnaireFile questBase = null;
          Class cClass = null;
          try
             // first we open the jar file with the classes we need
             String[] aJarList = new String[10];
             // Questionnaire format file
             File fURL1 = new File(GetMainFrame().m_strQuestionnaireFileName);
             URL url1   = new URL(fURL1.toURL(),"");
             URL urlNew = new URL("jar:" + url1.toExternalForm() + "!/" );
             // Server base class directory
             String strServerDirectory = "http://" + GetMainFrame().m_strHost + "/APPLETS/";
             File fURL2 = new File(strServerDirectory);
             URL url2 = new URL(fURL2.toURL(),"");
             URL urlNew2 = new URL("jar:" + url2.toExternalForm() + "!/" );
             // Local base class directory
             String strLocalDirectory = CSystem.GetBasePath() + "/Research/bin/";
             File fURL3 = new File(strLocalDirectory);
             URL url3 = new URL(fURL3.toURL(),"");
             URL urlNew3 = new URL("jar:" + url3.toExternalForm() + "!/" );
             File fURLBase = new File(CSystem.GetBasePath() + "/Research/bin/base.jar");
             URL urlBase = new URL(fURLBase.toURL(),"");
             URL urlNewBase = new URL("jar:" + urlBase.toExternalForm() + "!/" );
             File fURLControl = new File(CSystem.GetBasePath() + "/Research/bin/controls.jar");
             URL urlControl = new URL(fURLControl.toURL(),"");
             URL urlNewControl = new URL("jar:" + urlControl.toExternalForm() + "!/" );
             File fURLUtil = new File(CSystem.GetBasePath() + "/Research/bin/utlities.jar");
             URL urlUtil= new URL(fURLUtil.toURL(),"");
             URL urlNewUtil = new URL("jar:" + urlUtil.toExternalForm() + "!/" );
             // Determine where to look
             URL[] urlList = null;
             if(GetMainFrame().m_isStandalone == false) {
                // From a browser
                CSystem.PrintDebugMessage("Running as an applet");
                if(GetMainFrame().m_bOnLineMode == true) {
                   // On line
                   CSystem.PrintDebugMessage("*** On Line Mode ***");
                   urlList = new URL[2];
                   urlList[0] = urlNew;
                   urlList[1] = urlNew2;
                else {
                   // Off line
                   CSystem.PrintDebugMessage("*** Off Line Mode ***");
                   urlList = new URL[4];
                   urlList[0] = urlNew;
                   urlList[1] = urlNewBase;
                   urlList[2] = urlNewControl;
                   urlList[3] = urlNewUtil;
              else {
                 CSystem.PrintDebugMessage("*** Stand Alone Mode ***");
                 urlList = new URL[1];
                 urlList[0] = urlNew;
    CSystem.PrintDebugMessage("Question file/path: " + GetMainFrame().m_strQuestionnaireFileName);
            // Set the wait cursor
            GetMainFrame().SetWaitCursor();
            // Get a reference to the applets own classloader
            Class myClass = getClass();
            ClassLoader appletClassLoader = myClass.getClassLoader();
            // Call our multi-jar class loader
            JarClassLoader jarLoader = new JarClassLoader(urlList,appletClassLoader);
    CSystem.PrintDebugMessage("CPM Test - passed Jar Loader" + jarLoader.toString());
             // Load the classname from the jarfile
             try
                  cClass = jarLoader.loadClass(classname);
             catch(ClassNotFoundException cnfe)
                Object[] optionsConfirm = { "Ok" };
                JOptionPane.showOptionDialog(GetMainFrame(),"Questionnaire file is either damaged or has been tampered with.", "Questionnaire File Error",
                JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, optionsConfirm, optionsConfirm[0]);
                GetMainFrame().m_strQuestionnaireFileName = "";
                // Clear the wait cursor
                GetMainFrame().ClearWaitCursor();
                return null;
             Class cSuperclass = cClass.getSuperclass();
    CSystem.PrintDebugMessage("Test Superclass type is: " + cSuperclass.toString());
             Object o = cClass.newInstance();
    CSystem.PrintDebugMessage("Test plain class type is: " + o.toString());
             // Never remove this line of code
             // without it, a crafty user could use our load routine
             // to load/and run some nasty code
             // This test makes SURE that *ONLY* questionnaires get opened
             // and their methods get called
             if(o instanceof com.cpm.common.base.CBaseQuestionnaireFile)
                // Create the object
    CSystem.PrintDebugMessage("Test Is instance of CBaseQuestionnaireFile");
    CSystem.PrintDebugMessage("CPM Test - Casting to Base Class");
                questBase = (com.cpm.common.base.CBaseQuestionnaireFile)o;
    CSystem.PrintDebugMessage("CPM Test - Getting languages from questionnaire");
                GetMainFrame().GetLanguagesFromQuestionnaire(questBase);
    CSystem.PrintDebugMessage("CPM Test - Setting locale from Questionnaire selection");
                questBase.SetQuestionnaireLocale(GetMainFrame().m_locale);
    CSystem.PrintDebugMessage("CPM Test - Initializing Questionnaire");
                questBase.Initialize();
                questBase.InitializeCards();
              else
                Object[] optionsConfirm = { "Ok" };
                JOptionPane.showOptionDialog(GetMainFrame(),"Questionnaire file is either damaged or has been tampered with.", "Questionnaire File Error",
                JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, optionsConfirm, optionsConfirm[0]);
                GetMainFrame().m_strQuestionnaireFileName = "";
                // Clear the wait cursor
                GetMainFrame().ClearWaitCursor();
                return null;
          catch (Exception e)
              exDialog.showForThrowable(e.toString(),e);
         // Clear the wait cursor
         GetMainFrame().ClearWaitCursor();
         // Set MouseListener Pointer
    //     questBase.SetMouseListenerPointer(GetMainFrame().m_mouseListener);
         return questBase;
       }

  • A Generic Class is Shared by all its Invocations

    hello all,
    i am not understanding what this means
    all instances of a generic class have the same run-time class, regardless of their actual type
    i am taking this to mean that no matter how many instances of list i create underneath it all 1 class is actually holding all my data for all instances. is this correct?
    maybe i am not clear on the definition of a runtime class.
    how does this affect my programming? will calling static methods on one instance affect the others?
    i am confused
    thanks
    ed

    i am not understanding what this means
    all instances of a generic class have the same
    run-time class, regardless of their actual typeInstances of the generic class ArrayList<E> could be for example ArrayList<Integer>, ArrayList<String>, or ArrayList<Date>. What the phrase above means is that, although the actual type of these instances is different (the types contained in the list are different), at run-time (when your program executes), they are still of the same class, namely ArrayList. This is because the compiler removes all references to the types at compile time (called type erasure). So, an ArrayList<Integer> is not another class than ArrayList<String>.
    i am taking this to mean that no matter how many
    instances of list i create underneath it all 1 class
    is actually holding all my data for all instances. is
    this correct?This is not correct. That instances of generic types have the same run-time class is not related to the data the instances contain. As mentioned by Malvolio, only static data is contained in the class (and hence shared among instances). Instance data is stored in the instance and hence can be different for every instance of a class. But this is true for all kinds of classes, not only generic ones.
    how does this affect my programming? will calling
    static methods on one instance affect the others?If the static method modifies static data of the class, this will affect other instances since static data is shared by all instances of a class. But again, this holds for all kinds of classes, not only generic ones.
    i am confusedHope you�re not anymore.
    Cheers
    Matthijs

  • Need help with generic class with comparable type

    Hi. I'm at University, and I have some coursework to do on writing a generic class which offers ordered binary trees of items which implement the comparable interface.
    I cant get the code to compile which I have written.
    I get the error: OBTComparable.java uses unchecked or unsafe operations
    this is the more detailed information of the error when I compile with -Xlint:unchecked
    OBTComparable.java:62: warning: [unchecked] unchecked call to insert(OBTType) as
    a member of the raw type OBTComparable
    left.insert(insertValue);
    ^
    OBTComparable.java:64: warning: [unchecked] unchecked call to insert(OBTType) as
    a member of the raw type OBTComparable
    right.insert(insertValue);
    ^
    OBTComparable.java:75: warning: [unchecked] unchecked call to find(OBTType) as a
    member of the raw type OBTComparable
    return left.find(findValue);
    ^
    OBTComparable.java:77: warning: [unchecked] unchecked call to find(OBTType) as a
    member of the raw type OBTComparable
    return right.find(findValue);
    ^
    and here is my code for the class
    public class OBTComparable<OBTType extends Comparable<OBTType>>
      // A tree is either empty or not
      private boolean empty;
      // If the tree is not empty then it has
      // a value, a left and a right.
      // These are not used it empty == true
      private OBTType value;
      private OBTComparable left;
      private OBTComparable right;
      // Create an empty tree.
      public OBTComparable()
        setEmpty();
      } // OBTComparable
      // Make this tree into an empty tree.
      private void setEmpty()
        empty = true;
        value = null; // arbitrary
        left = null;
        right = null;
      } // setEmpty
      // See if this is an empty (Sub)tree.
      public boolean isEmpty()
      { return empty; }
      // Get the value which is here.
      public OBTType getValue()
      { return value; }
      // Get the left sub-tree.
      public OBTComparable getLeft()
      { return left; }
      // Get the right sub-tree.
      public OBTComparable getRight()
      { return right; }
      // Store a value at this position in the tree.
      private void setValue(OBTType requiredValue)
        if (empty)
          empty = false;
          left = new OBTComparable<OBTType>(); // Makes a new empty tree.
          right = new OBTComparable<OBTType>(); // Makes a new empty tree.
        } // if
        value = requiredValue;
      } // setValue
      // Insert a value, allowing multiple instances.
      public void insert(OBTType insertValue)
        if (empty)
          setValue(insertValue);
        else if (insertValue.compareTo(value) < 0)
          left.insert(insertValue);
        else
          right.insert(insertValue);
      } // insert
      // Find a value
      public boolean find(OBTType findValue)
        if (empty)
          return false;
        else if (findValue.equals(value))
          return true;
        else if (findValue.compareTo(value) < 0)
          return left.find(findValue);
        else
          return right.find(findValue);
      } // find
    } // OBTComparableI am unsure how to check the types of OBTType I am comparing, I know this is the error. It is the insert method and the find method that are causing it not to compile, as they require comparing one value to another. How to I put the check in the program to see if these two are of the same type so they can be compared?
    If anyone can help me with my problem that would be great!
    Sorry for the long post, I just wanted to put in all the information I know to make it easier for people to answer.
    Thanks in advance
    David

    I have good news and undecided news.
    First the good news. Your code has compiled. Those are warnings not errors. A warning is the compiler's way of saying "I understand what you are asking but maybe you didn't fully think through the consequences and I just thought I would let you know that...[something] "
    In this case it's warning you that you aren't using generics. But like I said this isn't stopping it from compiling.
    The undecided news is the complier is warning you about not using generics. Are you supposed to use generics for this assignment. My gut says no and if that's true then you have no problem. If you are supposed to use generics well then you have some more work.

  • BizProcException: BPE027 Could not get an instance for 'Callable'-class

    Hi Experts...
    I have so much troubles with the implementation of the  "Java Class Atom"...
    My Scenario doesn't work because i don't have any idea how to use this atom.
    Can you help me to implement my Java class...i had read the documentation
    but the atom does not work...put here mi java class code
    package Hola;
    import java.util.regex.Pattern;
    import java.util.Enumeration;
    import com.sap.b1i.bizprocessor.*;
    import java.sql.Connection;
    public abstract class Hola implements Callable{
         public Hola(){ }
         public boolean call(java.util.Properties inProps, BizProcMessage inMsg, java.util.Properties outProps, BizProcMessage outMsg, java.sql.Connection conn, java.lang.String jobID) throws Exception{
           try{
                String ret = null;
                ret = "Call Response in outprop ";  
                outProps.setProperty("clsprop", ret);
                return false;
           catch (Exception e){
                throw new Exception("Error");
      public boolean isThreadSafe() {return false;}
      public boolean usesJDBC() {return false;}
      public void mustDestroy(){}
      public static void main(String[] args){
    I have the suspect of the error is on my code, but i'm not sure.
    Thank you very much.
    Best Regards.
    Enrique

    Well I found this under Control Center -> Development -> BPC Reference
    User defined Java-Classes for the Call-Atom via the 'Callable' interface
    com.sap.b1i.bizprocessor.Callable
    This interface must be implemented by classes intended to be called by the B1iBizProcessor via the Call-Atom. Instances of these classes are subject of internal pooling if they do not indicate after a usage that they should be destroyed. In order to be able to create them internally in a generic way, they have to implement a parameterless initializer !!!
    I just searched the entire BizStore for com.sap.b1i.bizprocessor.Callable but was unable to find it. 
    I also searched Google for com.sap.b1i.bizprocessor.Callable and it only come up with my posts.
    I also searched the SAP Partner Portal, and SAP SDN with no avail.
    Is this functionality only for internal SAP use?

  • Creating instance of generic type

    Hi.
    Here is my class
    public class ManagerForm<M extends Stuff>{
    private Class<M>clazz;
    private M manager;
    public void setWorker(M manager){
    this.manager=manager;
    public M getWorker(){
    return this.manager;
    private final Class<M> getGenericClass() {
    Class<M> persistentClass = null;
    Type genericType = getClass().getGenericSuperclass();
    if (genericType instanceof ParameterizedType) {
    ParameterizedType pType = ((ParameterizedType) genericType);
    // obtaining first generic type class
    persistentClass = (Class<M>) pType.getActualTypeArguments()[0];
    return persistentClass;
    public ManagerForm(){
    this.clazz=getGenericClass();
    this.manager=this.clazz.newInstance();
    In default constructor I need to inicialize U instance this.user.
    I have an nullPointerException in line this.manager=this.clazz.newInstance();
    persistantClass is returned nullable because genericType is not instance of ParameterizedType.
    Could anybody say me what is wrong or propose other methods to create generic instance. I need help. Will be very appreciable.
    Thanks in advance.

    YoungWinston wrote:
    877715 wrote:
    Could anybody say me what is wrong or propose other methods to create generic instance. I need help. Will be very appreciable. I think you need to back up and explain exactly what you're trying to do here.
    It would appear that you're attempting to divine the actual type of a specific ManagerForm, but I'm not absolutely certain. Also, since you already specify the type as a field, why can't you just usemanager.getClass()? I suspect that all you'll get from getClass().getGenericSuperclass() is 'Stuff', but I have to admit I'm no expert on this.
    Far better to describe what you want than an implementation that plainly doesn't work.
    WinstonWell. I have class ManagerForm<M extends Stuff>. there is private field manager that have generic type M. And I need to instantinate manager in default constructor.
    I cant write
    public ManagerForm(){
    this.manager=new M();//will be compiler error
    Thats why exists a mechanism to get current generic type in runtyme through ParameterType.
    I have method getGenericClass that gets current class in runtime and then I create an instance of this class through <class>.newInstance(); And this is the standard way to instantinate generic type.
    I hoped line Type genericType = getClass().getGenericSuperclass(); of method returned ParameterizedType. But variable genericType cannot be casted to ParameterizedType. I don't know why. So I cannot get current generic param M and instantiate its.

  • Making a generic class that uses interfaces.

    I've learned how to do this:
    class MyClass<T extends Object> {
    }But I want a generic class that takes objects that implement another object like this:
    class MyClass<T implements Runnable> {
    }Why doesn't this work? Is there any way to do this?

    happypigface wrote:
    Yes thank you. Thats strange that Java does that. I didn't really test it yet, but I know Runnable is an instance and eclipse doesn't have any compiling errors for it. I'm glad that you can do this. It wouldn't very useful if you could only specify that the generic class had to be a subclass, not an implementation of a class.Generics are about types rather than classes and interfaces. Hence, one specifies the supertype(s) of a Generic Parameter by using the extends keyword.
    Note, however, it's possible to extend multiple interface types but only one class type.

  • Generic class for deep cloning

    How can I write generic class for deep cloning instead of implementing cloneable for each and every object

    Yes, probably you'd need to use reflection. Though, generic deep copy brings up some issues not readily resolvable at run-time, such as, for example, does the object you want to copy refer to a shared or synchronized resource, such as a db connection? If so, by making a new, say, DBConnection object, you then take up a db connection that you really don't need or want to take up (db conns being scarce in many I.T. shops that own a limited number of Oracle or SQL Server, etc. db conn. licenses). Also, many classes these days are getting written that use "obj = classname.newInstance()" (with their constructors made private so you can't use "new SomeObject()") instead of the more commonsense and traditional "obj = new SomeObject()". [Hey, can anyone explain why it might be preferable to use "classname.newInstance()" at times over "new SomeObject()"?  I can't to this day tell why it might be better or why some hacks have started doing this.]
    I am not saying either that you couldn't do it or that you shouldn't. In fact, if you wrote a really good generic deep copy class, it may very well suit your needs 95+% of the time. It'd be a great programming exercise that would likely result in something very useful to someone somewhere (yourself included), and would get you to really learn the reflect package, time generally well-spent. I also can see how it'd be a great exercise in writing recursive calls (if for example you'd like no limit to the depth of objects created within your deep-copied object). You may need to supply a few caveats for use, such as that there's no guarantee that objects within the object to be copied that don't have public constructors can be copied, and that objects that hold other objects that are limited in availablity due to their very natures, such as db connections, may not get fully copied. Another one may be that no object can be copied as long as a thread created and run from it is executing at the time the copy is done (because you couldn't guarantee the to-be-copied object instance's data or object reference state), or that perhaps in some cases, certain kinds of method-level (ie, what's officially called by Sun, "automatic") variables declared and used within, for example, blocks of code within methods, may not have their values copied correctly if they are not visible to the reflect pkg objects (though I'd have to look into that one myself to be sure it would be an issue).
    Doing a search on "deep copy" or "deep clone" on java.sun.com as well as on the 'net reveals surprisingly little except suggestions for using object serialization to do all the dirty work for you.
    I am surprised there isn't a kind of virtual working group trading ideas on the topic and trying collaboratively to come up with a good, solid generic deep copy class as a public service for all the Java brethren. Does anyone know of one? And if not, wanna start one?

  • Using static .values() method of Enum in Generic Class

    Hi *,
    I tried to do the following:
    public class AClass<E extends Enum<E> >  {
         public AClass() {
              E[] values = E.values(); // this DOESN'T work
              for (E e : values) { /* do something */ }
    }This is not possible. But how can I access all Enum constants if I use
    an Enum type parameter in a Generic class?
    Thanks for your help ;-) Stephan

    Here's a possible workaround. The generic class isn't adding much in this case; I originally wrote it as a static method that you simply passed the class to:
    public class Test21
      public static enum TestEnum { A, B, C };
      public static class AClass<E extends Enum<E>>
        private Class<E> clazz;
        public AClass(Class<E> _clazz)
        {  clazz = _clazz;  }
        public Class<E> getClazz()
        {  return clazz;  }
        public void printConstants()
          for (E e : clazz.getEnumConstants())
            System.out.println(e.toString());
      public static void main(String[] argv)
        AClass<TestEnum> a = new AClass<TestEnum>(TestEnum.class);
        a.printConstants();
    }

  • How to convert the javasource file(*.class) to execute file(*.exe)?

    How to convert the javasource file(*.class) to execute file(*.exe)?
    thank you!

    Although i have seen a few programs (that are platform specific) that will embed a small jvm into an exe with your class file, it is generally excepted that you cannot create an executable file using java. The JAR executable file is probably the closest your going to get
    Pete

  • How can I write an instance of a class in a static variable

    Hi !
    I have an instance of a class
    Devisen dev = new Devisen();
    In an other class I have a static method and I need there the content of some variables from dev.
    public static void abc()
    { String text=dev.textfield.getText()
    I get the errormessage, that the I cannot use the Not-static variable dev in a static variable.
    I understand that I cannot reference to the class Devisen because Devisen is not static I so I had to reference to an instance. But an instance is the same as a class with static methodes. (I think so)
    Is there a possibility, if I am in a static method, to call the content of a JTextField of an instance of a class ?
    Thank you Wolfgang

    Hallo, here is more code for my problem:
    class Login {
       Devisen dev=new Devisen();
    class Devisen {
       JTextField field2;
       if (!Check.check_field2()) return; // if value not okay than return
    class Check {
       public static void check_field2()
         HOW TO GET THE CONTENT OF field2 HERE ?
    One solution ist to give the instance to the static function, with the keyword "this"
    if (!Check.check_field2(this)) return;and get the instance
    public static void check_field2(Devisen dev)BUT is that a problem for memory to give every method an instance of the class ? I have 50 fields to control and I dont want do give every check_method an instance of Devisen, if this is a problem for performance.
    Or do I only give the place where the existing instance is.
    Hmm...?
    Thank you Wolfgang

  • How to call a instance method without creating the instance of a class

    class ...EXCH_PRD_VERT_NN_MODEL definition
    public section.
      methods CONSTRUCTOR
        importing
          value(I_ALV_RECORDS) type ..../EXCH_VBEL_TT_ALV
          value(I_HEADER) type EDIDC .
      methods QUERY
        importing
          I_IDEX type FLAG
          i_..........
        returning
          value(R_RESULTS) type .../EXCH_VBEL_TT_ALV .
    Both methods are instance methods.
    But in my program i cannot created instance of the class unless i get the results from Query.
    I proposed that Query must be static, and once we get results we can create object of the class by pasing the result table which we get from method query.
    But i must not change the method Query to a static method.
    Is there any way out other than making method Query as static ?
    Regards.

    You can't execute any instance method without creating instance of the class.
    In your scenario, if you don't want to process your method of your class, you can check the instance has been created or not.
    Like:
    IF IT_QUERY IS NOT INITIAL.
      CRATE OBJECT O_QUERY EXPORTING......
    ENDIF.
    IF O_QUERY IS NOT INITIAL.
    CALL METHOD O_QUERY->QUERY EXPORTING....
    ENDIF.
    Regards,
    Naimesh Patel

Maybe you are looking for

  • Creation of Business partner from customer

    Dear Friends, I am trying to create business partner from customer thorugh T-code FLBPD1 but unable to do so. Also. whenever i create a customer, a corresponding business partner is automatically created which is not desirable. Rather system should a

  • MRP Issue

    Dear Experts, I have some confusion about MRP wizard. In MRP running wizard step 3 of 4 i checked Existing Inventory, Purchase Orders, Sales Orders and Production Orders. But in  the order recommendation report status is not considering the Open Purc

  • TS5376 iTunes will not open and errors

    I followed the instructions in the forum http://support.apple.com/kb/TS5376 but the error message I got remained and and no fix resulted.  Can anyone help?  The error message I get is, 'The procedure entry point ?fastFree@***@@YAXPAX@Z could not be l

  • Notes will not sync

    I have an original iPhone (2G?-not sure if that's the correct term, but it's a late 2007 model, 8GB) and have just updated its OS from 1.1.4 to 3.1.3 but find that my Notes will no longer sync. iTunes (v9.3) seems to stall for a moment (following the

  • Renaming a tablespace

    hi I have a tablespace and wanted to rename it: alter tablespace oldttbs rename TO newttbs; create user newttbs identified by newttbs default tablespace newttbs grant unlimited tablespace to newttbs However, I noticed that the owner is still the old