NullPointerException and RepaintManager

Hello,
I want to overwrite the paintDirtyRegions function in the RepaintManager so it will continue painting the remaining (J)Component(s).
The problem is, to copy the source of paintDirtyRegions won't bring anything, because the HashTables with the Components are private so I can't access them from a sub-class, and rebuild the RepaintManager is in my opinion not a good idea.
Has anybody an idea for this case?

To prevent a nullpointerexception on an empty value, do the checks like this:
if("boston".equals(city))If city is null, this will simply return false. It can never become an NPE because "boston" will always be a valid object.

Similar Messages

  • "AWT-EventQueue-0" java.lang.NullPointerException and JInternalFrame

    I have two classes one with main method second with GUI methods (JFrame, JInternalFrame). When I call method to start second JInternalFrame from main everything is working but if i call it form any other method i get:
    Exception in thread "main" java.lang.NullPointerException
    at pkg1.GUI.createFrame(GUI.java:123)
    at pkg1.GUI.startFrame2(GUI.java:66)
    at pkg1.Top.cos(Top.java:25)
    at pkg1.Top.main(Top.java:20) My code:
    GUI class
    package pkg1;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.Frame;
    import java.awt.Toolkit;
    import java.awt.event.MouseMotionListener;
    import javax.swing.JDesktopPane;
    import javax.swing.JFrame;
    import javax.swing.JInternalFrame;
    import javax.swing.JPanel;
    import javax.swing.plaf.basic.BasicInternalFrameUI;
    import oracle.jdeveloper.layout.XYLayout;
    public class GUI
        public JDesktopPane desktop;
        private XYLayout xYLayout1 = new XYLayout();
        public int openFrameCount = 0;
        JFrame f = new JFrame();
        public void GUII()  // Prepare JFrame
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setSize(500, 600);
            f.setVisible(true);
        public void startFrame()
            desktop = new JDesktopPane();
            createFrame(); //create first "window"
            f.setContentPane(desktop);
            desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
        public void startFrame2()
            createFrame(); //create second "window"
            f.setContentPane(desktop);
            desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
        public void createFrame()
            MyInternalFrame frame = new MyInternalFrame();
            frame.setVisible(true); //necessary as of 1.3
            desktop.add(frame);
            frame.add(new GUI2());
        } Top class
    public class Top
        public static void main(String[] args)
            GUI g = new GUI();
            g.GUII(); //Create JFrame
            g.startFrame(); //Create JInternalFrame
            Top t = new Top();
            t.sth();
        public void sth()
            GUI gui = new GUI();
            gui.startFrame2();
    } MyIntternalFrame class
    import javax.swing.JInternalFrame;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.SwingConstants;
    import oracle.jdeveloper.layout.XYConstraints;
    import oracle.jdeveloper.layout.XYLayout;
    /* Used by InternalFrameDemo.java. */
    public class MyInternalFrame extends JInternalFrame {
        static int openFrameCount =  0;      
        static final int xOffset = 30, yOffset = 30;
        private XYLayout xYLayout1 = new XYLayout();
        private JButton jButton1 = new JButton();
        private JLabel jLabel1 = new JLabel();
        private JFrame c = new JFrame();
        private JPanel d = new JPanel();
        private XYLayout xYLayout2 = new XYLayout();
        public MyInternalFrame() {         
            super("Document #"  + (++openFrameCount),true /*resizable*/,true /*closable*/,true /*maximizable*/,true);//iconifiable*/
            //...Create the GUI and put it in the window...
            //...Then set the window size or call pack...
            int width = new GUI2().width + 10;
            int height = new GUI2().height + 40;
            setSize(width,height);
            setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
    } Please tel me where is my mistake or maybe you knew another way to open JInternalFrame with public method form another class

    Some possibly helpful suggestions:
    1) Create one JDesktopPane, and do it in the constructor of GUI. You should call this constructor only once.
    2) Get rid of GUII. The GUI constructor will do all this and more.
    3) Get rid of startFrame and startFrame2.
    4) In GUI2, change your width and height to static variables if you are going to use them in outside classes. There is no reason to have to create a GUI2 object just to get those values. Get them from the class, not the instances.
    5) You're doing something funky in your Top class with your mixing of static code and non-static code. My gut tells me that Top is just a static universe that exists to get your code up and running, and that the code within it should all be static, but that's just my personal opinion.
    6) In MyInternalFrame, get the height and width from GUI2 (if that's what you want to do) again in a static fashion. Rather than new GUI2().width which makes no sense, use GUI2.width.
    Why can't you put the button inside of the JInternalFrame object? I believe that the contentPane of this object which may hold your button (unless you embed a jpanel) uses BorderLayout, so you have to take care how you add jcomponents to the jinternalframe (or more precisely, it's contentPane).

  • Java.lang.NullPointerException and ConnectionPool problem

    refresh page , problem gone
    java.lang.NullPointerException
    at Deferment.UpdatePostgraduate.getStatus(UpdatePostgraduate.java:278)
    at Deferment.UpdatePostgraduate.doPost(UpdatePostgraduate.java:175)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:402)
    at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:170)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    UpdatePostgraduate.java:278
    ->while (rs.next()) {
    175-> tarCount=getStatus(userid);
    now I have
    Connection conn = null;
    CallableStatement calstat=null;
    ResultSet rs = null;
    in every of my function
    and my
    public Connection getConnection()         throws SQLException, ServletException       {           Connection conn = null;           try{           pool.getConnection();           }catch (SQLException sqle) {             throw new ServletException(sqle.getMessage());         }           return conn;       }

    private DataSource pool = null; 
        int tarCount;
        int sendMail;
        @Override
        public void init() throws ServletException {
            Context env = null;
            try {
                env = (Context) new InitialContext().lookup("java:comp/env");
                pool = (DataSource) env.lookup("jdbc/test");
                if (pool == null) {
                    throw new ServletException(
                            "'jdbc/test' is an unknown DataSource");            }
            } catch (NamingException ne) {
                throw new ServletException(ne);
          public Connection getConnection()
            throws SQLException, ServletException
              Connection conn = null;
              try{
             conn=pool.getConnection();
              }catch (SQLException sqle) {
                System.out.println("JDBC error:" + sqle.getMessage());
                sqle.printStackTrace();
              return conn;
          }then on every function I call it like
    private int getFound(String UNumber) throws Exception {
            Connection conn = null;
            CallableStatement calstat=null;
            ResultSet rs = null;
            try {
                conn = pool.getConnection();
                calstat = (CallableStatement) conn.prepareCall("{call DuplicatePost(?)}");
                calstat.setString(1, UNumber);
                rs = calstat.executeQuery();
                tarCount = 0;
                while (rs.next()) {
                    tarCount++;
            } catch (SQLException se) {
                System.out.println("JDBC error:" + se.getMessage());
                se.printStackTrace();
            } catch (Exception e) {
                System.out.println("other error:" + e.getMessage());
                e.printStackTrace();
            } finally {
                try {
                    if (rs != null) {
                        rs.close();
                    if (calstat != null) {
                        calstat.close();
                } catch (SQLException e) {
                    e.printStackTrace();
            } //end finally
            return tarCount;
        }// end function
    }// end

  • NullPointerException and event handling

    In this forum I want to know why my program doesn't work. In my program, I want to show the text in JTextfield (Swing) if the user click Jbutton, but the rusult show this comment: java.lang.NullPointerException
    Why can this happen in my programm?
    The Scrypt of my program:
    //event handling
    itemBuka.addActionListener((ActionListener) this);//itemBuka is JButton
    public void actionPerformed(ActionEvent e){
    String perintah = e.getActionCommand();
    if (perintah.equals("Buka...")){
    f1.setText("bisa"); // f1 is a JTextfield and want to shoe the word "bisa"
    }

    public void actionPerformed(ActionEvent e){
    String perintah = e.getActionCommand();
    if (perintah.equals("Buka...")){
    f1.setText("bisa"); // f1 is a JTextfield and
    d and want to shoe the word "bisa"
    }A NullPointerException is indicative of a method call invoked on a null reference.
    This piece of code is insufficient to tell you why it is occuring, annd you didn't even mention the line where the exception is thrown.
    A good guess is that f1 is somehow appearing as null... might be a problem with the scope or something that your code does!
    So, post the complete code.

  • Java.lang.NullPointerException and javaBeans

    I think that part of the problem is due to some wonky requirements, but maybe not. There are three classes:
    lab02.util.MySlider -- has a JSlider and a few other bits
    lab02.util.ColorSelector -- has three JSliders and creates a Color (not a JColorChooser)
    lab02.view.View -- the driver and JFrame, has two ColorSelectors and JTextField
    However, a requirement is to have ColorSelector load as a jar file. The only way I could find of doing that was create two parallel projects: beans and lab2.
    I added MySlider to the palette for ColorSelector, and then added ColorSelector to the palette. Switching over the lab2 project, I added ColorSelector to View. When I received the following error:
    xception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at a00720398.lab02.util.MySlider.jSlider1StateChanged(MySlider.java:53)
            at a00720398.lab02.util.MySlider.access$000(MySlider.java:6)
            at a00720398.lab02.util.MySlider$1.stateChanged(MySlider.java:39)I then added both MySlider and ColorSlider to the Library Manager, and then added them to the library for lab2 project. Same result.
    Is it a coding problem? A netbeans problem? A packaging problem? I've tried some System.out statements to try to track it down but couldn't get anywhere.
    Keepin in mind that there are two projects with overlapping package structures, here's the code:
    thufir@arrakis:~/bcit3621$
    thufir@arrakis:~/bcit3621$ cat lab2beans/src/a00720398/lab02/util/MySlider.java
    package a00720398.lab02.util;
    import javax.swing.event.ChangeListener;
    public class MySlider extends javax.swing.JPanel {
        private ChangeListener changeListener;
        /** Creates new form MySlider */
        public MySlider() {
            initComponents();
        public MySlider(ChangeListener changeListener) {
            this();
            this.changeListener = changeListener;
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc="Generated
    Code">//GEN-BEGIN:initComponents
        private void initComponents() {
            bindingGroup = new org.jdesktop.beansbinding.BindingGroup();
            jLabel1 = new javax.swing.JLabel();
            jSlider1 = new javax.swing.JSlider();
            jTextField1 = new javax.swing.JTextField();
            jLabel1.setText("jLabel1");
            add(jLabel1);
            jSlider1.setMaximum(255);
            jSlider1.addChangeListener(new javax.swing.event.ChangeListener() {
                public void stateChanged(javax.swing.event.ChangeEvent evt) {
                    jSlider1StateChanged(evt);
            add(jSlider1);
            org.jdesktop.beansbinding.Binding binding =
    org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE,
    jSlider1, org.jdesktop.beansbinding.ELProperty.create("${value}"), jTextField1,
    org.jdesktop.beansbinding.BeanProperty.create("text"));
            bindingGroup.addBinding(binding);
            add(jTextField1);
            bindingGroup.bind();
        }// </editor-fold>//GEN-END:initComponents
        private void jSlider1StateChanged(javax.swing.event.ChangeEvent evt)
    {//GEN-FIRST:event_jSlider1StateChanged
            // TODO add your handling code here:
            changeListener.stateChanged(evt);
        }//GEN-LAST:event_jSlider1StateChanged
        public void setName(String string) {
            jLabel1.setText(string);
        public int getValue() {
            return jSlider1.getValue();
        public void setValue(int value) {
            jSlider1.setValue(value);
        // Variables declaration - do not modify//GEN-BEGIN:variables
        private javax.swing.JLabel jLabel1;
        private javax.swing.JSlider jSlider1;
        private javax.swing.JTextField jTextField1;
        private org.jdesktop.beansbinding.BindingGroup bindingGroup;
        // End of variables declaration//GEN-END:variables
    thufir@arrakis:~/bcit3621$
    thufir@arrakis:~/bcit3621$ cat lab2beans/src/a00720398/lab02/util/ColorSelector.java
    package a00720398.lab02.util;
    import java.awt.Color;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    public class ColorSelector extends javax.swing.JPanel implements ChangeListener {
        private ChangeListener changeListener;
        private Color color;
        /** Creates new form ColorSelector */
        public ColorSelector() {
            initComponents();
        public ColorSelector(Color color) {
            //initComponents();
            red = new a00720398.lab02.util.MySlider(this);
            green = new a00720398.lab02.util.MySlider(this);
            blue = new a00720398.lab02.util.MySlider(this);
            setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS));
            add(red);
            add(green);
            add(blue);
            this.color = color;
        public ColorSelector(Color color, ChangeListener changeListener) {
            //initComponents();
            this(color);
            this.changeListener = changeListener;
            //initComponents();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc="Generated
    Code">//GEN-BEGIN:initComponents
        private void initComponents() {
            red = new a00720398.lab02.util.MySlider();
            green = new a00720398.lab02.util.MySlider();
            blue = new a00720398.lab02.util.MySlider();
            setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS));
            add(red);
            add(green);
            add(blue);
        }// </editor-fold>//GEN-END:initComponents
        // Variables declaration - do not modify//GEN-BEGIN:variables
        private a00720398.lab02.util.MySlider blue;
        private a00720398.lab02.util.MySlider green;
        private a00720398.lab02.util.MySlider red;
        // End of variables declaration//GEN-END:variables
        public void stateChanged(ChangeEvent arg0) {
            throw new UnsupportedOperationException("Not supported yet.");
            //color = new Color(red.getValue(), green.getValue(), blue.getValue());
        public Color getColor() {
            System.out.println("getColor   " + color);
            return color;
    thufir@arrakis:~/bcit3621$
    thufir@arrakis:~/bcit3621$ cat lab2/src/a00720398/lab02/view/Lab02View.java
    package a00720398.lab02.view;
    import a00720398.lab02.util.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class Lab02View extends javax.swing.JFrame implements ChangeListener {
        private Color color;
        /** Creates new form Lab02View */
        public Lab02View() {
            initComponents();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc="Generated
    Code">//GEN-BEGIN:initComponents
        private void initComponents() {
            jTextArea1 = new javax.swing.JTextArea();
            colorSelector1 = new a00720398.lab02.util.ColorSelector();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(),
    javax.swing.BoxLayout.Y_AXIS));
            jTextArea1.setColumns(20);
            jTextArea1.setRows(5);
            getContentPane().add(jTextArea1);
            getContentPane().add(colorSelector1);
            pack();
        }// </editor-fold>//GEN-END:initComponents
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    //new Lab02View().setVisible(true);
                    JFrame frame = new Lab02View();
                    frame.setLocationRelativeTo(null);
                    frame.setSize(600,400);
                    frame.setVisible(true);
        public void stateChanged(ChangeEvent arg0) {
            throw new UnsupportedOperationException("Not supported yet.");
            //jTextArea1.setBackground(colorSelector1.getColor());
            //color = colorSelector1.getColor();
        // Variables declaration - do not modify//GEN-BEGIN:variables
        private a00720398.lab02.util.ColorSelector colorSelector1;
        private javax.swing.JTextArea jTextArea1;
        // End of variables declaration//GEN-END:variables
    thufir@arrakis:~/bcit3621$
    thufir@arrakis:~/bcit3621$ thanks,
    Thufir

    don't respond to this question, it's too "large". I'm creating another thread.

  • NullPointerException and cannot be cast when extended CO!

    Hello!
    Forms develop in to Brazil and I am now entering the area of customization in Oa Framework, forgive my English strange ...
    I have the need to extend the controller ExpSearchCO to include a new filter field search. Just extending ExpSearchCO and without any additional logic error occurs in the super class !!!!
    oracle.apps.fnd.framework.OAException: java.lang.NullPointerException return the inside super class
    the line of code is the line informed :oaquerybean.setSimpleSearchInstructionTexts(null);
    trying to deal with this error message appeared
    oracle.apps.fnd.framework.OAException: java.lang.ClassCastException: oracle.apps.fnd.framework.webui.beans.layout.OAQueryBean cannot be cast to oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:891)
    the snippet is:
    OAFormattedTextBean oaformattedtextbean = (OAFormattedTextBean)oawebbean.findIndexedChildRecursive("SearchInstruction");
    ((OAPageLayoutBean)oawebbean).prepareForRendering(oapagecontext);
    oaformattedtextbean.setText(oapagecontext.getMessage("ICX", s2, null));
    there is some initialization that should be within my custom control or dealings that errors do not occur in the super class?
    ================================================================================
    first error :
    oracle.apps.fnd.framework.OAException: java.lang.NullPointerException at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:891) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:603) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247) at oracle.apps.fnd.framework.webui.OAQueryHelper.processRequest(OAQueryHelper.java:673) at oracle.apps.fnd.framework.webui.beans.layout.OAStackLayoutBean.processRequest(OAStackLayoutBean.java:350) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:959) at
    ## java.lang.NullPointerException at oracle.apps.icx.por.reqmgmt.webui.ExpSearchCO.processRequest(ExpSearchCO.java:56) at xmtd.oracle.apps.icx.por.reqmgmt.webui.XxExpSearchCO.processRequest(XxExpSearchCO.java:54) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:587) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247) at oracle.apps.fnd.framework.webui.OAQueryHelper.processRequest(OAQueryHelper.java:673) at oracle.apps.fnd.framework.webui.beans.layout.OAStackLayoutBean.processRequest(OAStackLayoutBean.java:350) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:959) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:926) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:646) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247) at
    =====================================================================================
    second error
    oracle.apps.fnd.framework.OAException: java.lang.ClassCastException: oracle.apps.fnd.framework.webui.beans.layout.OAQueryBean cannot be cast to oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:891) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:603) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247) at ...
    ## java.lang.ClassCastException: oracle.apps.fnd.framework.webui.beans.layout.OAQueryBean cannot be cast to oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean at oracle.apps.icx.por.reqmgmt.webui.ExpSearchCO.processRequest(ExpSearchCO.java:79) at xmtd.oracle.apps.icx.por.reqmgmt.webui.XxExpSearchCO.processRequest(XxExpSearchCO.java:54) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:587) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247) at oracle.apps.fnd.framework.webui.OAQueryHelper.processRequest(OAQueryHelper.java:673) at
    for details of the problem, link with Attach: http://www.4shared.com/file/132642195/f3340a3e/anexo.html
    Edited by: user2019065 on 14/09/2009 14:17

    The question is as follows:
    Within the page oracle /apps/icx/by/reqmgmt/webui/ExpSearchPG 115.27 in iproc.
    Is necessary to include a new filter for search.
    Analyzing the source code finds the need to extend the View Object AllReqsVO to include this new field.
    was necessary to extend the classes
    oracle.apps.icx.por.reqmgmt.webui.ExpSearchCO
    oracle.apps.icx.por.reqmgmt.ExpSearchCriteria
    oracle.apps.icx.por.reqmgmt.server.ExpSrchSvrCmd
    that perform the logic to filter the information.
    However, just extending the class oracle.apps.icx.por.reqmgmt.webui.ExpSearchCO , Not changed anything yet in this class ok !
    The application presents the errors mentioned above during the tests.
    the question is whether there is any procedure to follow when extending a control?
    ake two weeks since my first contact with OA Framework and Java ...
    think it is you are doing wrong, because it is a simple test. you have any tips or documentation about extending controls
    Edited by: EdgarOliveira on 15/09/2009 10:12

  • NullPointerException and getGraphics

    In what cases does getGraphics() throw NullPointerException?
    offImage=createImage(cellImage.getWidth(this),cellImage.getHeight(this));
    og=offImage.getGraphics();in the above code snippet from my program it throws null pointer exception, i have made sure that all the image files have loaded using mediaTracker, before creating the offscreen image and graphics

    http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Component.html#createImage(int,%20int)
    Since you're trying to use the return value of that method, why didn't you check the documentation for the return value of the method?

  • NullPointerException and BinarySearchTree

    I have a BinarySearchTree and each BSTNode of it contains variables of type int. I have created BinarySearchTree.insert(int i) method. However, when i am comparing "i", with BSTNode.element -the int variable contained inside each BSTNode, in order to find the right place to insert the node, i get "NullPointerException". The statement
    if (i==node.element) return; ends up with a NullPointerException. So does if (i<node.element) node=node.leftIdeas?

    Most likely, node at this point is null. Can't tell more without seeing code.

  • NullPointerException and Permissions

    Hi.
    OK, I am trying to use the java.io package to create an applet which gets a file name from the user and filters info out of that file and puts it into a new one (called results).
    I am not sure what the NullPointerException is referring to. I have created a policy file, but I am not sure whether I have correctly entered the pathways for those files; I am wondering if this is the source of my error.
    Also, I have used code in the following format:
    String results = System.getProperty("user.home",                File.separatorChar + "home" +
    File.separatorChar + "zelda") +
    File.separatorChar + "results.dat";
    and from my diagnostic prints I have found that this points to C:\Windows. I don't understand why this would be a problem as long as my policy file was compatible with that, which is why I am suspicious that the policy file is the cause of the error.
    Finally, in the policy file, when I define my PropertyPermission - is it correct to set the target name to user.home? I assume this means C:\Windows, but I can't find anywhere that explicitly tells me so.
    Help would be greatly appreciated.
    Thanks.

    If you look in the java documentation for System.getProperties(), you will see a list of standard properties. "user.home" is the user's home directory, which means more in Unix than in does in Windows. Under Windows 9x you will probably get C:\Windows, but under Windows NT/2000/XP, you will most likely get "C:\Documents and Settings\Username", or something like that. Basically, under Windows, you can't really rely on user.home pointing to something meaningful.
    Robin

  • GUI, NullPointerException and WTK

    Hi There,
    i wrote this simple application:
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    public class HighUI extends MIDlet {
         private Display display;
         private Form form;
         private TextField name;
         private TextField phone1;
         private TextField phone2;
         private TextField phone3;
         private Command exit;
         private Command submit;
         private List contact;
         public HighUI() {
              super();
              display = Display.getDisplay(this);
                 form = new Form("Contact");
              name = new TextField("Nome:", null, 30, TextField.ANY);
              phone1 = new TextField("Tel1:", null, 15, TextField.PHONENUMBER);
              phone2 = new TextField("Tel2:", null, 15, TextField.PHONENUMBER);
              phone3 = new TextField("Tel3:", null, 15, TextField.PHONENUMBER);
              form.append(name);
              form.append(phone1);
              form.append(phone2);
              form.append(phone3);
              submit = new Command("Invia", Command.OK, 1);
              exit = new Command("Esci", Command.EXIT, 1);
              form.addCommand(submit);
              form.addCommand(exit);
              form.setCommandListener(public void commandAction(Command c, Displayable arg1) {
                        if (c == exit) {
                             notifyDestroyed();
                        } else if (c == submit) {
                             String nameValue = name.getString();
                             contact = new List(nameValue, List.IMPLICIT);
                             contact.append(phone1.getString(), null);
                             contact.append(phone2.getString(), null);
                             contact.append(phone3.getString(), null);
                             display.setCurrent(contact);
         protected void startApp() throws MIDletStateChangeException
            display.setCurrent(form);
        protected void pauseApp() { }
        protected void destroyApp(boolean arg0) throws MIDletStateChangeException { }
    }...The code is correct... or atlast the compiler doesn't give me any error... Why when i start the application in the device-phone emulator i give this error in the console and the app doesn't start?
    Project "HighUI" loaded
    Running with storage root DefaultColorPhone
    Unable to create MIDlet highui.HighUI
    java.lang.ClassNotFoundException: highui/HighUI
         at com.sun.midp.midlet.MIDletState.createMIDlet(+14)
         at com.sun.midp.midlet.Selector.run(+22)
    Execution completed.Thank you for answers :)
    Bye bye
    hawake
    Edited by: hawake on Nov 27, 2007 12:39 PM

    Hi, the previous error is correct now! :) Thank you!
    But, another boring question, now I give another error with this source (corrected):
    package highui;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    public class HighUI extends MIDlet {
         private Display display;
         private Form form;
         private TextField name;
         private TextField phone1;
            private TextField phone2;
         private TextField phone3;
         private Command exit;
         private Command submit;
         private List contact;
         public HighUI() {
              super();
              display = Display.getDisplay(this);
                 form = new Form("Contact");
              name = new TextField("Nome:", null, 30, TextField.ANY);
              phone1 = new TextField("Tel1:", null, 15, TextField.PHONENUMBER);
              phone2 = new TextField("Tel2:", null, 15, TextField.PHONENUMBER);
              phone3 = new TextField("Tel3:", null, 15, TextField.PHONENUMBER);
              form.append(name);
              form.append(phone1);
              form.append(phone2);
              form.append(phone3);
              submit = new Command("Invia", Command.OK, 1);
              exit = new Command("Esci", Command.EXIT, 1);
              form.addCommand(submit);
              form.addCommand(exit);
              form.setCommandListener(this);
    public void commandAction(Command c, Displayable arg1) {
                        if (c == exit) {
                             notifyDestroyed();
                        } else if (c == submit) {
                             String nameValue = name.getString();
                             contact = new List(nameValue, List.IMPLICIT);
                             contact.append(phone1.getString(), null);
                             contact.append(phone2.getString(), null);
                             contact.append(phone3.getString(), null);
                             display.setCurrent(contact);
         protected void startApp() throws MIDletStateChangeException
            display.setCurrent(form);
        protected void pauseApp() { }
        protected void destroyApp(boolean arg0) throws MIDletStateChangeException { }
    }Error:
    Project settings saved
    Building "HighUI"
    D:\Programmi\WTK22\apps\HighUI\src\highui\HighUI.java:33: setCommandListener(javax.microedition.lcdui.CommandListener) in javax.microedition.lcdui.Displayable cannot be applied to (highui.HighUI)
              form.setCommandListener(this);
                  ^
    1 error
    com.sun.kvem.ktools.ExecutionException
    Build failedThank you for answer!
    Bye
    hawake

  • NullPointerException and more

    Hi
    I was testing a flow in B2B. However, I am getting the following error. THis error appears only for one business action. For rest of the business actions, it is working fine.
    007.11.28 at 02:30:26:840: Thread-10: B2B - (ERROR) Error -: AIP-51505: General Validation Error: com.edifecs.shared.jni.JNIException: Execute failed - file_exception thrown - reason[3], description[The system cannot find the path specified.
    Caused by: com.edifecs.shared.jni.JNIException: Execute failed - file_exception thrown - reason[3], description[The system cannot find the path specified.
    2007.11.28 at 02:30:26:840: Thread-10: B2B - (ERROR) java.lang.NullPointerException
    2007.11.28 at 02:30:26:840: Thread-10: B2B - (ERROR) Error -:  AIP-50014:  General Error: java.lang.NullPointerException
         at oracle.tip.adapter.b2b.engine.Engine.processOutgoingMessage(Engine.java:977)
         at oracle.tip.adapter.b2b.engine.Engine.handleMessageEvent(Engine.java:2149)
         at oracle.tip.adapter.b2b.engine.Engine.processEvents(Engine.java:2085)
         at oracle.tip.adapter.b2b.data.MsgListener.onMessage(MsgListener.java:491)
         at oracle.tip.adapter.b2b.data.MsgListener.run(MsgListener.java:339)
         at java.lang.Thread.run(Thread.java:534)
    Caused by: java.lang.NullPointerException
    Please help.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi,
    It appears to be a problem with XEngine installation. Please install the B2B with the latest patch

  • XDK 9i Issues : setXSLT - NullPointerException And RMI Server hangs

    Present Scenario :
    JDK 1.3
    Oracle DB : 8.1.6
    JDBC Driver : OracleThin.jar
    XML Parser : xmlparserv2.jar : ( size = 1121488 )
    XML-SQL utility : xsu12.jar : ( size = 180522 )
    We use RMI with JDBC. RMI server object connects to database , uses xsu12.jar and xmlparserv2.jar to convert data into XML. Servlet connects to RMI server and gets this XML. Everything works fine.
    Problem Scenario :
    Since this parser does not support JAXP , I downloaded XDK 9i from oracle site.(9.2.0.1.0 - Dated 01/31/02 ) . After extracting , I replaced xmlparserv2.jar and xsu12.jar with this new ones. And problem started. There are 2 problems :
    A. setXSLT( String, String ) throws NullPointerExcpetion
    B. When I commented setXSLT method, RMI server completes execution of remote method which can be verified from Log. But it never returns , so client gets blocked. When RMI server is stopped by doing ctrl-C , client gets correct XML document.
    Then I installed latest JDBC2.0 driver for 8.1.6 from site which is classes.zip. This also resulted in to same problems mentioned above. But it did work fine wirh earlier version of xmlparserv2.jar and xsu12.jar. Just FYI : I noticed significant size difference betwenn new and old jars.
    New xmlparserv2.jar : size = 660421
    New xsu12.jar : size = 473249
    Thanks for patience
    What could be possible solution ?

    Thanks Jinu
    Problem A of setXSLT throwing NullPOinter Exception is solved. However problem B of RMI server not returning still there.
    Just as an FYI , following is system
    DB : oracle 8.1.6
    xmlparserv2.jar : 9i xdk
    xsu12_816.jar : 9i xdk
    classes12.zip : JDBC2.0 for 8.1.6
    When RMI server is stopped ( ctrl- C ) , client gets correct XML document alongwith proper Node names as set in setStyleSheet( String, String).

  • Validate failure and report java.lang.NullPointerException

    there are three required textinput field in my dialog window . after input data into them, i click button to commit data, meet the validate failure error . report a java.lang.NullPointerException at these three fields bottom. others non-required fields has no error.
    The error message in page is
    JBO-35007: Row currency has changed .... need oracle.jbo.Key[5 ] -
    Length - java.lang.NullPointerException
    RollId - java.lang.NullPointerException
    VatId - java.lang.NullPointerException
    and in application.log is
    08/02/24 12:48:15.951 fabricmis: Servlet error
    java.lang.NullPointerException
         at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:346)
         at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:152)
         at oracle.adfinternal.view.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:157)
         at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
         at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at oracle.webcache.adf.filter.PageCachingFilter.doFilter(PageCachingFilter.java:232)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._invokeDoFilter(AdfFacesFilterImpl.java:228)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:197)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:123)
         at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:103)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:621)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)

    the log in debug mode
    08/03/01 16:31:45 [22632] Failed to validate :1 for binding:VatId
    2008-3-1 16:31:45 oracle.adf.view.faces.util.MessageFactory getMessage
    Warning:
    java.lang.NullPointerException
         at oracle.jbo.uicli.binding.JUCtrlValueBinding.validateAttributeValue(JUCtrlValueBinding.java:757)
         at oracle.jbo.uicli.binding.JUCtrlValueBinding.validateInputValue(JUCtrlValueBinding.java:2128)
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlAttrsBinding$AttrValidator.validate(FacesCtrlAttrsBinding.java:189)
         at oracle.adf.view.faces.component.UIXEditableValue.validateValue(UIXEditableValue.java:378)
         at oracle.adf.view.faces.component.UIXEditableValue.validate(UIXEditableValue.java:206)
         at oracle.adf.view.faces.component.UIXEditableValue._executeValidate(UIXEditableValue.java:522)
         at oracle.adf.view.faces.component.UIXEditableValue.processValidators(UIXEditableValue.java:302)
         at oracle.adf.view.faces.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:855)
         at oracle.adf.view.faces.component.UIXComponentBase.validateChildren(UIXComponentBase.java:839)
         at oracle.adf.view.faces.component.UIXComponentBase.processValidators(UIXComponentBase.java:689)
         at oracle.adf.view.faces.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:855)
         at oracle.adf.view.faces.component.UIXComponentBase.validateChildren(UIXComponentBase.java:839)
         at oracle.adf.view.faces.component.UIXComponentBase.processValidators(UIXComponentBase.java:689)
         at oracle.adf.view.faces.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:855)
         at oracle.adf.view.faces.component.UIXComponentBase.validateChildren(UIXComponentBase.java:839)
         at oracle.adf.view.faces.component.UIXComponentBase.processValidators(UIXComponentBase.java:689)
         at oracle.adf.view.faces.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:855)
         at oracle.adf.view.faces.component.UIXComponentBase.validateChildren(UIXComponentBase.java:839)
         at oracle.adf.view.faces.component.UIXComponentBase.processValidators(UIXComponentBase.java:689)
         at oracle.adf.view.faces.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:855)
         at oracle.adf.view.faces.component.UIXComponentBase.validateChildren(UIXComponentBase.java:839)
         at oracle.adf.view.faces.component.UIXComponentBase.processValidators(UIXComponentBase.java:689)
         at oracle.adf.view.faces.component.UIXForm.processValidators(UIXForm.java:59)
         at oracle.adf.view.faces.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:855)
         at oracle.adf.view.faces.component.UIXComponentBase.validateChildren(UIXComponentBase.java:839)
         at oracle.adf.view.faces.component.UIXComponentBase.processValidators(UIXComponentBase.java:689)
         at oracle.adf.view.faces.component.UIXComponentBase.validateChildrenImpl(UIXComponentBase.java:855)
         at oracle.adf.view.faces.component.UIXComponentBase.validateChildren(UIXComponentBase.java:839)
         at oracle.adf.view.faces.component.UIXComponentBase.processValidators(UIXComponentBase.java:689)
         at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:932)
         at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:362)
         at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:98)
         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
         at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:110)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:213)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at oracle.webcache.adf.filter.PageCachingFilter.doFilter(PageCachingFilter.java:274)
         at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._invokeDoFilter(AdfFacesFilterImpl.java:228)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:197)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:123)
         at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:103)
         at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:17)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._invokeDoFilter(AdfFacesFilterImpl.java:228)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:197)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:123)
         at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:103)
         at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:17)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:162)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:621)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
         at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
         at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
         at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)

  • Checking Account and help with code ?

    Hi all..my computer hung up on me, so I'm not sure if my last post went through. First of all thank you all for helping me out the other day with my question on the Bank Account. It continues :)
    I'm trying to work on each class one by one..when I test my Checking Account, it isn't printing out the correct balance. The string method to print this is coming from the Withdrawal class...so I know it has to be somewhere in there but I can't seem to figure out why it isn't totalling the balance...or how to get it too.
    Then when I test my MyBank class, it hangs up on line 63..which I could swear I have written correctly. Again I am getting a NullPointerException and I honestly think I have the line of code written right, but I'm guessing I dont.
    Any help would be appreciated.
    public abstract class BankAccount {
        public static final String bankName = "BrianBank";
        protected String custName;
        protected String pin;
        protected Transaction[] history;
        private double balance;
        private double amt, amount;
        private double bal, initBal;
        private int transactions;
        private final int MAX_HISTORY = 100;
        private int acct;
        protected BankAccount(String cname, String cpin, double initBal) {
         custName = cname;
         pin = cpin;
         balance = initBal;
         history = new Transaction[MAX_HISTORY];
         transactions =0;
        public double getBalance() {
         return balance;
        public void withdraw(double amt) {
         history [transactions] = new Withdrawal (bal, amt);
       balance = bal;
         amount = amt;
         balance -= amt;
       transactions = transactions + 1;     
        public void deposit(double amt) {     
         history [transactions] = new Deposit (bal, amt);
         balance = bal;
         amount = amt;
         balance += amt;
         transactions = transactions +1;
        // abstract method to return account number
        public abstract int getAcctNum();
        // abstract method to return a summary of transactions as a string
        public abstract String getStatement();
    public class CheckingAccount extends BankAccount implements IncursFee
          private int transactions;
          private double balance, initBal, amt;
          private static final int NOFEE_WITHDRAWALS = 10;
          private static final double TRANSACTION_FEE = 5.00;
          public static final String bankName = "iBank";
          public static final int STARTING_ACCOUNT_NUMBER = 10000;
          private int checkingAccountNumber = STARTING_ACCOUNT_NUMBER;
          private static int accountNumberCounter = STARTING_ACCOUNT_NUMBER;
          private String custName;
          private String pin;
          public CheckingAccount (String cname, String cpin, double initBal)
             super (cname, cpin, initBal);
              custName = cname;
              pin = cpin;
             balance = initBal;
             accountNumberCounter++; 
             checkingAccountNumber = accountNumberCounter;
          //initialize a count of transactions
             transactions = 0;          
           public double getBalance()
             return balance;
           public void withdraw(double amt)
            super.withdraw (amt);
             transactions ++;
           public void deposit(double amt)
           super.deposit (amt);
             transactions ++;
           public int getAcctNum ()
             return checkingAccountNumber;     
           public String getStatement ()
             int i = 0;
             String output = "";
             while ( i < history.length && history[i] != null )
                output += history.toString () + "\n";
    i++;
    return output;     
    public void deductFee(double fee)
    if (transactions > NOFEE_WITHDRAWALS)
    {  fee = TRANSACTION_FEE *(transactions - NOFEE_WITHDRAWALS);
    super.withdraw(fee);
    balance -=fee;
    transactions = 0;
    public interface IncursFee {
    public abstract void deductFee(double fee);
    public abstract class Transaction {
    protected double initBal;
    protected double tranAmt;
    // constructor
    protected Transaction(double bal, double amt) {
         initBal = bal;
         tranAmt = amt;
    abstract public String toString();
    public class Withdrawal extends Transaction
         private double initBal;
         private double amount;
         private static NumberFormat fmt = NumberFormat.getCurrencyInstance();
         public Withdrawal (double bal, double amt)
              super (bal, amt);
              initBal = bal;
              amount = amt;
         public String toString ()
         return "Balance : " + fmt.format(initBal) + "\n" + "Withdrawal : " + fmt.format(amount);
    import java.text.NumberFormat;
    public class Deposit extends Transaction
         private double initbal, balance;
         private double amount;
         private static NumberFormat fmt = NumberFormat.getCurrencyInstance();
         public Deposit (double bal, double amt)
         super (bal, amt);
         initbal = bal;
         amount = amt;
         public String toString ()
         return "Balance : " + fmt.format(initbal) + "\n" + "Deposit : " + fmt.format(amount);
    public class TestCheckingAcct {
    public static void main(String[] args) {
         BankAccount b1 = new CheckingAccount("Harry", "1234", 500.0);
         System.out.println (b1.getBalance ());
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.deposit(50);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.deposit(10);
         b1.withdraw(1);
         System.out.println(b1.getStatement());
    // This interface specifies the functionality requirements of a bank
    public interface Bank {
    public abstract int openNewAccount(String customerName, String customerPIN, String accType, double initDepAmount);
    public abstract void processWithdrawal(int accNum, String pin, double amount);
    // executes a deposit on the specified acct by the amount
    public abstract void processDeposit(int accNum, String pin, double amount);
    // returns the balance of acct
    public abstract double processBalanceInquiry(int accNum, String pin);
    // returns summary of transactions
    public abstract String processStatementInquiry(int accNum, String pin);
    import java.util.ArrayList;
    public class MyBank implements Bank
    private ArrayList<BankAccount> savAccounts = new ArrayList<BankAccount>(); //dynamically grows
    private ArrayList<BankAccount> chkAccounts = new ArrayList<BankAccount>(); //dynamically grows
    private SavingsAccount sav;
    private CheckingAccount chk;
    private int accNum;
    private String customerName, customerPIN, accType, pin;
    private double initDepAmount, amount, balance;
    public int openNewAccount(String customerName, String customerPIN, String accType, double initDepAmount)
    this.customerName = customerName;
    this.customerPIN = customerPIN;
    this.accType = accType;
    this.initDepAmount = initDepAmount;
    if ( accType.equals("Savings"))
    BankAccount savAcct = new SavingsAccount(customerName, customerPIN, initDepAmount);
    try
    savAccounts.add(savAcct);
    catch (ArrayIndexOutOfBoundsException savAccounts)
    return savAcct.getAcctNum();
    else
    CheckingAccount chkAcct = new CheckingAccount(customerName, customerPIN, initDepAmount);
         try
    chkAccounts.add(chkAcct);
    catch (ArrayIndexOutOfBoundsException chkAccounts)
    return chkAcct.getAcctNum();
    public void processWithdrawal (int accNum, String pin, double amount)
         this.accNum = accNum;
         this.pin = pin;
         this.amount = amount;
    if (accNum >10000 && accNum < 20000)
         chk.withdraw (amount);
    if (accNum >50000 && accNum <60000)
         sav.withdraw (amount);
    public void processDeposit (int accNum, String pin, double amount)
         this.accNum = accNum;
         this.pin = pin;
         this.amount = amount;
    if (accNum >10000 && accNum < 20000)
         chk.deposit (amount);
    if (accNum >50000 && accNum <60000)
         sav.deposit (amount);
    public double processBalanceInquiry (int accNum, String pin)
         this.accNum = accNum;
         this.pin = pin;
         this.balance = 0;
    if (accNum >10000 && accNum <20000)
         balance = chk.getBalance ();
    if (accNum >50000 && accNum <60000)
         balance = sav.getBalance ();
    return balance;
    public String processStatementInquiry(int accNum, String pin)
         this.accNum = accNum;
         this.pin = pin;
         this.statement = "";
    if (accNum >10000 && accNum <20000)
    statement = chk.getStatement ();
    if (accNum >50000 && accNum <60000)
    statement= sav.getStatement ();
         return statement;

    Here's some quick code review:
    public abstract class BankAccount {
    public static final String bankName =
    me = "BrianBank";
    protected String custName;
    protected String pin;
    protected Transaction[] history;
    private double balance;
    private double amt, amount;
    private double bal, initBal;
    private int transactions;// make MAX_HISTORY private static final, too.
    private final int MAX_HISTORY = 100;
    private int acct;
    protected BankAccount(String cname, String cpin,
    pin, double initBal) {
         custName = cname;
         pin = cpin;
         balance = initBal;
         history = new Transaction[MAX_HISTORY];
         transactions =0;
    public double getBalance() {
         return balance;
    public void withdraw(double amt) {
         history [transactions] = new Withdrawal (bal, amt);
    balance = bal;
         amount = amt;
         balance -= amt;// ++transactions above would be elegant.
    transactions = transactions + 1;     
    public void deposit(double amt) {     
         history [transactions] = new Deposit (bal, amt);
         balance = bal;
         amount = amt;
         balance += amt;
         transactions = transactions +1;
    // abstract method to return account number// why abstract?
    public abstract int getAcctNum();
    // abstract method to return a summary of
    y of transactions as a string// why abstract?
    public abstract String getStatement();
    public class CheckingAccount extends BankAccount
    implements IncursFee
    private int transactions;
    private double balance, initBal, amt;
    private static final int NOFEE_WITHDRAWALS =
    WALS = 10;
    private static final double TRANSACTION_FEE =
    _FEE = 5.00;
    public static final String bankName = "iBank";
    public static final int STARTING_ACCOUNT_NUMBER
    NUMBER = 10000;
    private int checkingAccountNumber =
    mber = STARTING_ACCOUNT_NUMBER;
    private static int accountNumberCounter =
    nter = STARTING_ACCOUNT_NUMBER;// BankAccount has a custName attribute; why does CheckingAccount need
    // one if it extends BankAccount?
    private String custName;
    private String pin;
    public CheckingAccount (String cname, String
    String cpin, double initBal)
    super (cname, cpin, initBal);
    custName = cname;
    pin = cpin;
    balance = initBal;
    accountNumberCounter++;
    checkingAccountNumber =
    tNumber = accountNumberCounter;
    //initialize a count of transactions
    transactions = 0;          
    // same as BankAccount - why rewrite it?
    public double getBalance()
    return balance;
    // same as BankAccount - why rewrite it?
    public void withdraw(double amt)
    super.withdraw (amt);
    transactions ++;
    // same as BankAccount - why rewrite it?
    public void deposit(double amt)
    super.deposit (amt);
    transactions ++;
              // same as BankAccount - why rewrite it?
    public int getAcctNum ()
    return checkingAccountNumber;     
    public String getStatement ()
    int i = 0;
    String output = "";
    while ( i < history.length && history[i] !=
    ory[i] != null )
    output += history.toString () + "\n";
    i++;
    return output;     
    public void deductFee(double fee)
    if (transactions > NOFEE_WITHDRAWALS)
    {  fee = TRANSACTION_FEE *(transactions -
    ansactions - NOFEE_WITHDRAWALS);
    super.withdraw(fee);
    balance -=fee;
    transactions = 0;
    public interface IncursFee {
    public abstract void deductFee(double fee);
    public abstract class Transaction {
    protected double initBal;
    protected double tranAmt;
    // constructor
    // why protected? make it public.
    protected Transaction(double bal, double amt) {
         initBal = bal;
         tranAmt = amt;
    abstract public String toString();
    public class Withdrawal extends Transaction
         private double initBal;
         private double amount;
    private static NumberFormat fmt =
    = NumberFormat.getCurrencyInstance();
         public Withdrawal (double bal, double amt)
              super (bal, amt);
              initBal = bal;
              amount = amt;
         public String toString ()
    return "Balance : " + fmt.format(initBal) + "\n" +
    + "Withdrawal : " + fmt.format(amount);
    import java.text.NumberFormat;
    public class Deposit extends Transaction
         private double initbal, balance;
         private double amount;
    private static NumberFormat fmt =
    = NumberFormat.getCurrencyInstance();
         public Deposit (double bal, double amt)
         super (bal, amt);
         initbal = bal;
         amount = amt;
         public String toString ()
    return "Balance : " + fmt.format(initbal) + "\n" +
    + "Deposit : " + fmt.format(amount);
    public class TestCheckingAcct {
    public static void main(String[] args) {
    BankAccount b1 = new CheckingAccount("Harry",
    , "1234", 500.0);
         System.out.println (b1.getBalance ());
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.deposit(50);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.deposit(10);
         b1.withdraw(1);
         System.out.println(b1.getStatement());
    // This interface specifies the functionality
    requirements of a bank
    public interface Bank {
    public abstract int openNewAccount(String
    String customerName, String customerPIN, String
    accType, double initDepAmount);
    public abstract void processWithdrawal(int
    (int accNum, String pin, double amount);
    // executes a deposit on the specified acct by
    t by the amount
    public abstract void processDeposit(int accNum,
    Num, String pin, double amount);
    // returns the balance of acct
    public abstract double processBalanceInquiry(int
    (int accNum, String pin);
    // returns summary of transactions
    public abstract String
    ring processStatementInquiry(int accNum, String
    pin);
    import java.util.ArrayList;
    public class MyBank implements Bank
    private ArrayList<BankAccount> savAccounts =
    unts = new ArrayList<BankAccount>(); //dynamically
    grows
    private ArrayList<BankAccount> chkAccounts =
    unts = new ArrayList<BankAccount>(); //dynamically
    grows
    private SavingsAccount sav;
    private CheckingAccount chk;
    private int accNum;
    private String customerName, customerPIN,
    erPIN, accType, pin;
    private double initDepAmount, amount, balance;
    public int openNewAccount(String customerName,
    erName, String customerPIN, String accType, double
    initDepAmount)
    this.customerName = customerName;
    this.customerPIN = customerPIN;
    this.accType = accType;
    this.initDepAmount = initDepAmount;
    if ( accType.equals("Savings"))
    BankAccount savAcct = new
    vAcct = new SavingsAccount(customerName, customerPIN,
    initDepAmount);
    try
    savAccounts.add(savAcct);
    catch (ArrayIndexOutOfBoundsException
    Exception savAccounts)
    return savAcct.getAcctNum();
    else
    CheckingAccount chkAcct = new
    hkAcct = new CheckingAccount(customerName,
    customerPIN, initDepAmount);
         try
    chkAccounts.add(chkAcct);
    catch (ArrayIndexOutOfBoundsException
    Exception chkAccounts)
    return chkAcct.getAcctNum();
    public void processWithdrawal (int accNum,
    accNum, String pin, double amount)
         this.accNum = accNum;
         this.pin = pin;
         this.amount = amount;
    if (accNum >10000 && accNum < 20000)
         chk.withdraw (amount);
    if (accNum >50000 && accNum <60000)
         sav.withdraw (amount);
    public void processDeposit (int accNum, String
    String pin, double amount)
         this.accNum = accNum;
         this.pin = pin;
         this.amount = amount;
    if (accNum >10000 && accNum < 20000)
         chk.deposit (amount);
    if (accNum >50000 && accNum <60000)
         sav.deposit (amount);
    public double processBalanceInquiry (int accNum,
    String pin)
         this.accNum = accNum;
         this.pin = pin;
         this.balance = 0;
    if (accNum >10000 && accNum <20000)
         balance = chk.getBalance ();
    if (accNum >50000 && accNum <60000)
         balance = sav.getBalance ();
    return balance;
    public String processStatementInquiry(int accNum,
    m, String pin)
         this.accNum = accNum;
         this.pin = pin;
         this.statement = "";
    if (accNum >10000 && accNum <20000)
    statement = chk.getStatement ();
    if (accNum >50000 && accNum <60000)
    statement= sav.getStatement ();
         return statement;
    Very bad style with those brace placements. Pick a style and stick with it. Consistency is the key.
    Your code isn't very readable.
    You don't have a SavingsAccount here anywhere, even though your MyBank uses one.
    You use JDK 1.5 generics yet you've got ArrayList as the static type on those declarations. Better to use the interface type List as the compile time type on the LHS.
    You have a lot of compile time problems, and some incomprehensible stuff, but I was able to change it enough to my TestCheckingAcct run to completion. No NPE exceptions.
    I'm not sure I agree with your design.
    No SavingsAccount. The accounts I have ALL incur fees - no need for a special interface there. Savings accounts are usually interest bearing. That's the way they behave differently from checking accounts. Where do you have that?
    You rewrite too much code. If you put behavior in the abstract BankingAccount class (a good idea), the whole idea is that concrete classes that extend BankingAccount don't need to overload any methods whose default behavior is correct for them.
    I don't know that I'd have separate Deposit and Withdrawal to implement Transaction. I'd make Transaction concrete and have starting balance, ending balance, and a transaction type String (e.g., "DEPOSIT", "WITHDRAWAL")
    It'd be good to see some thought put into exception handling. I don't see an OverdrawnException anywhere. Seems appropriate.
    No transfer methods from one account to another. I often do that with my bank.
    That's enough to get started.

  • Very simple EJB 3.0 MDB but I get NullPointerException

    I tried to create a very simple EJB 3.0 Message Driven Bean in JDeveloper 10.1.3.2 as follows:
    Message Driven Bean Class:
    import javax.ejb.MessageDriven;
    import javax.jms.Message;
    import javax.jms.MessageListener;
    @MessageDriven(mappedName="MDBQueue")
    public class MDB implements MessageListener {
    public void onMessage(Message message) {
    System.out.println("Got message!");
    Application Client:
    import javax.annotation.Resource;
    import javax.jms.*;
    public class MDBAppClient {
    @Resource(mappedName="MDBQueueConnectionFactory")
    private static QueueConnectionFactory queueCF;
    @Resource(mappedName="MDBQueue")
    private static Queue mdbQueue;
    public static void main(String args[]) {
    try {
    QueueConnection queueCon = queueCF.createQueueConnection();
    QueueSession queueSession = queueCon.createQueueSession
    (false, Session.AUTO_ACKNOWLEDGE);
    QueueSender queueSender = queueSession.createSender(null);
    TextMessage msg = queueSession.createTextMessage("hello");
    queueSender.send(mdbQueue, msg);
    System.out.println("Sent message to MDB");
    queueCon.close();
    } catch(Exception e) {
    e.printStackTrace();
    But I get the following error:
    java.lang.NullPointerException
         at model.MDBAppClient.main(MDBAppClient.java:17)
    I read similar problem in the this thread:
    Re: message driven bean on ejb 3.0 does not work
    some one said that the version in ejb-jar.xml must be changed from 2.1 to 3.0
    but in this case there is no ejb-jar.xml.
    ( I have other cases with ejb-jar.xml file but I can't change the version in ejb-jar.xml)
    the version in web.xml is 2.4 but it not accept any value except 2.4 and an error occur when I tried to change it to 3.0
    please can you tell me why I get NullPointerException and how can I allow EJB 3.0 MDB and JMS to work in JDeveloper

    Note that you can't run MDBs in the embedded OC4J in JDeveloper - try deploying to a stand-alone install of OC4J and see if it works there.

Maybe you are looking for

  • Cross-reference notes

    FM 7.2 I wish to maintain conceptual consistency between two portions of text. I'm curious as to the best way to inform the FM user, but not the document reader, of the connection between the two portions of text. I refer to this concept as cross-ref

  • Text insertion problem with 'Share' applications

    When I add photos to an email in iPhoto (9.3) using the templates and try to insert text, the "insert your message here" dialogue cannot be removed and my text sustituted.  Also the same situation in the book and card creation programs. This is just

  • Using mail with hotmail accounts/university accounts..

    I have a hotmail account and a university e-mail and was wondering if I would use those through mail? Because I know the only way to send things in pdf's from pages, lets say, is through mail.

  • How to get ringtones if file sharing wont show up after sync

    after i  sync iphone itunes will not show filesharing to add ringtones, have had other friends with iphone5 come over they cant figure out even tho they can do on theres.  Please help =)

  • How do I bring "focus" to a window?

    I'm trying to improve my workflow in FCP and sometimes find myself a bit frustrated. For example, when I am in the Viewer window fiddling with filter parameters, I want to suddenly switch down to the Sequence in the Timeline window. On a PC I would p