Deploying Applet as JNLP

102 views
Skip to first unread message

e...@dark-storm.com

unread,
May 22, 2015, 12:00:02 PM5/22/15
to qz-p...@googlegroups.com
The basic code sample on your website deploys the app using the applet function.

<input type=button onClick="print()" value="Print">
<applet id="qz" name="QZ Print Plugin" code="qz.PrintApplet.class" archive="./qz-print.jar" width="100" height="100">
<param name="printer" value="zebra">
</applet>

<script>
function print() {
var qz = document.getElementById('qz');
qz.append('A37,503,0,1,2,3,N,PRINTED USING QZ-PRINT\n');
// ZPLII
// qz.append('^XA^FO50,50^ADN,36,20^FDPRINTED USING QZ-PRINT^FS^XZ');
qz.print();
}
</script>

When I attempt to run this in my current environment (Chrome 43.0.2357.65 m / Java 8u45) I receive the following error:

General Exception
Name: QZ Print Plugin
SecurityException: JAR should not contrain JNLP-INF/APPLICATION.JNLP

After doing some research the issue seems to be that newer versions of chrome require that the app be launched as a JNLP. Based on info I found, I tried using this code instead, but it returning an uncaught syntaxerror: unexpected token = on line 5.

<input type=button onClick="print()" value="Print">

<script src="https://www.java.com/js/deployJava.js"></script>
<script>
var attributes = { id='qz', archive='./qz-print.jar', name='QZ Print Plugin', code='qz.PrintApplet.class', width:55, height:55 };
var parameters = { jnlp_href: 'qz-print_jnlp.jnlp', cache_option: 'plugin', disable_logging: 'false', initial_focus: 'false' };
deployJava.runApplet(attributes, parameters);
</script>

<script>
function print() {
var qz = document.getElementById('qz');
qz.append('A37,503,0,1,2,3,N,PRINTED USING QZ-PRINT\n');
// ZPLII
// qz.append('^XA^FO50,50^ADN,36,20^FDPRINTED USING QZ-PRINT^FS^XZ');
qz.print();
}
</script>

Does anyone have a basic code set that runs as a JNLP to work with newer versions of chrome and java???

Tres Finocchiaro

unread,
May 22, 2015, 12:26:22 PM5/22/15
to e...@dark-storm.com, qz-p...@googlegroups.com
sample.html has this in the example, as does our demo page at http://demo.qzindustries.com

However, last I checked the <applet> tags work just fine on chrome, but you'll need to provide the path to the JNLP file as a parameter.  This parameter is also provided in sample.html, just search for the commented <applet> tags.

I'm guessing you're coming from an older version of the plugin.  The older versions didn't use JNLP, but once we start using it, it becomes a mandatory parameter whether using the deployJava or <applet> tag method.

PS.  For many, many users, we still recommend the <applet> tag approach.  deployJava is a very poorly written script, despite Oracle feeling it is "recommended".  It uses document.write() which can really mess up a page with a lot of dynamic content.

Furthermore, we're working to get our desktop application finished which will abolish this Java-plugin mess once and for all (disclaimer, we do still use Java in the desktop application, just no longer rely on the NPAPI method for talking to it)

 :)

-Tres

--
You received this message because you are subscribed to the Google Groups "qz-print" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qz-print+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

e...@dark-storm.com

unread,
May 22, 2015, 12:44:44 PM5/22/15
to qz-p...@googlegroups.com, e...@dark-storm.com
Functional Code:

<applet name="qz" code ="qz.PrintApplet.class" width="55" height="55">
<param name="jnlp_href" value="qz-print_jnlp.jnlp" />
<param name="cache_option" value="plugin"/>
<param name="printer" value="Your Printer Name Here">
</applet>

Tres Finocchiaro

unread,
May 22, 2015, 12:58:42 PM5/22/15
to DarkStormIndustries, qz-p...@googlegroups.com
Thanks Ed.

Please note, if you have sporadic loading issues after upgrading to Java 8, we also recommend the separate_jvm parameter.  This is also mandatory for users leveraging the serial port functions.

     <param name="separate_jvm" value="true">
</applet>
Reply all
Reply to author
Forward
0 new messages