0

My below code works fine on running from NetBeans IDE

 public Selector() {
        try {

            if (count == 0) {
                initComponents();
                count++;
                ims.CPool.configureConnPool();
                fillTable();
                setResizable(false);
                Dimension Size = Toolkit.getDefaultToolkit().getScreenSize();
                setLocation(new Double((Size.getWidth() / 2) - (getWidth() / 2)).intValue(), new Double((Size.getHeight() / 2) - (getHeight() / 2)).intValue());
                jTable1.addMouseListener(this);
                img = ImageIO.read(Selector.class.getResource("/ims/Icons/login.png"));
                sci = img.getScaledInstance(jLabel3.getWidth(), jLabel3.getHeight(), java.awt.Image.SCALE_SMOOTH);
                ImageIcon newIconImage = new javax.swing.ImageIcon(sci);

                jLabel3.setIcon(newIconImage);

            } else {
                throw new myExc("Only one instance of the application is allowed to run at a time !");
            }
        } catch (HeadlessException | IOException | myExc x) {
            x.printStackTrace();
            JOptionPane.showMessageDialog(null,x.getMessage());
        }
    }

Whenever i try to launch the class having the above constructor i get an exception shown below

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: input
 == null!
        at javax.imageio.ImageIO.read(Unknown Source)
        at ims.init.Selector.<init>(Selector.java:60)
        at ims.init.Selector$8.run(Selector.java:502)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$000(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

pls help

1 Answer 1

2

Check what's returned by the getResource() call

img = ImageIO.read(Selector.class.getResource("/ims/Icons/login.png"));

Could be that path is not correct "ims" but could be "imgs"

Sign up to request clarification or add additional context in comments.

2 Comments

getResource() returns: file:/G:/IMS/build/classes/ims/Icons/login.png
Obviously it's null. Add the check in the line by e.g. wrapping it into try/catch

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.