deployJava.runApplet() with cache

859 views
Skip to first unread message

br...@databaseknowledge.com

unread,
Apr 19, 2013, 10:15:39 AM4/19/13
to jzebra...@googlegroups.com
I have been experimenting with deployJava() / caching and I think I may have it working.  I wanted to share this with the community and see if anyone may have any suggestions or comments:

Add this code exactly in the same place the where the <applet> tag would normal appear in the html:

    <script src="https://java.com/js/deployJava.js"></script>
    <script>
        var attributes = {codebase:"/jscripts/jprint/jZebra1.4.7/dist",
                          code:"jzebra.PrintApplet.class",
                          archive:"jzebra.jar",
                          name: "jzebra",
                          cache_option:"plugin", 
                          cache_archive:"jzebra.jar",
                          cache_version:"0.1.4.7", 
                          width:50, 
                          height:50} ;
        var parameters = {printer:"zebra"} ;
        var version = "1.6" ;
        deployJava.runApplet(attributes, parameters, version);        
    </script>

Watching the console is interesting.  The first time this is run the console says things like:

network: Cache entry not found [url: https://mysite.com/jscripts/jprint/jZebra1.4.7/dist/jzebra.jar, version: 0.1.4.7]
network: Connecting http://mysite.com:443/ with proxy=DIRECT
security: Loading Root CA certificates from C:\Program Files (x86)\Java\jre7\lib\security\cacerts
security: Loaded Root CA certificates from C:\Program Files (x86)\Java\jre7\lib\security\cacerts
security: Loading SSL Root CA certificates from C:\Program Files (x86)\Java\jre7\lib\security\cacerts
security: Loaded SSL Root CA certificates from C:\Program Files (x86)\Java\jre7\lib\security\cacerts
security: Loading certificates from Deployment session certificate store
security: Loaded certificates from Deployment session certificate store
Content-Length: 55,410
Content-Encoding: null
network: Wrote URL https://mysite.com/jscripts/jprint/jZebra1.4.7/dist/jzebra.jar?version-id=0.1.4.7 to File C:\Users\myaccount\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\4\145f7b84-4704fa88-0.1.4.7--temp

So you can see the JVM is opening a connection to the web server and pulling down the jar file and then caching on the local file system.


The next time deployJava is run (even from a different browser page) the console says:

network: Cache entry found [url: https://mysite.com/jscripts/jprint/jZebra1.4.7/dist/jzebra.jar, version: 0.1.4.7] prevalidated=false/0
network: Created version ID: 0.1.4.7

The JVM skips the network communication to download the jar files and uses the cached version. (nice!)

I think this is going in the right direction.  A few things I would like to learn:  
1.  What does prevalidated=false/0 mean? 
2.  Is there a way to dynamically deployJava() so that the applet tag can be added to DOM only when needed?

 


Tres Finocchiaro

unread,
Apr 19, 2013, 10:22:50 AM4/19/13
to jzebra...@googlegroups.com
Brian,

Thanks for your research on this.  I have found very, very, very little on deployJava. I searched for a long time last night.

I did find dtjava, which is the updated version for JavaFX, but again, mixed reviews and very little help.

The issue I had with deployJava is that it was doing a document.write() and erasing the webpage every time it was called.

Were you able to work-around this issue?

I agree that it is a better method for caching the applet, but I know about as much about it as you.

-Tres


 


--
--
To unsubscribe from this group, send email to jzebra-users...@googlegroups.com
 
http://code.google.com/p/jzebra
 
---
You received this message because you are subscribed to the Google Groups "jZebra users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jzebra-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
- Tres.Fin...@gmail.com

br...@databaseknowledge.com

unread,
Apr 19, 2013, 10:50:39 AM4/19/13
to jzebra...@googlegroups.com
I found something on stackoverflow where someone suggested redefining document.write before and and after deployJava call:


I have not tired this approach.  I'll keep messing around with things.  I am not 100% certain how beneficial deployJava() really is, I think makes it easier to users to download the java and a few other things. Using Chrome, you can use "inspect element" and search for "applet" and see the applet tag setting in the DOM.  So the end result of deployJava() is to push the  <applet> into the dom.

It is probably possible to have a local copy of: https://java.com/js/deployJava.js" and change it write the applet to a div.  

In the meantime, for people now wishing to use deployJava, It is also possible to caches the applet using html as:

<applet name="jzebra" 
code="jzebra.PrintApplet.class" 
archive="/jscripts/jprint/jZebra1.4.7/dist/jzebra.jar"
>
<param name="printer" value="zebra">
<param name="cache_option" value="plugin">
<param name="cache_archive" value="jzebra.jar">
<param name="cache_version" value="0.1.4.7">
</applet>

The JVM will use the cache version and bypass the network trip.  This can be saved as javascript string and added into the DOM on demand.


br...@databaseknowledge.com

unread,
Apr 19, 2013, 10:52:41 AM4/19/13
to jzebra...@googlegroups.com
typo correction:

In the meantime, for people not wishing to use deployJava, It is also possible to caches the applet using html as:

capp...@yahoo.com

unread,
Apr 19, 2013, 11:03:31 AM4/19/13
to jzebra...@googlegroups.com
Hello Brian,

deployJava's function, as it name suggests, is to ensure user has correct version of java installed so that the deployment is properly made for the applet. When the user does not have the required version of java installed, it just redirects user to someplace he can download it (as far as I know this is configurable but never tried it)

Bahadir


From: "br...@databaseknowledge.com" <br...@databaseknowledge.com>
To: jzebra...@googlegroups.com
Sent: Friday, 19 April 2013, 17:50
Subject: Re: [jZebra] deployJava.runApplet() with cache

I found something on stackoverflow where someone suggested redefining document.write before and and after deployJava call:


I have not tired this approach.  I'll keep messing around with things.  I am not 100% certain how beneficial deployJava() really is, I think makes it easier to users to download the java and a few other things. Using Chrome, you can use "inspect element" and search for "applet" and see the applet tag setting in the DOM.  So the end result of deployJava() is to push the  <applet> into the dom.

It is probably possible to have a local copy of: https://java.com/js/ deployJava.js" and change it write the applet to a div.  

In the meantime, for people now wishing to use deployJava, It is also possible to caches the applet using html as:

<applet name="jzebra" 
code="jzebra.PrintApplet.class" 
archive="/jscripts/jprint/jZebra1.4.7/dist/jzebra.jar"
>
<param name="printer" value="zebra">
<param name="cache_option" value="plugin">
<param name="cache_archive" value="jzebra.jar">
<param name="cache_version" value="0.1.4.7">
</applet>

The JVM will use the cache version and bypass the network trip.  This can be saved as javascript string and added into the DOM on demand.


br...@databaseknowledge.com

unread,
Apr 19, 2013, 9:10:22 PM4/19/13
to jzebra...@googlegroups.com
As I am pressed for time, I decided to go with the <applet> tag instead of the javaDeploy:

<applet name="jzebra" code="jzebra.PrintApplet.class" 
   archive="/jscripts/jprint/jZebra1.4.7/dist/jzebra.jar" 
   style="width:110px; height: 110px; float: left;">
<param name="printer" value="zebra">
<param name="cache_option" value="plugin">
<param name="cache_archive" value="/jscripts/jprint/jZebra1.4.7/dist/jzebra.jar">
<param name="cache_version" value="0.1.4.7">

</applet>

Note that this is a bit different than the syntax I posted earlier.   The  param: "cache_archive" needs a relative path pointing to the jar file (exactly as the Archive attribute).

The console shows the jar file being reused bypassing 1 network round trip.  Web server logs also confirm this.  

That in itself makes the applet load faster than without cache.  Just going off of feel, (sorry no time to benchmark) this is faster than not caching (no duh), and the deployJava() just a tad bit fastest.

So for now, I am going with this.  When time permits I'll look at modifying https://java.com/js/deployJava.js so that the applet is appended into the dom before the </body> tag.


Tres Finocchiaro

unread,
Apr 20, 2013, 9:48:48 AM4/20/13
to jzebra...@googlegroups.com
Thanks again for your time on this Brian.

I will put in a bug report to have the default option to cache this applet. It's fantastic advice and much appreciated research.

-Tres

--
--
To unsubscribe from this group, send email to jzebra-users...@googlegroups.com
 
http://code.google.com/p/jzebra
 
---
You received this message because you are subscribed to the Google Groups "jZebra users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jzebra-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jeroen Evers

unread,
Apr 20, 2013, 10:47:48 AM4/20/13
to jzebra...@googlegroups.com
Regarding the document.write() from javaDeploy:
I used the docWriteWrapper() function from StackOverflow (mentioned before) in my project with jZebra and it works for me!

I have added the extra cache params like this:
var parameters = {
    cache_option: 'plugin',
    cache_archive: APPLET_URL+','+APPLET_LIBS,
    cache_version: '1.4.7'
};

seems to work just fine, I will test the performance boost on monday :)

-Jeroen-



Op zaterdag 20 april 2013 15:48:48 UTC+2 schreef Tres Finocchiaro het volgende:
Reply all
Reply to author
Forward
0 new messages