I am trying to update the cache for an applet. The applet properly caches, but afterwards, no matter how stale the cache is, it won't update. If I manually delete the cache, a new one will be created upon the next page load, and all changes to the .jar file I am trying to cache take effect. Having to do this, though, is not acceptable.
I have tried using cache_archive in conjunction with cache_version in my index file like so:
if (navigator.appVersion.indexOf("Win")!=-1){
var attributes = { id:'manager', code:'HardwareManagerApplet_FileWriter', width:1, height:1} ;
var parameters = {jnlp_href: '/java/HardwareManagerApplet.jnlp', codebase: '/java/hardwaremanager.jar', cache_archive:'hardwaremanager.jar', cache_version:'0.0.0.7'};
check = deployJava.runApplet(attributes, parameters, '1.6');
hardware_enabled = true
console.log("Applet started")
}
This is having no effect. I have tried moving cache_archive and cache_version to attributes and as various permutations between to no avail. I have tried enabling cache_option set to first browser, then tried again setting it to plugin. No dice. I've looked into ETags, and I'm not confident that will be the best solution. I've also looked into last-Modified, but A) I'm not sure how to implement it into the http so the cache will update and B) that will open a whole new can if I have to go that route.
Is there any other reasonable alternative? Better yet, am I simply implementing cache_archive et al incorrectly?
And actually, even if I can get it to cache every single time the page loads, I will be satisfied.
Thanks for all and any help!
Edit: The block of code about is the ONLY implementation I've made of cache_archive etc. Do I need to put in a couple lines elsewhere? As far as Oracle's documentation went, I didn't find that to be very clear.
Your missing the parameter for the cache option they are as follows
The cache_option attribute can take one of three values:
No - Disable applet installation. Always download the file from the web server.
Browser - Run applets from the browser cache (default).
Plugin - Run applets from the new Java Plug-in cache.
By defaulting to browser you would have to clear the browser cache for the updated values to take effect. Use plugin to take full advantage of the versioning you want to implement.
The caching of an applet is the work of both the virtual machine (JVM) and your browser. The browser as well as the JVM are optimized for caching applet for performance purpose.
My solution were one of both:
Clear the cache of the virtual machine after every classes build: open the Java console and type x (ClassLoader-Cache clear). Then refresh your browser.
or
Close your browser and start it all afresh
I prefer solution 1.
Related
I've to get all active browsers that are opened in the local machine along with corresponding session ids.
I've made little research and i do find the below link.
It's giving the active browser name which is not enough though
I know there is some plugin's available to get the sessions but i need to do it programmatically.
Thanks in advance!!
Short answer: it's impossible.
Long answer: Nothing distinguish browser from any other program. In fact many programs have browser functionality embedded in it.
If you define browser as one of known program such as "Firefox", "Chrome", "IE" etc. than you can do something to achieve some result.
First of all: forget about Java, you need to work with Win-API and Java is not best solution to do it.
You can enumerate process and find browsers by executable name.
Then you can check each browser documentation to find if there any integration API. Each browser will have its own API (or do not have).
Then using this API you can extract what is available.
So it will be hard if even possible to get what you want.
I am working on web app with jquery, jqueryui, ajaxify and many jquery extensions.
At some point in the application I have to use Java applet.
The applet is run via ajax call, let's say jquery.load loads a page that generates applet code. I would like then to detect if Java is installed on the computer running the app, and if it is version 1.7+. The detection should occur only if applet is going to be used, since this functionality is to be used by limited number of users and only in certain circumstances.
I can't use deploy.js, as this script was not designed to be run via ajax call and simply fails.
I would like to detect java only when it it really needed, i.e. when user is going to launch the applet.
How can I do that?
I will appreciate your help.
You should use Java Deployment Toolkit in any case. When I need to some specific checks I open the java_deploy.js and see how this works. It not so hard to understand, really. For example, in Chrome it just inserts a specific tag with certaing uid. Nothing complicated. Then I just exec the code doing this manually.
At the end of deploy.js it just launch Java check after the page load. One method call. I've just removed this code and launch it manually in my own code.
Finally I found a way to detect if java is installed.
At first I tried with navigator.javaEnabled(), but it didn't work properly with IE.
Then I tried Java deployment toolkit, but didn't succeed due to window.write which was not compatible with pages fetched via ajax.
Then I tried to customize Java deployment toolkit following odiszapc advice ... but by the end of the day I used unmodified Java development toolkit, simply I used its versionCheck method.
If java is not detected, the user is told to download and install JRE, and link is provided.
If correct version of Java is installed then the subpage is reloaded via ajax with parameter javaOK=1. In such a case there is no java detection, just pure applet tags, in short:
$SuccessUrl = FileName . "?javaOK=1&" . $_SERVER['QUERY_STRING'];
(...)
$java_detect=EOQ (heredoc shoud be here, some tags don't work)
var version = '1.7'; //required version
var check = deployJava.versionCheck(version+"+"); //1.7 and higher
if(!check){
$("#sign_dialog").html("$java_err"); //wrong java or no java at all
}else{
$("#sign_dialog").load("$SuccessUrl");
}
EOQ;
(...)
if(isset($_GET['javaOK']) && $_GET['javaOK']=='1'){
echo $applet;
}else{
echo $java_detect;
}
I need some advice on how to load a big applet.
I need to make an instance of JWord text editor to work as an applet, but the editor is about 4 mb.
I'm aware of the java web start solution, but my boss doesn't like it, so I'm stuck with the applet solution.
What I would like to ask you is on how to reduce the user waiting time.
JWord needs about 10 external libraries, so the question here is:
-pack up all in a single big jar?
-make the jars load singularly?
I'm putting this in a jsp page, but the last time I developed an applet the tag "applet" was not deprecated. Now I saw that it's been substituted with "object" tag, can someone help me with that? Point the similarities/differences?
And finally, since this is a big applet, I would like to know if there's the possibility to remove the grey box in the waiting, maybe putting a loading bar in replacement? If so please provide examples! Never done that before..
Thank you
In deference to Thorbjørn Ravn Andersen, I think 4meg is a huge download for an applet. Perhaps that is just me talking from the perspective of my very slow wireless connection. Some people have gone (significantly) further in applet size on LANs with high bandwidth.
Decrease the size of the download.
Use Pack200
& obfuscation (one of the few end purposes for which obfuscation is well suited).
Provide information to the user as applet loads.
Before the applet loads
See Special Attributes of Applets - image.
image The image attribute allows you to replace the default animation with a custom graphic.
Use an animated GIF like the one below, to indicate that something is happening.
(Image courtesy of http://www.ajaxload.info/)
After a tiny 'splash' applet loads
Trusted? Loader applet using URLClassLoader for the bulk of the download. Pop a
JProgressBar for the downloads after the initial 'splash applet'.
JWS versus standard deployment
You seem to be assuming a 'JWS solution' will result in a free-floating app. That is not the case since the Plug-In 2 JRE (Sun's 1.6.0_10+). As mentioned in the info. page on the applet tag - visit that page and chase the links for more details.
To use the JWS abilities you might have:
One jar for compatibility applet (used by a pre Plug-In 2 JRE). This results in one single HTTP request & a slightly smaller1 final Jar. (1) Smaller than the total size of a number of Jars.
Multiple Jars for JWS/Plug-In 2 JRE. Lazy loading of dependent Jars by the JRE as needed, or programmatically using the DownloadService classes.
See also the JWS info. page for more information on JWS generally.
Deploying the applet- applet vs. object.
Don't hard-code HTML for it, use the deployJava.js script referred to in both info. pages linked above.
There is nothing wrong with having a large applet, and the dependent jar referred to from the invocation snippet in HTML.
See the applet trail in the Java tutorial - http://docs.oracle.com/javase/tutorial/deployment/applet/deployingApplet.html
Note that there is a limit to the memory available to an applet, and - especially for older Java deployments - this may be too small for your application. In that case the easiest way is most likely the Java WebStart (which for Java 6 supports Applets too) where you can specify your memory needs.
You can shrink your program with the Free and Open Source program proguard. It takes big jars, and removes every class which isn't used.
Still trying to decide which application will suit : current options JxBrowser vs SWT widget.
Java application implements a webbrowser control like JxBrowser or SWT browser control. Both of these provide options to pass info from java to javascript.
Now I need to know: Is it possible not to save the html/css/javascript file into the cache? Is it possible to have java serve the content as input (looks like this is possible with SWT, unsure of JxBrowser).
Essentially I don't want to have temporary files, either in the cache or in temp folder, and I want to feed the information from an input stream.
Or do you have to roll/embed your own browser to avoid having all saved to cache?
Perhaps for clarity: I am asking if these two programs offer defined methods when implementing their own browser from within java, to not cache, and if you can stream input directly to serve the html / css/ javascript content.
I understand the no-cache methods in a webbrowser, here I am simply asking whether embedding the browser behaves in the same way. The documentation does not seem very specific about this issue, but perhaps I need to look more.
On further looking it looks like it saves files to cache. Secondly, methods like clearing the cache are so non-specific that if you call clear cache function you happen to have to empty the clients entire cache. Argh....
It's possible to render HTML from memory by SWT Browser widget. I'm not sure how is it with caching those pages (it may depend on used browser), but it seems reasonable not cache those pages.
See SWT Browser snippets for additional info about rendering HTML from memory.
I have a Java Applet application ( achart) on my php Webpage ... Problem here is the Java Applet takes more time to load ... I am thinking of replacing these applets with some similar technology but fast ... I am counting on Ajax... what are my other options ... ?
Java applets load slowly. shrug Its the nature of the beast....
If you have multiple jars, you should check the order of the classpath you provide to your applet. Note that each jar is only downloaded "on demand" whenever a class needs to be loaded. It looks in the first jar, if it can't find the class it looks in the second and so on... You can reduce your startup time by ensuring that all of your classes required for starting up the app are in the first jar(s) listed.
Also, if you are attempting to load a class or resource which is not in your classpath, it must search through all the jars before returning AND hit the server codebase to look there. It can potentially greatly reduce your startup time.
Turn on applet tracing in the java control panel and you should get a better idea of how classes are being loaded out of the jars.
If the size of the applet's JAR library takes to long to download, you can shrink the size with the ProGuard tool. Here is a comparison of the compression ratio for some Java libraries.
Have you packed your jars.....
Have you tried Java deployment toolkit (http://blogs.oracle.com/vaibhav/entry/java_deployment_toolkit_6u10)
with jdk 1.6.10+.....
If its simple charts you want, have a look at:
http://code.google.com/apis/chart/
Yahoo has some nice charting components for actionscript 3 (flash) http://developer.yahoo.com/flash/astra-flash/charts/
Google has a service that will generate charts as images as Tim already pointed out.
Alternatively you could try to speed up the delivery of the applets that you are using - check if they have an Expires header so they only get downloaded once in a while instead of for every page (this won't help on the first view, but will speed up those after that)
Edit: if you only target specific browsers you could try and create the charts using javascript and the Canvas element, but that is definitely not supported by internet explorer. https://developer.mozilla.org/en/Canvas_tutorial
I know this answer is a bit late but, it could be that you are just being very inefficent with java or your machine is slow, I have a java program that has quite alot of code as well as accessing an SQLite DataBase and it runs quite quickly, loading within five seconds. If you have anything you don't use in your program then remove it, also try jaring and signing it(not sure if last two things would help.)