java error using Matlab GUI

4 次查看(过去 30 天)
Toke Søltoft
Toke Søltoft 2015-2-5
I am getting this (below) error after my script has been running for 3-5 hours. I don't know how long exactly since it is just running in the background. The script continues but e.g. the plot in the GUI stops updating. Anybody have an idea why? Is it a java memory error?
I update my GUI every 10 second by this code:
handles.emptyTable =get(handles.DataTable,'data');
h = {'CH1','CH2','CH3','CH4','CH5','CH6','CH7'};
while true
[results,time,IP_gates,noOfSeq,seq_channels,noDeltaResVolt,...
data_exist] = read_db();
set(handles.TempCur,'String',{'Temperature (C):',...
sprintf('%2.1f',last_temp),'Current (mA):',...
sprintf('%2.1f',last_cur),'Channels:',...
sprintf([num2str(sum(seq_channels)-seq_channels(end)),'-',...
num2str(sum(seq_channels)),'/',num2str(length(GF))])});
if mod(sum(seq_channels(1:end-1)),1) == 0
set(handles.DataTable,'data',handles.emptyTable) %Update table in GUI
s=get(handles.DataTable,'data');
for k=1:seq_channels(end)
s(k,1)=cellstr([num2str(GF(sum(seq_channels(1:end-1))+k,1)),...
',',num2str(GF(sum(seq_channels(1:end-1))+k,2))]);
s(k,2)=cellstr([num2str(GF(sum(seq_channels(1:end-1))+k,3)),...
',',num2str(GF(sum(seq_channels(1:end-1))+k,4))]);
s(k,3)=cellstr([num2str(GF(sum(seq_channels(1:end-1))+k,5)),...
',',num2str(GF(sum(seq_channels(1:end-1))+k,6))]);
s(k,4)=cellstr([num2str(GF(sum(seq_channels(1:end-1))+k,7)),...
',',num2str(GF(sum(seq_channels(1:end-1))+k,8))]);
s(k,5) =num2cell((Volt(noDeltaResVolt-1)/last_cur)*...
GF(sum(seq_channels(1:end-1))+k,9));
end
set(handles.DataTable,'data',s)
%Plot data
axes(handles.PlotDecay)
cla(handles.PlotDecay, 'reset')
counter = 1;
cmap = hsv(seq_channels(end)); %Create x numbers of colors
for j=1:seq_channels(end)
semilogx(IP_gates,IP(counter+1:counter+12),'-x',...
'Color',cmap(j,:),'LineWidth',2,'MarkerSize',10)
if j ~= seq_channels(end)
counter = counter +13; %Jump to next IP values
end
hold on;
ylabel('Chargeability (mV/V)');
xlabel('Time (seconds)');
title('IP decay');
end
legend(h(1:seq_channels(end)));
end
pause(10)
end
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at com.sun.java.swing.plaf.windows.WindowsTableHeaderUI$XPDefaultRenderer.paint(Unknown Source) at javax.swing.CellRendererPane.paintComponent(Unknown Source) at javax.swing.plaf.basic.BasicTableUI.paintCell(Unknown Source) at javax.swing.plaf.basic.BasicTableUI.paintCells(Unknown Source) at javax.swing.plaf.basic.BasicTableUI.paint(Unknown Source) at javax.swing.plaf.ComponentUI.update(Unknown Source) at javax.swing.JComponent.paintComponent(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JViewport.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JLayeredPane.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JLayeredPane.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paintToOffscreen(Unknown Source) at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source) at javax.swing.RepaintManager$PaintManager.paint(Unknown Source) at javax.swing.RepaintManager.paint(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source) at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source) at sun.awt.SunGraphicsCallback.runComponents(Unknown Source) at java.awt.Container.paint(Unknown Source) at java.awt.Window.paint(Unknown Source) at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source) at javax.swing.RepaintManager.access$700(Unknown Source) at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source) 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)
  1 个评论
Georg Kratz-Kummetz
This NPE has a long history (since 2004); Problem is that by various reasons windows sets the header variable in WindowsTableHeaderUI$XPDefaultRenderer to null. One Reason could be that there is a screen saving mechanism whith your longterm running program; if you don´t need WindowsLookAndFeel don´t use it, and the error will disappear. G.F. Kratz-Kummetz

请先登录,再进行评论。

回答(2 个)

Martin Caron
Martin Caron 2017-5-15
I have the exact same problem and I need help too!

Cam Salzberger
Cam Salzberger 2017-5-15
编辑:Cam Salzberger 2017-5-15
Hello Toke and Martin,
It really depends on what release of MATLAB you are using. There are issues with Java discovered in earlier releases of MATLAB that have been fixed in later versions of it. Here are some general strategies that can help avoid this though:
1) Generally try to use the latest release of MATLAB, if compatible with your OS.
2) If you are not currently using the JRE that shipped with MATLAB, I'd suggest using it. MATLAB is qualified to work with the shipped JRE, but no guarantees about any other Java version. If you're not certain if it is using the shipped version, check the "MATLAB_JAVA" environment variable. If that environment variable is unset, MATLAB should be using the shipped JRE.
3) If your Windows theme changes, or anything else changes the look-and-feel of Windows, this can cause issues with Java. For example, using any kind of screen-sharing or remote-access software generally changes the Windows look-and-feel, and can cause this error. I would recommend closing MATLAB before using anything like that.
4) Similar to above, changing your display settings while MATLAB is running can cause this issues. Check out this bug report.
5) As a last resort, you can try changing the JRE that MATLAB uses to a newer version of Java. I would highly recommend having the latest release of MATLAB possible before doing this though. MATLAB is not guaranteed to work with other Java versions though, but it may resolve the issue. See this post for instructions.
Also, Martin, many Java errors related to graphics look the same. In this case, I would double-check that you are also getting this part in the first line of the error:
WindowsTableHeaderUI$XPDefaultRenderer.paint
before assuming it's the same thing. Still, these tips are generally good to follow, they just may not apply to your specific error.
-Cam

类别

Help CenterFile Exchange 中查找有关 Call Java from MATLAB 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by