• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Printer Applets that use Jar Files

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi There,
I'm having some problems printing a java applet that uses a jar file. I have signed and verified signing
with verisign certificate. When I try to print the applet I get the following error in the IE java console
window:
got frame
com.ms.security.SecurityExceptionEx[testapp/testapp.actionPerformed]
at com/ms/security/PolicyEngine.deepCheck
at com/ms/security/PolicyEngine.checkPermission
at com/ms/security/StandardSecurityManager.chk
at com/ms/security/StandardSecurityManager.checkPrintJobAccess
at com/ms/awt/WToolkit.getPrintJob
at testapp/testapp.actionPerformed
at java/awt/Button.processActionEvent
at java/awt/Button.processEvent
at java/awt/Component.dispatchEventImpl
at java/awt/Component.dispatchEvent
at java/awt/EventDispatchThread.run
Exception occurred during event dispatching:
com.ms.security.SecurityExceptionEx[testapp/testapp.actionPerformed]
at com/ms/security/PolicyEngine.deepCheck
at com/ms/security/PolicyEngine.checkPermission
at com/ms/security/StandardSecurityManager.chk
at com/ms/security/StandardSecurityManager.checkPrintJobAccess
at com/ms/awt/WToolkit.getPrintJob
at testapp/testapp.actionPerformed
at java/awt/Button.processActionEvent
at java/awt/Button.processEvent
at java/awt/Component.dispatchEventImpl
at java/awt/Component.dispatchEvent
at java/awt/EventDispatchThread.run
One site I read said that I has to convert my HTML files using Sun's html converter so I tried this
but now when I try to print I the printer dialog box comes up but I get the following error in the Java
console window and a blank page is printed (you can see here it's not even getting the frame)

Exception occurred during event dispatching:
java.lang.NullPointerException
at sun.awt.windows.WGraphics.clone(Unknown Source)
at sun.awt.windows.WPrintGraphics.clone(Unknown Source)
at sun.java2d.SunGraphics2D.create(Unknown Source)
at sun.awt.windows.WPrintGraphics.create(Unknown Source)
at sun.awt.windows.WPrintGraphicsWrapper.create(Unknown Source)
at sun.awt.windows.WPrintJob.getGraphics(Unknown Source)
at testapp.testapp.actionPerformed(testapp.java:52)
at java.awt.Button.processActionEvent(Unknown Source)
at java.awt.Button.processEvent(Unknown Source)
at java.awt.Component.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)

Please help!! I have to use 1.1.8 in this example and this code also has to work on the MAC. Am
I going to have to use a Java Plugin and is there one available for the MAC? Any information/help
you can provide will be greatly appreciated. Here is my test code:
public class testapp extends Applet implements ActionListener {
private Button print;
public void init() {
print=new Button("print");
print.addActionListener(this);
add(print);
}
//get the browser frame (to use as the owner when creating a dialog)
private Frame getBrowserFrame() {
Container c = this.getParent();
while (c != null) {
if (c instanceof Frame) {
System.out.println("got frame");
return((Frame)c);
}
c = c.getParent();
}
return ((Frame)c);
}
public void actionPerformed(ActionEvent e) {
PrintJob pj = getToolkit().getPrintJob(getBrowserFrame(), "printing" , null);
if (pj != null) {
System.out.println("got print job");
Graphics pg = pj.getGraphics();
System.out.println("after got graphics");
if (pg!=null) {
System.out.println("got graphics");
printComponents(pg);
System.out.println("printed components");
pg.dispose();
System.out.println("dispose graphics");
} else {
System.out.println("graphics is null");
}
pj.end();
} else {
System.out.println("printjob is null");
}
System.out.println("ending printing");
}
}
Thanks,
Naomi
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Naomi,
You only need to use the Sun HTML converter if you want to use Java2 on browsers by using the plug-in.
Go back to your original HTML file.
You need to actually ask the user for permission to perform any I/O unders Java 1.1.x and browsers. You need to have something like the following lines in your java code:
com.ms.security.PolicyEngine.assertPermission(com.ms.security.PermissionID.FILEIO); com.ms.security.PolicyEngine.assertPermission(com.ms.security.PermissionID.UI); com.ms.security.PolicyEngine.assertPermission(com.ms.security.PermissionID.USERFILEIO); com.ms.security.PolicyEngine.assertPermission(com.ms.security.PermissionID.SYSTEM);
I am not sure which one (or more) you need.
Regards,
Manfred.
 
Naomi Proctor
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Manfred,
I did what you suggested below but I am still
getting and com.ms.security exception thrown
(see below). Is this because I'm using Verisign
to sign my certificate but Verisign requires
use of the Java plugin. If so, what should I do now? Is there a Java plugin for the Mac? I also read something about self-signed/ing certificates. Is there something else I might be
doing wrong here?
Thanks in advance,
Naomi
hello
got printing permission
got file io permission
got ui permission
got userfileio permission
got system permission
got clientstore permission
got exec permission
got multimedia permission
got netio permission
got property permission
got reflection permission
got registry permission
got security permission
got sysstreams permission
got thread permission
file writer test
com.ms.security.SecurityExceptionEx[testapp/testapp.actionPerformed]: cannot access file c:\output.txt
at com/ms/security/permissions/FileIOPermission.check
at com/ms/security/PolicyEngine.deepCheck
at com/ms/security/PolicyEngine.checkPermission
at com/ms/security/StandardSecurityManager.chk
at com/ms/security/StandardSecurityManager.checkWrite
at java/io/FileOutputStream.<init>
at java/io/FileWriter.<init>
at testapp/testapp.actionPerformed
at java/awt/Button.processActionEvent
at java/awt/Button.processEvent
at java/awt/Component.dispatchEventImpl
at java/awt/Component.dispatchEvent
at java/awt/EventDispatchThread.run
Exception occurred during event dispatching:
com.ms.security.SecurityExceptionEx[testapp/testapp.actionPerformed]: cannot access file c:\output.txt
at com/ms/security/permissions/FileIOPermission.check
at com/ms/security/PolicyEngine.deepCheck
at com/ms/security/PolicyEngine.checkPermission
at com/ms/security/StandardSecurityManager.chk
at com/ms/security/StandardSecurityManager.checkWrite
at java/io/FileOutputStream.<init>
at java/io/FileWriter.<init>
at testapp/testapp.actionPerformed
at java/awt/Button.processActionEvent
at java/awt/Button.processEvent
at java/awt/Component.dispatchEventImpl
at java/awt/Component.dispatchEvent
at java/awt/EventDispatchThread.run

Originally posted by Manfred Leonhardt:
Hi Naomi,
You only need to use the Sun HTML converter if you want to use Java2 on browsers by using the plug-in.
Go back to your original HTML file.
You need to actually ask the user for permission to perform any I/O unders Java 1.1.x and browsers. You need to have something like the following lines in your java code:
com.ms.security.PolicyEngine.assertPermission(com.ms.security.PermissionID.FILEIO); com.ms.security.PolicyEngine.assertPermission(com.ms.security.PermissionID.UI); com.ms.security.PolicyEngine.assertPermission(com.ms.security.PermissionID.USERFILEIO); com.ms.security.PolicyEngine.assertPermission(com.ms.security.PermissionID.SYSTEM);
I am not sure which one (or more) you need.
Regards,
Manfred.

 
reply
    Bookmark Topic Watch Topic
  • New Topic