Java Applets loading at snail's pace - java

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.)

Related

Evaluating Jsweet for applet to HTML conversion

I have been evaluating Jsweet since the past 4 days in order to finalize a tool that can be used to modernize an application from applet to html5/js based front end. I have been able to try the trial examples where applet based java files are getting transpiled to .js files. As a next step I need to have Jsweet introduced to the an applet based application which has 9 tabs with considerable components like dashboards, report generation related drop downs, date picker elements, tables etc. However this application which I need to modernize is not maven based and hence does not have a pom.xml. It is executed using Tomcat.
Is maven a pre requisite for Jsweet?
My expectations from Jsweet are that if I am able to introduce Jsweet to my codebase like in the example and able to create a build using maven, I should be in a position to get .js files created in the target>js>applet folder. Could these be confirmed please?
You might consider CheerpJ (https://leaningtech.com/cheerpj/) for this project. From your description it seems likely that the applet would work out-of-the-box.
If you want to give quickly give it a try: https://chrome.google.com/webstore/detail/cheerpj-applet-runner/bbmolahhldcbngedljfadjlognfaaein
Full disclosure: I am lead dev of CheerpJ and CTO of LeaningTech.

Self updating game in java

I'm making a game, in Java, that has these following important features:
1) Connects to a remote Server (which i made), and will check for updates and install them if necessary
2) is NOT A SINGLE .JAR FILE (ie. has multiple .jar's and other things, such as .png, .wav, etc)
3) JAVA WEB START IS NOT AN OPTION, AS I WANT TO MAKE THIS ALL MYSELF
keeping the things above in mind, i have run into a problem. i have no clue how to implement a multiple "patch" update system. currently i have 1 .txt file, that the server reads from, and sends the files listed in the .txt to the client, which then moves them into place. The problem is, that is only useful for maybe 2 updates. I'm looking for a more useful, long term solution, and i need some help. here are some of the things i've thought of:
1) have a zip folder named after each version (problem: how would the client get ALL of the most updated files
2) have a .txt file INSIDE of each jar containing the version (problem: cant do that with png's or wav's, and i dont know how i would read the txt file to begin with)
i really need some help, i've tried googling it, i've thought about it for going on 3 weeks now, and cannot think of anything.
QUESTION: how would i make a game/program update with multiple patches?
Firstly, the best solution by a long, long way is to use Webstart / JNLP.
But if you insist on not using it (for whatever reason then) then it is technically possible. However:
It is messy and complicated.
It will either be very inefficient ('cos you have to load the entire program each time the user), or the user has to trust you enough to install your program with permissions that will allow it to install random stuff on his machine without notice.
The way to do it is to split the game into a launcher part and an application part. The launcher needs permissions to write and delete (non-temporary) files, and fetch stuff from the internet. It "calls home" to find out the latest version(s) of the application files, and then downloads and installs them. It has to cope with all sorts of error conditions, and it needs to make sure that nothing can trick it into installing bad stuff on the user's machine, etcetera, is someone spoofs your update service.
Of course, JNLP takes care of all of this, and lots more besides. People are going to be more willing to install the JNLP infrastructure that yours ... which might be insecure, or actively nasty (for all they know). (I for one wouldn't install a self updating application on my machine unless it was supplied by a company with impeccable credentials.)
I think you need here JNLP framework.
JNLP provides followed things:
allows to user to download jars from server
on launch verifies if application need to update
runs on local JVM
Actually, every java application you can convert to JNLP. Just to sign on all jars that your game contains, create executable jar from your game and create single Web page from where you can download your game

How to load large applet

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.

GWT Application loading time

I am using GWT 2.0.3 with ext version.When I run the application its take some time to load.As much as I know It take time to load some JS file (Not sure about it).For slow internet connection it wiil take more time.
I want to know what exactly GWT application do while loading.If it is loading some JS file the is there ant way to reudce loading time by dividing JS file or by nay other way?
Thanks in advance
When a GWT application loads, it loads all js files contained in your html host page, what means everything client side related is loaded.
To optimize this GWT introduced code splitting some time ago. You can check it here. The basic idea is to divide your application in logical parts, when a user wants to access to another part, its loaded on demand.
To speed up web app loading time, indeed split points are a first step.
But check as well this tool:
http://pagespeed.googlelabs.com
Slowness can also come from uncompressed pictures for instance.
Also, when you compile your GWT app, ensure you use "OBFUSCATED" mode for your compiled javascript, which makes it significantly smaller.
http://code.google.com/webtoolkit/doc/1.6/FAQ_DebuggingAndCompiling.html#Why_is_my_GWT-generated_JavaScript_gibberish?
Now if you are using Apache HTTPD as web server, Google has released a wonderful Apache module that implements web app best practices out of the box:
http://code.google.com/p/modpagespeed/

Best way to upload multiple files from a browser

I'm working on a web application. There is one place where the user can upload files with the HTTP protocol. There is a choice between the classic HTML file upload control and a Java applet to upload the files.
The classic HTML file upload isn't great because you can only select one file at a time, and it's quite hard to get any progress indication during the actual upload (I finally got it using a timer refreshing a progress indicator with data fetched from the server via an AJAX call). The advantage: it's always working.
With the Java applet I can do more things: select multiple files at once (even a folder), compress the files, get a real progress bar, drag'n'drop files on the applet, etc...
BUT there are a few drawbacks:
it's a nightmare to get it to work properly on Mac Safari and Mac Firefox (Thanks Liveconnect)
the UI isn't exactly the native UI and some people notice that
the applet isn't as responsive as it should (could be my fault, but everything looks ok to me)
there are bugs in the Java UrlConnection class with HTTPS, so I use the Apache common HTTP client to do the actual HTTP upload. It's quite big a package and slows down the download of the .jar file
the Apache common HTTP client has sometimes trouble going through proxies
the Java runtime is quite big
I've been maintaining this Java applet for a while but now I'm fed up with all the drawbacks, and considering writing/buying a completely new component to upload theses files.
Question
If you had the following requirements:
upload multiple files easily from a browser, through HTTP or HTTPS
compress the files to reduce the upload time
upload should work on any platform, with native UI
must be able to upload huge files, up to 2gb at least
you have carte blanche on the technology
What technology/compontent would you use?
Edit :
Drag'n'Drop of files on the component would be a great plus.
It looks like there are a lot of issues related to bugs with the Flash Player (swfupload known issues). Proper Mac support and upload through proxies with authentication are options I can not do without. This would probably rule out all Flash-based options :-( .
I rule out all HTML/Javascript-only options because you can't select more than one file at a time with the classic HTML control. It's a pain to click n-times the "browse" button when you want to select multiple files in a folder.
I implemented something very recently in Silverlight.
Basically uses HttpWebRequest to send a chunk of data to a GenericHandler.
On the first post, 4KB of data is sent. On the 2nd chunk, I send another 4K chunk.
When the 2nd chunk is received, I calculate the round trip it took between first and 2nd chunk and so now
the 3rd chunk when sent will know to increase speed.
Using this method I can upload files of ANY size and I can resume.
Each post I send along this info:
[PARAMETERS]
[FILEDATA]
Here, parameters contain the following:
[Chunk #]
[Filename]
[Session ID]
After each chunk is received, I send a response back to my Silverlight saying how fast it took so that it can now send a larger
chunk.
Hard to put my explaination without code but that's basically how I did it.
At some point I will put together a quick writeup on how I did this.
I've never used it with files of 2GB in size, but the YUI File Uploader worked pretty well on a previous project. You may also be interested in this jQuery Plugin.
That said, I still think the Java Applet is the way to go. I think you'll end up with less portability and UI issues than you expect and Drag/Drop works great. For the record, Box.net uses a Java Applet for their multi-file quick uploads.
OK this is my take on this
I did some testing with swfupload, and I have my previous experience with Java, and my conclusion is that whatever technology is used there is no perfect solution to do uploads on the browser : you'll always end up with bugs when uploading huge files, going through proxies, with ssl, etc...
BUT :
a flash uploader (a la swfupload) is really lightweight, doesn't need authorization from the user and has a native interface which is REALLY cool, me thinks
a java uploader needs authorization but you can do whatever you want with the files selected by the user (aka compression if needed), and drag and drop works well. Be prepared for some epic bugs debuggin' though.
I didn't get a change to play with Silverlight as long as I'd like maybe that's the real answer, though the technology is still quite young so ... I'll edit this post if I get a chance to fiddle a bit with Silverlight
Thanks for all the answers !!
There are a number of free flash components that exist with nice multiple file upload capability. They make use of ActionScripts FileReference class with a PHP (or whatever) receiver on the server side. Some have recently broken with the launch of FP10 but I know for certain that swfupload will work :)
Hope this helps!
What about these two
Jupload
http://jupload.sourceforge.net/
and
jumploader
http://jumploader.com/
Both are java applets but they are also both really easy to use and implement.
what about google gears?
There are HTTP/HTTPS upload controls that allow multi-file upload. Here is one from Telerik, which I have found to be solid and reliable. The latest version looks to have most if not all of your feature requirements.
You can upload multiple files with HTTP forms as well, as Dave already pointed out, but if you're set on using something beyond what HTTP and Javascript offers I would heavily consider Flash. There are even some pre-existing solutions for it such as MultiPowUpload and it offers many of the features you're looking for. It's also easier to obtain progress information using a Flash client than with AJAX calls from Javascript since you have a little more flexibility.
You may check the Apache Commons FileUpload package. It allows you to upload multiple files, monitor the progress of the upload, and more. You can find more information here:
http://commons.apache.org/fileupload/
http://commons.apache.org/fileupload/using.html
Good luck

Categories

Resources