Thread Subject: Java Exception on Printing?

Subject: Java Exception on Printing?

From: Rebecca

Date: 24 Sep, 2009 02:09:19

Message: 1 of 8

I'm trying to print out my code, and pressing the print button in the Editor or choosing File/Print seems to cause a Java exception to be thrown. How do I fix this so I can print from MatLab?

I'm running 2009a Student Version on Mac OS X 10.6.1

This is the specific error message that is displayed in the cmd window:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.mathworks.widgets.text.print.PrintSettings.getLastPrintRequestAttributes(PrintSettings.java:280)
at com.mathworks.widgets.SyntaxTextPaneBase.printDocument(SyntaxTextPaneBase.java:2031)
at com.mathworks.widgets.SyntaxTextPaneMultiView.printDocument(SyntaxTextPaneMultiView.java:750)
at com.mathworks.mde.editor.EditorView.doPrint(EditorView.java:1284)
at com.mathworks.mde.editor.EditorView.access$2300(EditorView.java:92)
at com.mathworks.mde.editor.EditorView$8.update(EditorView.java:775)
at com.mathworks.mde.editor.EditorAction$ObservableAction.actionPerformed(EditorAction.java:52)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
at java.awt.Component.processMouseEvent(Component.java:6348)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at com.mathworks.mwswing.MJButton.processMouseEvent(MJButton.java:294)
at java.awt.Component.processEvent(Component.java:6113)
at java.awt.Container.processEvent(Container.java:2085)
at java.awt.Component.dispatchEventImpl(Component.java:4714)
at java.awt.Container.dispatchEventImpl(Container.java:2143)
at java.awt.Component.dispatchEvent(Component.java:4544)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4282)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4212)
at java.awt.Container.dispatchEventImpl(Container.java:2129)
at java.awt.Window.dispatchEventImpl(Window.java:2475)
at java.awt.Component.dispatchEvent(Component.java:4544)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:635)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Subject: Java Exception on Printing?

From: Richard Quist

Date: 24 Sep, 2009 02:21:57

Message: 2 of 8

Rebecca wrote:
> I'm trying to print out my code, and pressing the print button in the Editor or choosing File/Print seems to cause a Java exception to be thrown. How do I fix this so I can print from MatLab?
>
> I'm running 2009a Student Version on Mac OS X 10.6.1
>
> This is the specific error message that is displayed in the cmd window:
>
> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
> at com.mathworks.widgets.text.print.PrintSettings.getLastPrintRequestAttributes(PrintSettings.java:280)
> at com.mathworks.widgets.SyntaxTextPaneBase.printDocument(SyntaxTextPaneBase.java:2031)
> at com.mathworks.widgets.SyntaxTextPaneMultiView.printDocument(SyntaxTextPaneMultiView.java:750)
> at com.mathworks.mde.editor.EditorView.doPrint(EditorView.java:1284)
> at com.mathworks.mde.editor.EditorView.access$2300(EditorView.java:92)
> at com.mathworks.mde.editor.EditorView$8.update(EditorView.java:775)
> at com.mathworks.mde.editor.EditorAction$ObservableAction.actionPerformed(EditorAction.java:52)
> at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
> at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
> at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
> at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
> at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
> at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
> at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
> at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
> at java.awt.Component.processMouseEvent(Component.java:6348)
> at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
> at com.mathworks.mwswing.MJButton.processMouseEvent(MJButton.java:294)
> at java.awt.Component.processEvent(Component.java:6113)
> at java.awt.Container.processEvent(Container.java:2085)
> at java.awt.Component.dispatchEventImpl(Component.java:4714)
> at java.awt.Container.dispatchEventImpl(Container.java:2143)
> at java.awt.Component.dispatchEvent(Component.java:4544)
> at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618)
> at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4282)
> at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4212)
> at java.awt.Container.dispatchEventImpl(Container.java:2129)
> at java.awt.Window.dispatchEventImpl(Window.java:2475)
> at java.awt.Component.dispatchEvent(Component.java:4544)
> at java.awt.EventQueue.dispatchEvent(EventQueue.java:635)
> at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
> at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
> at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
> at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
> at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
> at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
That sounds like this issue: http://www.mathworks.com/support/bugreports/337376

There's a possible workaround mentioned near the bottom of that page

--

Richard Quist
Software Developer
The MathWorks, Inc.

Subject: Java Exception on Printing?

From: Mehmet

Date: 4 Oct, 2009 15:36:01

Message: 3 of 8

Richard Quist <rquist_nospam@mathworks.com> wrote in message

> That sounds like this issue: http://www.mathworks.com/support/bugreports/337376
>
> There's a possible workaround mentioned near the bottom of that page

I don't think it's the same issue. I don't have any network printers, and I get the same message as Rebecca, not the one mentioned in the bug report. I also have the same version as Rebecca, and also on snow leopard.

Subject: Java Exception on Printing?

From: Rebecca

Date: 8 Oct, 2009 19:52:02

Message: 4 of 8

Richard Quist <rquist_nospam@mathworks.com> wrote in message <h9el45$gbg$1@fred.mathworks.com>...
> Rebecca wrote:
<....>
> That sounds like this issue: http://www.mathworks.com/support/bugreports/337376
>
> There's a possible workaround mentioned near the bottom of that page
>
> --
>
> Richard Quist
> Software Developer
> The MathWorks, Inc.

