Java exception error

Hello,

Normally my code works fine, but sometimes when I try to rerun my code, mid-calculation it produces this error message. What might cause this error? How would I debug my code (it says there is an error on line 180 for example my code is no even 180 lines)?

edit: I’m pretty sure the problem is with my Dynare setup, since I also get the same error with other code. So the code works 1st time and then when I try to rerun it, it produces this error.

[code]Error using alternatePrintPath>LocalSetPaintDisabled (line 1111)
Java exception occurred:
java.lang.NullPointerException

at com.mathworks.hg.peer.FigureClientProxy.swapShowHandler(FigureClientProxy.java:591)

at com.mathworks.hg.peer.FigureClientProxyPanel.setPaintDisabled(FigureClientProxyPanel.java:58)

at com.mathworks.hg.peer.PaintDisabled.setPaintDisabled(PaintDisabled.java:60)

at
com.mathworks.hg.peer.HeavyweightLightweightContainerFactory$FigurePanelContainerLight.enablePaint(HeavyweightLightweightContainerFactory.java:335)

at
com.mathworks.hg.peer.HeavyweightLightweightContainerFactory$FigurePanelContainerLight.doSetPaintDisabled(HeavyweightLightweightContainerFactory.java:369)

at
com.mathworks.hg.peer.HeavyweightLightweightContainerFactory$FigurePanelContainerLight.setPaintDisabled(HeavyweightLightweightContainerFactory.java:387)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.mathworks.jmi.AWTUtilities$Invoker$3$1.call(AWTUtilities.java:466)

at com.mathworks.mvm.context.ThreadContext.callWithContext(ThreadContext.java:105)

at com.mathworks.mvm.context.MvmContext.callWithContext(MvmContext.java:113)

at com.mathworks.jmi.AWTUtilities$Invoker$3.runWithOutput(AWTUtilities.java:463)

at com.mathworks.jmi.AWTUtilities$Invoker$2.watchedRun(AWTUtilities.java:416)

at com.mathworks.jmi.AWTUtilities$WatchedRunnable.run(AWTUtilities.java:377)

at java.awt.event.InvocationEvent.dispatch(Unknown Source)

at java.awt.EventQueue.dispatchEventImpl(Unknown Source)

at java.awt.EventQueue.access$200(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 Source)

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)

Error in alternatePrintPath>printCleanup (line 314)

Error in alternatePrintPath>printSetup (line 212)

Error in alternatePrintPath (line 91)

Error in print (line 215)
pj = alternatePrintPath(pj);

Error in dyn_saveas (line 41)
print(h,’-depsc2’,[fname,’.eps’])

Error in stoch_simul (line 256)
dyn_saveas(hh,[M_.fname ‘IRF’ deblank(tit(i,:))],options_);

Error in ramsey_policy (line 25)
info = stoch_simul(var_list);

Error in commitment (line 218)
ramsey_policy(var_list_);

Error in dynare (line 180)
evalin(‘base’,fname) ;[/code]

Unfortunately, the Matlab plot engine is not the most stable one. When it only occurs randomly, this is most probably not a Dynare issue. There is not much you can do, except for closing Matlab and opening it again. Or did your code crash during the first run? In this case, you might need to say

before rerunning the program.

NB: the error message refers to the line in dynare.m, not your mod-file!