MATLAB: Do I receive a java.lang.​NullPointe​rException when trying to close a file in the HDFTOOL

closefilehdftoolMATLABnullpointerexception

I have several files open in the HDFTOOL GUI. I select one, and then use 'Close file' on the File menu to close it. If I attempt to use 'Close file' again, without selecting another file, I receive the following:
Exception occurred during event dispatching: java.lang.NullPointerException
at com.mathworks.toolbox.matlab.iofun.HDFImporter.removeFile(HDFImporter.java:304)
at com.mathworks.toolbox.matlab.iofun.HDFImporter$MIActionListener.actionPerformed(HDFImporter.java:555)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Best Answer

This bug has been fixed for Release 14 (R14). For previous releases, please read below for any possible workarounds:
This is a bug in MATLAB 6.5 (R13).
The exception can be ignored; the HDFTOOL will continue to function normally after the exception. To prevent the exception, always have a file selected before choosing 'Close File'.
Related Question