Error in extending a class

Dear All,
I have written a class by name Wood. and another program which implements this class. But, when i compile, it is not recoginzing class Wood. The code as follows:
Code:
class Wood
String type="teak";
String finish="glossy";
void showdet()
System.out.println("instance of class"+this.getClass().getName());
System.out.println("=========================================");
System.out.println("type of wood-"+type);
System.out.println("finish is-"+finish);
class Table extends Wood
int legs=4;
void show()
System.out.println("Wood type-"+type);
System.out.println("finish-"+finish);
System.out.println("legs-"+legs);
public static void main(String args[])
Table t=new Table();
t.show();
Errors are :
Can't resolve the symbol class Wood.
Can't resolve the symbol type,
Can't resolve the symbol finish,
Can any one help me how to solve these errors. PLEASE ??
With regards,
AShvini

Hi,
I have already set the class path as :
C:\WDT400\JAVAPossibly okay.
;%path%;Bad.
c:\jdk1.3-binBad
;c:\jdk1.3\libBad
;c:\jdk1.3\srcBad
;jsdk2.0\bin;jsdk2.0\lib;jsdk2.0\src;Bad, Bad, Bad.
However it appears you don't have the one directory you need--the one where Wood.java lives, or to be more precise, I think, where Wood.class gets put.