Thanks Richard, but I don't think that's it. I'm trying to print to a printer plugged into my computer via USB. It's not a network printer at all.

I've also tried the various other suggestions for dealing with (what seem to me to be) random Java exceptions - I changed the Java preferences to favour the 32-bit Java VM. I'm at a loss of what to do next though.

-R

Subject: Java Exception on Printing?

From: Richard Quist

Date: 9 Oct, 2009 11:48:49

Message: 5 of 8

Rebecca wrote:
> Richard Quist <rquist_nospam@mathworks.com> wrote in message <h9el45$gbg$1@fred.mathworks.com>...
>> Rebecca wrote:
> <....>
>> That sounds like this issue: http://www.mathworks.com/support/bugreports/337376
>>
>> There's a possible workaround mentioned near the bottom of that page
>>
>> --
>>
>> Richard Quist
>> Software Developer
>> The MathWorks, Inc.
>
> Thanks Richard, but I don't think that's it. I'm trying to print to a printer plugged into my computer via USB. It's not a network printer at all.
>
> I've also tried the various other suggestions for dealing with (what seem to me to be) random Java exceptions - I changed the Java preferences to favour the 32-bit Java VM. I'm at a loss of what to do next though.
>
> -R
I suggest you contact Customer Support. Sometimes the version of Java in use
and the version of CUPS (Common Unix Printing Service) that supports printing
on OS X. They may be able to help identify what's going on.

--

Richard Quist
Software Developer
The MathWorks, Inc.

Subject: Java Exception on Printing?

From: Eric

Date: 19 Oct, 2009 20:57:01

Message: 6 of 8

"Rebecca " <rbemros@siue.edu> wrote in message <h9ekcf$gf8$1@fred.mathworks.com>...
> I'm trying to print out my code, and pressing the print button in the Editor or choosing File/Print seems to cause a Java exception to be thrown. How do I fix this so I can print from MatLab?
>
> I'm running 2009a Student Version on Mac OS X 10.6.1
>

I have the same configuration and problem. It's not a fix, but if you need to get the stuff printed, you can use the Publish feature to get printable HTML or PDF output.

Subject: Java Exception on Printing? (snow leopard)

From: Eduard

Date: 26 Aug, 2010 21:33:22

Message: 7 of 8

"Rebecca " <rbemros@siue.edu> wrote in message <h9ekcf$gf8$1@fred.mathworks.com>...
> I'm trying to print out my code, and pressing the print button in the Editor or choosing File/Print seems to cause a Java exception to be thrown. How do I fix this so I can print from MatLab?

First create a Postscript printer:
1. Go to system preferences -> print & fax
2. Add a printer by clicking the +
3. choose IP (that is the Globe depicted on top)
4. first line "Protocol" select Line Printer Daemon
5. Address: localhost
6. Queue: leave empty
7. Name: e.g. Matlab (or whatever)
8. Location: leave empty
9. Print Using: select Postscript Printer
10. click Add

You now have a postscript printer. Set it as default (so Matlab wants to print to it).
A. When you print from matlab it will pop up a print dialog, choose "print to file". So now you can leave the file some place where you can find it.
B. This will produce a .ps (postscript) file.
C. Go to the place where you saved the file, and double click. This will open the file in Preview (actually it will convert it to PDF first).
D. From Preview you can print the file by selecting your prefered printer.

(Mail me if this is not detailed enough)
Eduard.

Subject: Java Exception on Printing?

From: Stefan

Date: 23 Oct, 2010 01:57:04

Message: 8 of 8

"Rebecca " <rbemros@siue.edu> wrote in message <h9ekcf$gf8$1@fred.mathworks.com>...
> I'm trying to print out my code, and pressing the print button in the Editor or choosing File/Print seems to cause a Java exception to be thrown. How do I fix this so I can print from MatLab?

Hi,

I had the same problem today and I found its because Matlab tries to use the printer name as the queue name, which are usually not the same on Mac OS. Setting the printer name to its queue name seems to fix it for me under Snow Leopard.

To try that yourself, open Mac OS' System Preferences, select "Print & Fax", select your printer, click "Option & Supplies...", change the name in the name field to that display in the "Queue Name" line, click "OK" (, close System Preferences).

You might have to quit and re-open Matlab to fetch the made changes.

Best
Stefan

PS: Alternatively one might find the bug (probably in /Applications/MATLAB_R2010aSV.app/toolbox/matlab/graphics/printdlg.m) and fix it.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
fix Stefan 22 Oct, 2010 21:59:12
exception Stefan 22 Oct, 2010 21:59:12
printing Stefan 22 Oct, 2010 21:59:12
mac os Stefan 22 Oct, 2010 21:59:11
printing problem Eduard 26 Aug, 2010 17:34:28
snow leopard Eduard 26 Aug, 2010 17:34:27
java Rebecca 8 Oct, 2009 15:54:09
mac Rebecca 8 Oct, 2009 15:54:09
snow leopard Rebecca 8 Oct, 2009 15:54:09
java exception Rebecca 23 Sep, 2009 22:09:21
print Rebecca 23 Sep, 2009 22:09:21
rssFeed for this Thread

Contact us at files@mathworks.com