The use of "super" in a constructor

Hi,
I am wondering what using "super();" in a constructor does. I've seen this used in may other people's code and I simply don't understand what that line would do.
Thanks for your advice.

the super class being that class which you have derived from.
Example:
Base Class
public class Amphibian
Amphibian();
System.out.println("Constructor of Amphibian");
public swims()
//swim
<b>SubClass</b>
public class Frog extends Amphibian
Frog()
super(); // this calls constructor of Amphibian and will print out: Constructor of Amphibian to the console
I hope this helps

Similar Messages

  • Not getting the use of 'this' keyword in constructor as shortcut approach.

    class Box{
    int width;
    int height;
    int depth;
    Box(){ //no-arg constructor
    Width =1;
    Height = 2;
    Depth = 3;
    Box(int width){
    this.width = width;
    height = 2;
    depth = 3;
    Box(int width, int height){
    this.width = width;
    this.height = height;
    depth = 3;
    /*Box(int width, int height, int depth){
    this.width = width;
    this.height = height;
    this.depth = depth;
    *//short cut approach*
    *Box(int width, int height, int depth){*
    this(width, height); //calls matching constructor from the same class
    this.depth = depth;
    Box(Box b){
    this.width = b.width;
    this.height = b.height;
    this.depth = b.depth;
    public class ConstructorDemo {
    public static void main(String[] args) {
    Box b1 = new Box(1,2,3);
    Box b2 = new Box(b1);
    In the above example, 'this' pointing to current object is understood but
    this(width, height); is used instead of this.width=width; this.height=height;
    how can it be shortcut when we have declared constructors ? And really how its so useful in a big code?
    Edited by: 1010533 on Jun 7, 2013 12:54 PM

    Welcome to the forum!
    >
    class Box{
    int width;
    int height;
    int depth;
    Box(){ //no-arg constructor
    Width =1;
    Height = 2;
    Depth = 3;
    Box(int width){
    this.width = width;
    height = 2;
    depth = 3;
    Box(int width, int height){
    this.width = width;
    this.height = height;
    depth = 3;
    /*Box(int width, int height, int depth){
    this.width = width;
    this.height = height;
    this.depth = depth;
    //short cut approach
    Box(int width, int height, int depth){
    this(width, height); //calls matching constructor from the same class
    this.depth = depth;
    Box(Box b){
    this.width = b.width;
    this.height = b.height;
    this.depth = b.depth;
    public class ConstructorDemo {
    public static void main(String[] args) {
    Box b1 = new Box(1,2,3);
    Box b2 = new Box(b1);
    In the above example, 'this' pointing to current object is understood but
    this(width, height); is used instead of this.width=width; this.height=height;
    how can it be shortcut when we have declared constructors ?
    >
    Shortcut? Who said it is a shortcut?
    >
    And really how its so useful in a big code?
    >
    EXTREMELY useful - especially in 'big code' (whatever you mean by that).
    Constructors are meant to create VALID instances. The business rules for creating a valid instance may not be as simple as your example.
    Ideally code should be written once and used often. The use of constructors is no different.
    Once you have a contructor for a given set of arguments you should use it if you need to construct an instance like that.
    So when you need a constructor that uses those same arguments and then some additional ones your new constructor should call the existing constructor and should then apply the new logic needed for the new constructor.
    That is important because it means that the business logic needed for those two arguments is only implemented in ONE place. That logic might be very complicated and there is no valid reason to duplicate it.
    Once you have a piece of code that works reuse it whenever possible.

  • Use of "super" key word in abap oops...

    Hi,
      Can any one explain me what is the use of ' super ' key word in abap oops. excluding super class.
    With Regards,
    M.S.Amirtharaj Vijay.

    Vijay,
    please read the sap documentation or f1 help
    Thanks
    Bala Duvvuri

  • Use of super

    Hi all,
    I have some questions on the use of super keyword.
    1, Why super cannot be used to assign the super object to an instance in current object. I tried this
    Class a
    Class b extends a
    in b
    a var = super;
    2, Is it possible to access the super class of a super class
    a , b extends a, c extends b.
    from c
    super.super.getClass();
    Antony Paul

    1) Because it's not really a separate object. You can do this in b:
    a var = this;
    Since b extends a, any object that is a b is also an a.
    2) Yes, but not that way. You can't chain supers together.
    Class thisClass = this.getClass(); // c
    Class superClass = this.getClass().getSuperclass(); // b
    Class superSuperClass = this.getClass().getSuperclass().getSuperclass(); // a
    or
    Class thisClass = this.getClass(); // c
    Class superClass = thisClass.getSuperclass(); // b
    Class superSuperClass = superClass.getSuperclass(); // a

  • What is the significance of super() in constructor?

    excuse me, my english is poor.
    public class App2 extends App1{
    App2(String str){
    //there is a crytic super() *****why?****
    System.out.println(str);
    public static void main(String args[]){
    App2 tt=new App2("hello");
    class App1{
    App1(){
    System.out.println("App1 constructor");
    //end progarm
    why there is a crytic super()?
    What is the significance of super() in constructor?

    "public class App2 extends App1"
    implies that App2 inherits something from App1.
    e.g.
    App1 has member data a1, b1, c1 and App2 add its own member data a2, b2, c2. Since App2 extends App1, now App2 has member data a1, b1, c1, a2, b2, c2.
    If you call App2's constructor, you can initialize a2, b2, c2. How about a1, b1, c1? If you don't use super in App2's constructor, a1 b1 c1 won't be initialized. So, call super to let App1 initialize a1, b1 and c1.

  • I have a new mac book pro System Version: OS X 10.9.4 just one week old. When i play games using chrome the mac gets super hot and in the middle and the bottom. I had to return a mac last week because of this and got a new one replaced. But it still

    I have a new mac book pro System Version: OS X 10.9.4 just one week old. When i play games using chrome the mac gets super hot and in the middle and the bottom. I had to return a mac last week because of this and got a new one replaced. But it still

    I ran the diagnostics suggested in Macbook Pro Running Slow and Overheating, High kernel_task CPU Usage. Results below. Any help would be great.
    System Version: OS X 10.9.4 (13E28) 
    Kernel Version: Darwin 13.3.0
    Boot Mode: Normal
    Model: MacBookPro11,1
    USB
       Dell USB Optical Mouse (Dell Inc.)
    System diagnostics
       2014-09-20 PluginProcess spin
       2014-09-20 PluginProcess spin
       2014-09-20 iTunes spin
       2014-09-22 PluginProcess spin
       2014-09-22 PluginProcess spin
       2014-09-25 PluginProcess spin
       2014-09-26 Google Chrome spin
       2014-09-26 Google Chrome spin
    User diagnostics
       2014-09-20 CalendarAgent crash
       2014-09-22 DashboardClient crash
    Kernel messages
       Sep 26 17:21:23   IOPPF: Sent gpu-internal-plimit-notification last value 4 (rounded time weighted average 4)
       Sep 26 17:21:35   IOPPF: Sent cpu-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:21:35   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 3 (rounded time weighted average 3)
       Sep 26 17:21:35   IOPPF: Sent gpu-internal-plimit-notification last value 3 (rounded time weighted average 3)
       Sep 26 17:21:47   IOPPF: Sent cpu-plimit-notification last value 8 (rounded time weighted average 7)
       Sep 26 17:21:47   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 3 (rounded time weighted average 3)
       Sep 26 17:21:47   IOPPF: Sent gpu-internal-plimit-notification last value 3 (rounded time weighted average 3)
       Sep 26 17:22:01   IOPPF: Sent cpu-plimit-notification last value 5 (rounded time weighted average 7)
       Sep 26 17:22:01   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 2 (rounded time weighted average 3)
       Sep 26 17:22:01   IOPPF: Sent gpu-internal-plimit-notification last value 2 (rounded time weighted average 3)
       Sep 26 17:22:21   IOPPF: Sent cpu-plimit-notification last value 10 (rounded time weighted average 9)
       Sep 26 17:22:21   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 4 (rounded time weighted average 3)
       Sep 26 17:22:21   IOPPF: Sent gpu-internal-plimit-notification last value 4 (rounded time weighted average 3)
       Sep 26 17:22:34   IOPPF: Sent cpu-plimit-notification last value 8 (rounded time weighted average 8)
       Sep 26 17:22:34   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:22:34   IOPPF: Sent gpu-internal-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:22:47   IOPPF: Sent cpu-plimit-notification last value 6 (rounded time weighted average 6)
       Sep 26 17:22:47   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:22:47   IOPPF: Sent gpu-internal-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:23:01   IOPPF: Sent cpu-plimit-notification last value 7 (rounded time weighted average 7)
       Sep 26 17:23:01   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:23:01   IOPPF: Sent gpu-internal-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:23:12   IOPPF: Sent cpu-plimit-notification last value 6 (rounded time weighted average 6)
       Sep 26 17:23:12   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:23:12   IOPPF: Sent gpu-internal-plimit-notification last value 5 (rounded time weighted average 5)
    Extrinsic daemons
       com.adobe.fpsaud
    Extrinsic agents
       com.google.keystone.user.agent
    launchd items
       /Library/LaunchDaemons/com.adobe.fpsaud.plist
        (com.adobe.fpsaud)
       Library/LaunchAgents/com.apple.FolderActions.enabled.plist
        (com.apple.FolderActions.enabled)
       Library/LaunchAgents/com.apple.FolderActions.folders.plist
        (com.apple.FolderActions.folders)
       Library/LaunchAgents/com.google.keystone.agent.plist
        (com.google.keystone.user.agent)
    Startup items
       /Library/StartupItems/TuxeraNTFSUnmountHelper/TuxeraNTFSUnmountHelper
    Extrinsic loadable bundles
       /Library/Internet Plug-Ins/Flash Player.plugin
        (com.macromedia.Flash Player.plugin)
       /Library/PreferencePanes/Flash Player.prefPane
        (com.adobe.flashplayerpreferences)
       /Library/PreferencePanes/Tuxera NTFS.prefPane
        (com.tuxera.ntfs.mac.prefpane)
       Library/Address Book Plug-Ins/SkypeABDialer.bundle
        (com.skype.skypeabdialer)
       Library/Address Book Plug-Ins/SkypeABSMS.bundle
        (com.skype.skypeabsms)
    User login items
       iTunesHelper
       Google Chrome
    Restricted user files: 45
    Elapsed time (s): 75

  • Can anyone tell me where i can get a new or used sony super drive dwu10 678-0429b in the UK, for my flat panel i mac g4  model no m9168lla , or  is there  any other compatable drives i could fit

    can anyone tell me where i can get a new or used sony super drive dwu10 678-0429b in the UK, for my flat panel i mac g4  model no m9168lla , or  is there  any other compatable drives i could fit

    Try eBay. You do occasionally see that old model advertised there.

  • I have a new mac book pro System Version: OS X 10.9.4 just one week old. When i play games using chrome the mac gets super hot and in the middle and the bottom. I had to return a mac last week because of this and got a new one replaced.

    i have a new mac book pro System Version: OS X 10.9.4 just one week old. When i play games using chrome the mac gets super hot and in the middle and the bottom. I had to return a mac last week because of this and got a new one replaced.The issue still remains

    I ran the diagnostics suggested in Macbook Pro Running Slow and Overheating, High kernel_task CPU Usage The results are below.
    System Version: OS X 10.9.4 (13E28) 
    Kernel Version: Darwin 13.3.0
    Boot Mode: Normal
    Model: MacBookPro11,1
    USB
       Dell USB Optical Mouse (Dell Inc.)
    System diagnostics
       2014-09-20 PluginProcess spin
       2014-09-20 PluginProcess spin
       2014-09-20 iTunes spin
       2014-09-22 PluginProcess spin
       2014-09-22 PluginProcess spin
       2014-09-25 PluginProcess spin
       2014-09-26 Google Chrome spin
       2014-09-26 Google Chrome spin
    User diagnostics
       2014-09-20 CalendarAgent crash
       2014-09-22 DashboardClient crash
    Kernel messages
       Sep 26 17:21:23   IOPPF: Sent gpu-internal-plimit-notification last value 4 (rounded time weighted average 4)
       Sep 26 17:21:35   IOPPF: Sent cpu-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:21:35   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 3 (rounded time weighted average 3)
       Sep 26 17:21:35   IOPPF: Sent gpu-internal-plimit-notification last value 3 (rounded time weighted average 3)
       Sep 26 17:21:47   IOPPF: Sent cpu-plimit-notification last value 8 (rounded time weighted average 7)
       Sep 26 17:21:47   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 3 (rounded time weighted average 3)
       Sep 26 17:21:47   IOPPF: Sent gpu-internal-plimit-notification last value 3 (rounded time weighted average 3)
       Sep 26 17:22:01   IOPPF: Sent cpu-plimit-notification last value 5 (rounded time weighted average 7)
       Sep 26 17:22:01   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 2 (rounded time weighted average 3)
       Sep 26 17:22:01   IOPPF: Sent gpu-internal-plimit-notification last value 2 (rounded time weighted average 3)
       Sep 26 17:22:21   IOPPF: Sent cpu-plimit-notification last value 10 (rounded time weighted average 9)
       Sep 26 17:22:21   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 4 (rounded time weighted average 3)
       Sep 26 17:22:21   IOPPF: Sent gpu-internal-plimit-notification last value 4 (rounded time weighted average 3)
       Sep 26 17:22:34   IOPPF: Sent cpu-plimit-notification last value 8 (rounded time weighted average 8)
       Sep 26 17:22:34   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:22:34   IOPPF: Sent gpu-internal-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:22:47   IOPPF: Sent cpu-plimit-notification last value 6 (rounded time weighted average 6)
       Sep 26 17:22:47   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:22:47   IOPPF: Sent gpu-internal-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:23:01   IOPPF: Sent cpu-plimit-notification last value 7 (rounded time weighted average 7)
       Sep 26 17:23:01   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:23:01   IOPPF: Sent gpu-internal-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:23:12   IOPPF: Sent cpu-plimit-notification last value 6 (rounded time weighted average 6)
       Sep 26 17:23:12   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:23:12   IOPPF: Sent gpu-internal-plimit-notification last value 5 (rounded time weighted average 5)
    Extrinsic daemons
       com.adobe.fpsaud
    Extrinsic agents
       com.google.keystone.user.agent
    launchd items
       /Library/LaunchDaemons/com.adobe.fpsaud.plist
        (com.adobe.fpsaud)
       Library/LaunchAgents/com.apple.FolderActions.enabled.plist
        (com.apple.FolderActions.enabled)
       Library/LaunchAgents/com.apple.FolderActions.folders.plist
        (com.apple.FolderActions.folders)
       Library/LaunchAgents/com.google.keystone.agent.plist
        (com.google.keystone.user.agent)
    Startup items
       /Library/StartupItems/TuxeraNTFSUnmountHelper/TuxeraNTFSUnmountHelper
    Extrinsic loadable bundles
       /Library/Internet Plug-Ins/Flash Player.plugin
        (com.macromedia.Flash Player.plugin)
       /Library/PreferencePanes/Flash Player.prefPane
        (com.adobe.flashplayerpreferences)
       /Library/PreferencePanes/Tuxera NTFS.prefPane
        (com.tuxera.ntfs.mac.prefpane)
       Library/Address Book Plug-Ins/SkypeABDialer.bundle
        (com.skype.skypeabdialer)
       Library/Address Book Plug-Ins/SkypeABSMS.bundle
        (com.skype.skypeabsms)
    User login items
       iTunesHelper
       Google Chrome
    Restricted user files: 45
    Elapsed time (s): 75

  • What is the use of constructors

    what is the use of constructors in abstract class when we cannot instantiate the class

    Double posted and answered.
    http://forum.java.sun.com/thread.jspa?threadID=740376

  • This() and super() invocations in constructor bodies

    Hi,
    Could someone please explain why it is not allowed to explicitly
    call this() or super() in a constructor body anywhere as opposed
    to the first statement in the constructor (which in turn implies that
    this() and super() can not be used together) ?
    Also, If the constructor is a constructor for an enum type, it is a compile-time
    error for it to invoke the superclass constructor explicitly. Why ?
    And the last question - why it is not allowed to invoke this() or super()
    with instance fields ?
    Cheers,
    Adrian

    AdrianSosialik wrote:
    Could someone please explain why it is not allowed to explicitly
    call this() or super() in a constructor body anywhere as opposed
    to the first statement in the constructorI think it was a language design decision. One could allow certain statements before invoking another constructor, but this would probably cause more confusion than help. So I guess it was deliberatly chosen to not allow this.
    (which in turn implies that this() and super() can not be used
    together) ?Yes, but if this would be permitted, it would also be harder to guarantee that a superclass constructor gets called exactly once.
    Also, If the constructor is a constructor for an enum type,
    it is a compile-time error for it to invoke the superclass
    constructor explicitly. Why ?Could you provide a "compilable" code snippet that demonstrates this?
    And the last question - why it is not allowed to invoke this()
    or super() with instance fields ?As you are not able to store something in them before the invocation, they contain their default values... (the JVM allows storing values in instance fields before invoking another constructor, but it was apparently decided to not include such a thing in Java)

  • HOw to create a text file in the given path and delete it after the use?

    Hi all,
    I am trying to create a text file at the given path and delete the created file after the use.
    I am using following code.:
    import java.io.*;
    // write binary data as characters
    public class RanIO {
                                            public static void main(String f[])
                                                      // First illustrate append
                                                      String lineSep = "\n";
                                                      try {
                                                                     File temp= new File("C:/Ash","cute.txt");
                                                      boolean ch=temp.createNewFile();
                                                      if(ch)
                                                           System.out.println("file created");
                                                      else
                                                      System.out.println("file Not created");
                                                      //writing to file
                                                 /*     PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter("cute.txt",true)));
                                                      p.print("Emp NO");
                                                      p.close();*/
                                                                // Open fileWriter in append mode
                                                                               FileWriter fos = new FileWriter(temp, true);
                                                                               BufferedWriter bw = new BufferedWriter(fos);
                                                                               PrintWriter pw = new PrintWriter(fos);
                                                                               double d=550;
                                                                          // lineSep = System.getProperty("line.separator");
                                                                          pw.print("Hello");
                                                                          //pw.print( lineSep );
                                                                          pw.print( d );
                                                                          pw.close();
                                  boolean det=temp.delete();
                                                 if(det)
                                                      System.out.println("File deleted");
                                                 else
                                                      System.out.println("File not deleted");
                                                 } catch (IOException ioe)
                                                                System.out.println( "Append IO error:" + ioe );
    My problem:
    1)
    I am not able to write to the file. I want to know, where i am going wrong.
    It is giving error message like
    "Canot resolve Symbol: temp,"
    But, FileWriter Constructor should accept a File type parameter.
    here temp is a file parameter.
    If i am not using file=new file();
    i can't delete the file after the use. i.e if i use
    PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter("cute.txt",true)));
    how can i delete cute.txt after the use?
    2)
    I am not able to write to the text file. file is created but, a blank file.
    "Hello" is not written into the text file.
    can anyone help me in this regard
    Thanks in advance
    Ashvini

    Thank you Ram,
    But, i want to create a text file in Append mode.
    for that i used
    FileWriter fos = new FileWriter(temp,true); But, it is not accepting FileWriter constructor in
    this format. if i use
    FileWriter fos = new
    FileWriter("c:/ash/cute.txt",true); it works fine. !!!!!Here's the javadoc
    public FileWriter(File file,
    boolean append)
    throws IOExceptionConstructs a FileWriter object given a File object. If the second argument is true, then bytes will be written to the end of the file rather than the beginning.
    Parameters:
    file - a File object to write to
    append - if true, then bytes will be written to the end of the file rather than the beginning
    Throws:
    IOException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
    Since:
    1.4
    Are you using jdk.13 or lower ?
    >
    ONe more doubt, Does flush method deletes a file?
    if not, then i need to use
    File temp=new File("c:/ash/cute.txt");
    FileWriter fos = new FileWriter(temp,true); //which
    is again a problem
    if(temp.delete())
    out.println("File is deleted");
    }I don't know whether i am taking it wrong ! or
    anything wrong with my coding ! but, after creating
    and writing data into a text file. I must delete it
    as it contains confidential informations.
    Regards,
    Thanks.'flush' writes to a file immediately. Else you should explicitly call 'flush' to write contents from buffer to underlying source.
    javadoc again
    PrintWriter
    public PrintWriter(Writer out,
    boolean autoFlush)Create a new PrintWriter.
    Parameters:
    out - A character-output stream
    autoFlush - A boolean; if true, the println, printf, or format methods will flush the output buffer
    cheers,
    ram.
    Question; What do you gain by opening a file, writing to it and deleting it in the same program ?

  • I have an older iMac 5,1 and the disc drive no longer works. I was hoping that I could the Apple USB super drive as a replacement, but the info on the super drive page says compatible with iMac 2012 or later. Does anyone know why it would not work for me?

    I have an older iMac 5,1 and the disc drive no longer works. I was hoping that I could the Apple USB super drive as a replacement, but the info on the super drive page says compatible with iMac 2012 or later. Does anyone know why it would not work for me?

    A reply to similar question (Q & As , in product page Apple Store) says:
    "...dissable the internal reader hardware from devices setup. Then plug the external usb superdrive and that's it."  Answered by Enrique T from Lima Oct  25 2013.
    If you can locate an external Apple USB 'Air" superdrive for earlier model MacBook Air, that should work. The newer one for the Air is the same as for iMac, now.
    You may be able to use other brands of external USB optical drive with your older intel-based iMac, as some of them function capably. A few should also be able to see system discs or other bootable utilities on DVD.
    Hopefully this helps.
    Good luck & happy computing!

  • HT2801 I understand there is a way to use my Super Drive with my PC.  However, it requires a System OS Disk.  Which I never received.  Can you help me with this?

    I understand there is a way to use my Super Drive with my PC.  However, it requires a System OS Disk.  Which I never received.  Can you help me with this?

    Rick6812 wrote:
      I'm using Windows 8.1. 
    I do not know what you mean by a Windows 8.1.  Please clarify.
    The Apple superdrive is designed to be used with the following Macs.
    It will not work with any other Mac unless you perform this modification;
    http://www.tuaw.com/2012/04/02/use-the-macbook-air-superdrive-with-any-almost-ma c/
    Are you trying to get it to work with a PC? 
    Ciao.

  • Use of super keyword

    Hi all , iam new to java . plz tell me what is use of super keyword

    You might read the Managing Inheritance part of the Learning the Java Language tutorial.

  • NullPointerException caused by the use of the addDoubleField method

    I develop most of my programs in BreezySwing GUI because I like the simplicity of it compared to AWT. I recently bought a new computer that I wanted to make Java equipped; just like my other two computers. I will get back to that later.
    Before I got a new computer, I made all of my programs on the first computer successfully. One of my most significant ones is a multiple conversion program developed in BreezySwing. After I made it, I wanted to make it runnable on my other computer. Using the BreezySwing jar file, the application's class file, an installed JDK, and a batch file, I now know how to make my programs work on new computers.
    Things changed when I tried to put my program on my newest computer. I moved all the necessary files (except the JDK and BreezySwing; which I downloaded again) from the original computer to my newest one. The first two computers had JDK version 7 while the newest one got JDK version 14. I made all the necessary changes to the batch file for the program (such as changing the classpath for the JDK and the class directory). However, upon running this program, Java throws a NullPointerException. This exception does not occur on either of my two other computers.
    Right away, I was determined to find the cause. I have no idea why the exception occurs, but I do know what part of the code causes the exception. By commenting out parts of a test program, I managed to find out that the use of the addDoubleField method causes the exception because it is thrown when not commented out, but it is not thrown when commented out. Here is the code for the test program:
    application: DFTest.class
    import javax.swing.*;
    import BreezySwing.*;
    class DFTest extends GBFrame {
    JTextField txtFld = addTextField("abcdefg",1,1,1,1);
    DoubleField valueFld = addDoubleField(0.0 ,2,1,1,1); /*this line causes the NullPointerException*/
    static public void main(String[] args){
    DFTest obj = new DFTest();
    obj.setSize(300,100);
    obj.setVisible(true);
    }Both my conversion program and this program use the addDoubleField method. I also tested the BreezySwing variable type DoubleField by seperating it from addDoubleField with a constructor. Java did not throw an exception for the DoubleField variable type.
    What do I need to do to get my programs working again?

    I will give one last detailed synopsis of the problem that I am having. I will do my best to include every detail and make the explanation as useful as possible.
    About a year ago I became interested in Java programming. I was learning it at school but I wanted to continue with it on my own as well. The first time I installed Java was on my first computer. I will call this computer Computer A. The first thing I did was download the JDK that was available at the time. It ended up being jdk1.6.0_07. Then I downloaded JCreator IDE because it was the same IDE that I was familiar with in the classroom. The classroom textbook was The Fundamentals of Java, by Lambert and Osborne. This textbook uses the add-on package BreezySwing which is available from their website. I downloaded whatever version or update that was available at the time. Computer A still has that same download.
    In the classroom I became very familar with BreezySwing to the point where I could use all the methods for it comfortably. During the school year, I ended up using about five different computers. There were no problems with them as far as odd errors go. Every time there was an error, it was clearly the fault of the programmer and easily fixable.
    Back to Computer A: Since almost all of the programs I wanted to write used BreezySwing, it had to be set up properly. After some instructions were given to me from my teacher, I created the PATH environment variable and set it to the location of the BreezySwing documentation; which on Computer A was:
    'C:\Program Files\Java\jdk1.6.0_07\bin'
    Every kind of program that I made on Computer A works perfectly; including my test program mentioned earlier:
    application: DFTest.class
    import javax.swing.*;
    import BreezySwing.*;
    class DFTest extends GBFrame {
    JTextField txtFld = addTextField("abcdefg",1,1,1,1);
    DoubleField valueFld = addDoubleField(0.0 ,2,1,1,1);
    static public void main(String[] args){
    DFTest obj = new DFTest();
    obj.setSize(300,100);
    obj.setVisible(true);
    }By now I was getting good at making programs. Some of them I found very useful, so I wanted to make them into some type of executable file. I became familiar with all of them including .jar and .exe. However, the only one that worked for me was the batch file. I also liked its simplicity. I quickly became good at using them to execute Java bytecode.
    The next thing I wanted to do was put the useful programs I had made on a computer that was in the other room. This computer will be called Computer B. Computer B is much older than Computer A, but still a Windows.
    I knew this computer first needed Java installed on it, so I returned to the Sun download site. This time, the newest Java JDK download was jdk1.6.0_13. I also downloaded jre6 and NetBeans IDE to see if I liked it better than JCreator and to have the option to develop Java on Computer B. Next, I had to download BreezySwing again to Computer B.
    A very odd thing occurred next:
    Upon trying to extract the files of BreezySwing to the proper directory 'C:\Program Files\Java\jdk1.6.0_13\bin', a message came saying that every file in BreezySwing required a password. It also said that all the files in the 'bin' folder (of jdk1.6.0_13) were read-only and it would not let any files be placed there. I still do not know why I did not have this issue with Computer A. I did not know what to do for weeks.
    In the end, I had to copy jdk1.6.0_07 from Computer A to Computer B. It already had BreezySwing in it. However, I was unable to set up NetBeans to work with BreezySwing. Part of the problem was that Computer B is too old and slow for such an advanced program like NetBeans. It was at this point that I started using batch and command prompt entirely to execute all the programs I made or used on Computer B.
    Just like I expected, every type of program I made or put on Computer B worked perfectly.
    About a month ago, I got a third computer; Computer C. By now I knew what I wanted in it so again I returned to the Sun download site. This time, I downloaded jdk1.6.0_14 and nothing else. Both Computer A and Computer B also had jre6; but not Computer C because I saw no need for it if I already had the JDK. I also did not bother with IDEs for Computer C; I just used notepad and command prompt to develop programs.
    The first program I put on Computer C was the one that I had made on Computer A. I already got it to work on Computer B, so I used that knowledge to do everything correctly for Computer C. The program would be executed by batch file which would tell the computer it was interacting with:
    1. The directory of the .class file
    2. The directory of the JDKs bin folder
    3. To include BreezySwing.jar in the execution path (needed to recognize all the methods used in the program)
    Everything about the batch files was correct. An error in the batch file would clearly cause an error not Java related; but rather cmd.exe related.
    After placing the .class file into the directory of all my other .class files (and BreezySwing)
    'C:\Documents and Settings\Java Applications\classes+src',
    I changed the information in the batch file to match the jdk update and match the correct class directory. Upon double clicking the batch file, a NullPointerException was thrown.
    Jump ahead to my test program; DFTest.class. After creating several other test programs to try to isolate the cause of the exception, this is what I found:
    When I attempt to execute the following code (after successful compilation):
    application: DFTest.class
    import javax.swing.*;
    import BreezySwing.*;
    class DFTest extends GBFrame {
    JTextField txtFld = addTextField("abcdefg",1,1,1,1);
    DoubleField valueFld = addDoubleField(0.0 ,2,1,1,1);
    static public void main(String[] args){
    DFTest obj = new DFTest();
    obj.setSize(300,100);
    obj.setVisible(true);
    }My message is too long so I will continue...

Maybe you are looking for