Similar Messages

  • Error while extending controller: class name is wrong or not included

    Hi All,
    I am getting this error while I port my extended controller class to the custom top and assign this controller to the page. I have made sure its the class file that is copied. The directory is correct, the permissions were given using chmod 775. There exists a soft link betwen the custom top and the oracle top as well. What else am I missing here?
    Error: oracle.apps.fnd.framework.OAException: Could not create Java class: (oracle.apps.ap.oie.entry.webui.XXEntryFlowPageCO) associated with region: (GeneralInformationPG). This is probably because the class name is wrong or not included in project.

    :( Started out with that Gyan. If i do give the path with xx. appended to it, it lets me save and when i log back in and there are no changes to the page. I go to the personalise option to find the modification has been overwritten. I was told that this is so because Oracle doesnt recognise the xx.path and since there exists a soft link already the standard path with the new controller name should work.
    i have really tried both of these options and am not sure what could be wrong. thanks for all your attempts to help. anything else i can try?

  • NoMatchingActionMethodException error when extending class

    I have a base class (BaseProcess) that extends the PageFlowController. This class has an instance of a form:
    ,FSFormBean. I also have an action method that uses this form:
    * @jpf:action
    * @jpf:forward name="success" path="../hub/HubController.jpf"
    public Forward submitNext(FSFormBean form){
    return new Forward("success");
    When I extend this class
    public class TestController extends BaseProcess
    and a JSP calls the action "submitNext", I get the following error:
    No Matching Action Method Exception. I noticed that the form (FSFormBean) is empty when this is called from the parents class. Can anyone tell me why? Is it because of the notations? There are several action methods that are used throughout my class and I trying to simply my code, how can I make this to work?
    Thanks,
    Marcelo

    Check the build directory - do a clean build - or delete following folder in your webapp directory
    build/netui/weboutput/_pageflow

  • Extending Image class and addChild errors

    I am attempting to extend the Image class to allow us to place highlights over an image that are stored in an XML file. 
    I'm extending the class and adding the highlights to a sprite.  I use the addChild() method to add the sprite to the Image class, but I get the error "addChild() is not available in this class. Instead, use addElement() or modify the skin, if you have one."
    I try to use the addElement but that gives me compile errors..
    anyone have any idea what to do?  I'm trying to copy/paste the class code here, but its not working (no idea how to make it work)

    Update to last posting,
    Since the Primtive Class is extending Group I just added TransformGroup to it. To this TransformGroup object I add 4 TransformGroup objects and it all works fine. I was able to rotate all the 4 triangles at different rates.
    This is how it looks now :-
    http://www.tzi.de/~fayyaz/2.bmp
    Now I just want to shift the centre of rotation of all the triangles to the center and rotate the TOP and Bottom triangles along the x-axis.
    Assume I just have to add these operations to a TransformGroup above a single shape which is a single triangle. How do I do it. I know the answer is really simple but it beats me.
    Thanx in advance.

  • Extended a class, getting a class cast error

    Hi all,
    I'm writing a program that uses a closed-source jar in its library (with permission, of course).
    One of the classes in that jar wasn't working as I wanted it to, so I extended the class and overwrote one of its methods. So, when using the class, instead of callingThirdPartyClass obj = new ThirdPartyClass();I could useMyThirdPartyClass obj = new MyThirdPartyClass();This seems to work, until a certain line of their code throws a class cast exception:
    java.lang.ClassCastException: org.thirdparty.ThirdPartyClass$2
         at org.thirdparty.Event.findTop(Event.java:279)
         at org.thirdparty.ThreadUtils$4.run(ThreadUtils.java:86
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
        ....Why does this occur? Surely, since MyThirdPartyClass is a child of ThirdPartyClass, anything that expects a ThirdPartyClass shouldn't have any problem, right? Or do I have that backwards? And if so, is there anything I can do to fix the problem?
    Thanks!
    Sam

    paulcw wrote:
    Specifically, the ThirdPartyClass itself was an extension of a JApplet. Since I wanted to use it directly in my code, I couldn't set the applet's parameters, so I overwrote the getParameters(String) method to return strings of my choosing.Your approach makes little sense to me. Applets follow a well-defined lifecycle. If you wanted to embed the applet into your own application, all you have to do is use the applet following its lifecycle (that is, instantiate it, set the context, invoke init and start and stop and destroy). Overriding anything should not be necessary.That's exactly what I want to do. However, the applet requires one parameter to be set (DefaultModel = some url) -- if this isn't set I can't run the applet. As far as I can tell (and I have an as-yet unanswered question in the Applets forum asking about this), there is no way to set the parameters in an Applet in any way besides putting in in the 'param' tag in the Applet code in the HTML.
    If I'm wrong about that, please let me know.
    On the assumption that I was right, I decided to extend the getParameters(String) method, so that it would return the desired String when asked. Naturally, to do this, I had to extend the entire class.
    This solved the problem of the program failing when it asked for the parameter, but then it failed when it checked the codebase. I overrode the getCodeBase() method, and the applet no longer had a problem there.
    Then I got the exceptions I got above.
    I'm fairly certain (but, naturally, not 100% certain of anything) that neither of my methods should have affected the inner-workings of LiteApplet -- I was overriding methods that were from Applet (and not overridden in LiteApplet, I checked) that are just supposed to pass back strings -- the same Strings that would be passed back if it were embedded in a web page -- and not affect the applet in any way.
    Naturally, I'm wrong about one or more of my assumptions above, but I just can't work out how overriding those two methods could have created the error that I'm getting.
    Sam
    PS: Here is the entire exception, if you think it could help. I was scrubbing it merely so as not to confuse matters and make my posts overly long. The last exception below gets repeated indefinitely.
    AutoConverter.runVisitor() failed: CREATE-SUN expected 2 inputs, a number and a command block (optional).
    java.lang.NullPointerException
         at org.nlogo.swing.OptionDialog.show(OptionDialog.java:36)
         at org.nlogo.window.GUIWorkspace$11.handleError(GUIWorkspace.java:1125)
         at org.nlogo.compiler.AutoConverter.convert(AutoConverter.java:161)
         at org.nlogo.window.ProceduresLite.handleLoadSectionEvent(ProceduresLite.java:44)
         at org.nlogo.event.LoadSectionEvent.beHandledBy(LoadSectionEvent.java:38)
         at org.nlogo.event.Event.doRaise(Event.java:215)
         at org.nlogo.event.Event.raise(Event.java:116)
         at org.nlogo.window.ModelLoader.loadHelper(ModelLoader.java:76)
         at org.nlogo.window.ModelLoader.load(ModelLoader.java:45)
         at org.nlogo.window.LiteApplet.go(LiteApplet.java:128)
         at org.nlogo.window.LiteApplet$1.run(LiteApplet.java:26)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    java.lang.ClassCastException: org.nlogo.window.CompilerManager
         at org.nlogo.event.Event.findTop(Event.java:279)
         at org.nlogo.event.Event.doRaise(Event.java:190)
         at org.nlogo.event.Event.raise(Event.java:116)
         at org.nlogo.window.CompilerManager.compileAll(CompilerManager.java:68)
         at org.nlogo.window.CompilerManager.handleLoadEndEvent(CompilerManager.java:61)
         at org.nlogo.event.LoadEndEvent.beHandledBy(LoadEndEvent.java:11)
         at org.nlogo.event.Event.doRaise(Event.java:215)
         at org.nlogo.event.Event.raise(Event.java:116)
         at org.nlogo.window.ModelLoader.loadHelper(ModelLoader.java:115)
         at org.nlogo.window.ModelLoader.load(ModelLoader.java:45)
         at org.nlogo.window.LiteApplet.go(LiteApplet.java:128)
         at org.nlogo.window.LiteApplet$1.run(LiteApplet.java:26)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    java.lang.ClassCastException: org.nlogo.window.LiteApplet$2
         at org.nlogo.event.Event.findTop(Event.java:279)
         at org.nlogo.event.Event.doRaise(Event.java:190)
         at org.nlogo.event.Event.raise(Event.java:116)
         at org.nlogo.window.GUIWorkspace$6.run(GUIWorkspace.java:660)
         at org.nlogo.window.ThreadUtils$2.run(ThreadUtils.java:37)
         at org.nlogo.window.ThreadUtils$4.run(ThreadUtils.java:86)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

  • LoadClass    (error loading a class which extends other class  at run-time)

    Hey!
    I'm using the Reflection API
    I load a class called 'SubClass' which exists in a directory called 'subdir' at run-time from my program
    CustomClassLoader loader = new CustomClassLoader();
    Class classRef = loader.loadClass("SubClass");
    class CustomClassLoader extends ClassLoader. I have defined 'findClass(String className)' method in CustomClassLoader.
    This is what 'findClass(String className)' returns:
    defineClass (className,byteArray,0,byteArray.length);
    'byteArray' is of type byte[] and has the contents of subdir/SubClass.
    the problem:
    The program runs fine if SubClass does not extend any class.
    If however, SubClass extends another class, the program throws a NoClassDefFoundError. How is it conceptually different?
    Help appreciated in Advance..
    Thanks!

    Because i'm a newbie to the Reflection thing, i'm notI don't see reflection anywhere. All I see is class loading.
    sure what role does the superclass play when i'm
    trying to load the derived class and how to get away
    with the errorWell... hint: all the superclass's stuff is not copied into the subclass.
    I am quite sure it fails to load the superclass because of classpath issues.

  • How to map a custom enum list to a custom form property in an extended incident class

    Hi,
    I'm struggeling to understand how to map a custom enum list to a custom form property in an extended incident class.
    Here's what i want to have happen:
    I am going to publish a request offering on my SMPortal for allowing users to submit basic IT incidents. I want the form to include "Whom does this problem affect" (answers(This is the custom enum list): Me, Multiple Users, Whole department or Whole
    company), "What is the problem about", "Description" and "Attachments".
    Here's what i've done:
    In the authoring tool i created a MP for the custom enum list and put only the list in it. I sealed the MP and imported it.
    I created another unsealed MP called TST.Incident.Library for storing incident library customizations and extended the incident class to add an extension class i called ClassExtension_Affected scope with a custom property i called AffectedScope. Then i am trying
    to set the datatype of this property to "list". In the "select a list" dialog i cannot chose my previously sealed MP with the custom enum list in it. Why?
    - Do i need to scratch the sealed MP and put the custom enum list in the latter TST.Incident.Library MP instead?
    - If so, can i do that and keep this MP unsealed, or will i get an error on import saying "Unsealed management packs should not contain type definitions"
    - Should i create one sealed MP for both the custom enum list and the extension class + custom property?

    Hi,
    Authoring Tool simply isn't informed about your list. Open the sealed management pack where you define the root of the list in the Authoring Tool and in the same time open TST.Incident.Library. You will have two opened MPs in the Authoring
    Tool and be able to add a custom list for your custom field.
    Cheers,
    Marat
    Site: www.scutils.com  Twitter:
      LinkedIn:
      Facebook:

  • JAVAMAP-Sax Parser ...............Linkage error when loading the class.

    Dear all,
    Do we have any extra things to execute the Java mapping using the Sax Parser?
    When I am executing the interface mapping ,I am getting the" Linkage error when loading the class" error.
    Kindly let me know your personnel maildId so that I can mail you the screen shots.
    Thanks,
    Srinivasa

    Dear sunil,
    Find the File.
    Source:
    <MTO_FTP_MAT_DETAILS>
    <MATDETAILS>
    <MAKTX>
    <MATNR>
    <WERKS>
    <LABST>
    <MEINS>
    <PERCNT>
    TARGET
    MTI_FTP_MAT_DETAILS
    <MATDETAILS>
    <MAKTX>
    <MATNR>
    <WERKS>
    <LABST>
    <MEINS>
    <PERCNT>
    Source:
    <MTO_FTP_MAT_DETAILS>
    <MATDETAILS>
    <MAKTX>
    <MATNR>
    <WERKS>
    <LABST>
    <MEINS>
    <PERCNT>
    TARGET
    MTI_FTP_MAT_DETAILS
    <MATDETAILS>
    <MAKTX>
    <MATNR>
    <WERKS>
    <LABST>
    <MEINS>
    <PERCNT>
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.Map;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.Attributes;
    import org.xml.sax.SAXException;
    import org.xml.sax.helpers.DefaultHandler;
    import com.sap.aii.mapping.api.StreamTransformation;
    class Echo {
    public static OutputStream out;
    public class myEcho extends DefaultHandler implements StreamTransformation {
    private Map map;
    public void setParameter(Map param) {
    map = param;
    public void execute(InputStream in, OutputStream out) {
    DefaultHandler handler = this;
    SAXParserFactory factory = SAXParserFactory.newInstance();
    try {
    SAXParser saxParser = factory.newSAXParser();
    Echo.out = out;
    saxParser.parse(in, handler);
    } catch (Throwable t) {
    t.printStackTrace();
    public void startDocument() throws SAXException {
    try {
    Echo.out.write("<?xml version='1.0' encoding='UTF-8'?>".getBytes());
    } catch (IOException e) {
    e.notify();
    public void endDocument() throws SAXException {
    try {
    Echo.out.flush();
    } catch (IOException e) {
    throw new SAXException("I/O error", e);
    public void startElement(String namespaceURI, String sName, // simple name
    String qName, // qualified name
    Attributes attrs) throws SAXException {
    String eName = sName; // element name
    if ("".equals(eName))
    eName = qName; // not namespace-aware
    if ("ns0:MTO_SAP_MAT_DETAILS".equals(qName)) {
    try {
    Echo.out.write(("<MTI_FTP_MAT_DETAILS>").getBytes());
    } catch (Exception e) {
    e.printStackTrace();
    } else {
    try {
    Echo.out.write(("<" + qName + ">").getBytes());
    } catch (Exception e) {
    e.printStackTrace();
    public void endElement(String namespaceURI, String sName, // simple name
    String qName // qualified name
    ) throws SAXException {
    String eName = sName; // element name
    if ("".equals(eName))
    eName = qName; // not namespace-aware
    if ("ns0:MTO_SAP_MAT_DETAILS".equals(qName)) {
    try {
    Echo.out.write(("</MTI_FTP_MAT_DETAILS>").getBytes());
    } catch (Exception e) {
    e.printStackTrace();
    } else {
    try {
    Echo.out.write(("</" + qName + ">").getBytes());
    } catch (Exception e) {
    e.printStackTrace();
    public void characters(char buf[], int offset, int len)
    throws SAXException {
    String s = new String(buf, offset, len);
    try {
    Echo.out.write(s.getBytes());
    } catch (Exception e) {
    e.printStackTrace();

  • How to extend a class in same package

    I have a class called LoginBean.java which extends the class ConnectDB.java
    this both files have a statement both the classes are under the directory pmtools.
    and both are included in package pmtools.
    (they both have statement "package pmtools; " at top)
    when i am trying to compile LoginBean.java, it is giving me following error,
    LoginBean.java:7: cannot resolve symbol
    symbol : class ConnectDB
    location: class pmtools.LoginBean
    public class LoginBean extends ConnectDB
    ^
    LoginBean.java:59: cannot resolve symbol
    symbol : variable dbConn
    location: class pmtools.LoginBean
    stmt = dbConn.createStatement();
    ^
    2 errors

    did you compile the other class already? donnow if ithahahaha!!!!!
    ok include the import statement
    import pmtools.ConnectDB;
    in the second class and than compile..

  • Implemenet/Extend interface/class in default package

    Filename: DeaultInterface.java
    public interface DefaultInterface {
        // Abstract Methods...
    Filename: ConcreteClass.java
    package com.company;
    import DefaultInterface;
    public class ConcreteClass implements DefaultInterface {
        // Implementation of Abstract Methods...
    }When I compile above java code it gives error "cannot find symbol. symbol: class DefaultInterface".
    Can anyone explain why can't we implement the interface/extend the class in default package(no package)?
    Edited by: 974531 on Dec 2, 2012 11:07 PM

    >
    When I compile above java code it gives error "cannot find symbol. symbol: class DefaultInterface".
    Can anyone explain why can't we implement the interface/extend the class in default package(no package)?
    >
    You CAN implement the interface defined in the default package.
    What you CANNOT do is import it. And that is because the Java Language Specification specifies that named types can only be referenced by their simple name if they are imported and must otherwise be referenced by their fully qualified name.
    See the 7.5 Import Declarations in the Java Language Specification - http://docs.oracle.com/javase/specs/jls/se7/html/jls-7.html
    >
    An import declaration allows a named type or a static member to be referred to by a simple name (§6.2) that consists of a single identifier.
    Without the use of an appropriate import declaration, the only way to refer to a type declared in another package, or a static member of another type, is to use a fully qualified name (§6.7).
    A type in an unnamed package (§7.4.2) has no canonical name, so the requirement for a canonical name in every kind of import declaration implies that (a) types in an unnamed package cannot be imported, and (b) static members of types in an unnamed package cannot be imported. As such, §7.5.1, §7.5.2, §7.5.3, and §7.5.4 all require a compile-time error on any attempt to import a type (or static member thereof) in an unnamed package.
    >
    So you can't reference that type by importing it because you can't import a type that doesn't have a canonical nmae. And you can't just use the simple name because, as the first statement above says you have to import it to use the simple name.
    When you use the simple name of that type without an import the simple name would refer to a class IN your 'com.company' named package.

  • Extending abstract classes

    I just have a simple question. I have one class which is abstract
    public abstract class Person
         private String firstName;
         private String lastName;
         private String title;
         private String dateOfBirth;
         private String homeAddress;
         private String phoneNumber;
         public static final String MR = "Mr";
         public static final String MISS = "Miss";
         public static final String MS = "Ms";
         public static final String MRS = "Mrs";
         public static final String DR = "DR";
         public static final String PROF = "Prof";
         public Person(String firstName, String lastName, String title, String dateOfBirth,
                         String homeAddress, String phoneNumber){
              this.firstName=firstName;
              this.lastName=lastName;
              this.title=title;
              this.dateOfBirth=dateOfBirth;
              this.homeAddress=homeAddress;
              this.phoneNumber=phoneNumber;
         And i have another class which extends this class
    public abstract class Borrower extends Person{
      public LibraryItem [] itemsBorrowed;
      private double currentFine;
      private int barCode;
      public LibraryItem [] getItemsBorrowed()
           return itemsBorrowed;
      public double getCurrentFine()
           return currentFine;
      public int getBarCode()
           return barCode;
      }When i try to compile these two classes, i get the error
    Cannot find symbal constructor Person(). The problem is that the tutor hates us providing default constructors, and i presume that this is what the error is asking for. Is there any way around this or does a default constructor need to be povided?
    cheers

    codingMonkey wrote:
    georgemc wrote:
    nick2price wrote:
    Ok, i get you, better call the superclass constructor as tutor hates me using no param constructorsChallenge him on that. Not only are they perfectly acceptable, they're a mandatory part of the JavaBeans spec.Personally, even though there are nothing wrong with them, I prefer to avoid no-arg constructors in a lot of cases. Usually when I feel that a class should always have certain attributes. I.e. instead of having a no-arg constructor for something like a Person class, I'd rather have a constructor that takes at least a name. It is true that the name could always be initialized in the no-arg constructor, but I would think that it makes more sense for a person to always have a name, rather than being called "null" or "N/A".If you plan on using any framework that uses the Beans spec (and while the inexperienced, self-professed "purist" might balk at that, you'll find it virtually impossible to avoid as a commercial coder) you won't be able to with those classes. Your argument about always needing a sensible starting point falls down where you have multiple disparate types that you are re-constructing. While it's quite nice to say "a Person should always have a Name", if you have, for example, a persistence framework that will generically map the results of various database queries back onto Java objects, you have to write some special case code for each class in your domain model, that says "in order to contruct this object, you first need to perform this query, then invoke this constructor with this part of the result of that query, then populate the rest of the properties using setter methods". For every class in your domain model. That's a fair amount of overhead. The no-args constructor model completely circumvents that, since everything's populated by the same generic code - beans introspection. Think about it. For every class in your model, you have to have separate chunks of code that are aware of - and hence, coupled to - a specific query, and a specific constructor of a specific class. Far from ideal.
    Even if you decide to roll your own code to manage peristence, configuration, remoting and the like, you'll still eventually settle on no-args constructors as extremely handy tools. Note that I'm all for the presence of other constructors as well, that do allow sensible creation of objects with certain values. Just that the no-args constructor is so infinitely useful for writing a huge amount of generic code
    I would think that it makes more sense for a person to always have a name, rather than being called "null" or "N/A".Me too. And there's nothing in any of my points that gainsays, or opposes that. You create a Person instance, and he's called "null" for a few clock cycles before you populate him from a database query - nothing wrong with that

  • Extending a class

    I am writing 3 files for a homework assignment and two of them extend the last one. WHen i compile the last I get no prob. When I compile the other two I get the cannot resolve symbol error. I have all three files in the same folder. What do I need to do to have the other two recognize and properly extend the class.

    when I say javac yourfile.java -classpath=%CLASSPATH%;C:\yourfolder
    I get Bad command or file name error. I tried just setting classpath=%classpath% and I still get Bad command or file name error. It only works if I use set classpath=%classpath%.

  • Extending a class (newbie)

    I'm very new to Java. I'm making use of custom web classes from a proprietary application.
    I want to write my own class by extending another class. My class need to do exactly what the super class does. The super class extends another class.
    Here is how it looks,
    MY CLASS:
    public RmCopyCommand extends DwCopyCommand
    THE SUPER CLASS:
    public DwCopyCommand extends DwDocbaseCommand
    The super class, DwCopyCommand, has four methods defined (plus many inherited). To make my class, RmCopyCommand, mimic the super class, I did the following:
    1. I made a constructor
    RmCopyCommand()
                   super();
    2. I duplicated the methods
    public boolean hasTransaction()
                   return super.hasTransaction();
    I did the above to all four methods defined in the super class. I also used TRY...CATCH blocks where necessary. The source compiled.
    Off course, this doesn't work. I got a nullPointerException error. What I want to do is use the exact functionality of DwCommand, but write another method that makes a call to an inherited method.
    Could anyone tell me what I might be doing wrong?
    I hope I included enough details. If you need further details, let me know.
    Thanks,
    Moshe

    Lets go through this point by point:
    I'm very new to Java. I'm making use of custom web
    classes from a proprietary application.
    I want to write my own class by extending another
    class. My class need to do exactly what the super
    class does. The super class extends another class.Does you class really need to do exactly what the super class does? If the super class has everything you need why are you subclassing it.
    Here is how it looks,
    MY CLASS:
    public RmCopyCommand extends DwCopyCommandThe above statement is all you need followed by {} according to your description.
    THE SUPER CLASS:
    public DwCopyCommand extends DwDocbaseCommand
    The super class, DwCopyCommand, has four methods
    defined (plus many inherited). To make my class,
    RmCopyCommand, mimic the super class, I did the
    following:
    1. I made a constructor
    RmCopyCommand()
    super();
    }You only need to do this for constructors with arguments. If you don't create a default constructor, one is created for you. Also if you don't call super() in your constructor it will automatically before anything else is executed.
    2. I duplicated the methods
    public boolean hasTransaction()
    return super.hasTransaction();
    }This is unneccesary. By subclassing a class all its public and protected members are part of the sub class.
    I did the above to all four methods defined in the
    super class. I also used TRY...CATCH blocks where
    necessary. The source compiled.
    Off course, this doesn't work. I got a
    nullPointerException error. What I want to do is use
    the exact functionality of DwCommand, but write
    another method that makes a call to an inherited
    method.Nothing that you have stated here would cause that.
    Could anyone tell me what I might be doing wrong?
    I hope I included enough details. If you need further
    details, let me know.
    Thanks,
    Moshe

  • Extending a class through inner anonymous class??

    What kind of construction is this?
    SomeClass sc = new SomeClass()
                      public void sayHello()
                        System.out.println("Hello");
              };I thought this is equal to sc extends SomeClass, and this is what the decompiled inner class tells. Anyhow I don't think this is the same as extending a class cause you can only overwrite methods which are declared/implemented in SomeClass, adding new methods doesn't make sense to compiler. If in the example above SomeClass doesn't contain sayHello method
    sc.sayHello();
    will result in compiler error message.

    The compiler error is because you are calling the method via a reference of type SomeClass, not a reference of the type of the anonyomous class you have created. If you need to do that, then use a named class.
    You can have any number of methods in an anonymous class, but you will only be able to call them from within the class itself unless they are declared in the superclass or super-interface.

  • Extend ShoppingClientHelper.class

    Does anyone knows how to extend ShoppingClientHelper.class.
    I create a class xxShoppingClientHelper extend ShoppingClientHelper and method addToReqs. I want the system to process the original logic in addToRegs first then the extended addToReqs. But I get compilation error that 'super cannot be reference from a static context'. Does this means I can not extend the ShoppingClientHelper.class since all methods in the class are static.
    Regards
    Lawrence

    Hi,
    Here is a start (not compiled, not tested):
    public class TwoValuedInteger {
        // Refer to these to avoid allocation of new objects
        // (just like Boolean.TRUE/Boolean.FALSE)
        public static TwoValuedInteger ZERO = new TwoValuedInteger(0);
        public static TwoValuedInteger ONE  = new TwoValuedInteger(1);
        private int value;
        public TwoValuedInteger(int v) {
            if (v != 0 && v != 1)
                throw new IllegalArgumentException();
            this.value = v;
        public String toString() {
            return value == 0 ? "0" : "1";
        public boolean equals(Object obj) {
            if (obj == null)
                return false;
            if (!(obj instanceof TwoValuedInteger))
                return false;
            return ((TwoValuedInteger)obj).value == value;
    }Regards,
    S&oslash;ren Bak

Maybe you are looking for