Java Web Start vs Embedded Java Applet - java

I'm going to deploy my Java game to show it to my friends and whatnot, but I'm having trouble deciding between Java Web Start and applets.
Under what conditions is one preferable over another and what advantages/disadvantages are there?

If your game is going to consume a lot of cpu and memory resources I recommend deploying it as Java Web Start since applets run slower.
If you have some java-javascript interaction you'd better use applets
Here you can find a table with advantages/disadvantages

Java applets have the advantage that they run instantly without the user having to click on anything. In addition, applets will automatically prompt the browser to download the Java plug-in if it's not already installed. This is important if your end users aren't very tech-savvy.
However, applets are extremely limited in terms of memory (60 - 90 MB), so if your game uses a lot of graphics you will notice a performance slowdown.
If performance is an issue, you will probably have to use Java Web Start. It suffers no performance penalty, but is a lot trickier to deploy and more difficult for end users to run.

I'd make it run as either, and then choose which to use. An applet will sit in a web page nicely. A WebStart application will look like a normal application (only with a little triangle to indicate it's from the web). From 6u10, applets can use JNLP services, and can be dragged out on to the desktop.

You can actually have both applets and web start with the same Java applet code. Web start supports launching unmodified applet .jar in a separate frame, all you need is to write JNLP file properly. You can specify the applet parameters in JNLP file, if required. The only difference is that the applet will pop out in a separate frame and not as part of the web page which may or may not be a problem. Why not to provide both applet and web start link? JNLP is not much more difficult to write than the applet tag.
I think it should not be much difference between Web start and applet performance unless applet runs in some old JRE that is part of the browser. I would not recommend this anyway - as any other software, Java evolves and gets better over time. This may explain posts talking about that Web start application is much faster, this otherwise would be very difficult to understand. If you applet supports also old JREs, I think you can simply specify the low version number in JNLP, adding + so it can also run with future versions.

Since Oracle is not making any progress in delivering a non-NPAPI java plugin, I would say that applets is an obsolete technology.
Otherwise, we would dive into a good old IE-only web. Banks are already requiring IE browsers so they would not spend tons of money to modernize their software. I feel sorry for them.

Web Start requires the client to install the Java application (and possibly the JRE) on their computers. If they don't have administrative rights to install software this is going to be a problem.

Related

Is a Java applet usable online anymore?

I have a BlueJ applet that I want to run in a web browser. I've realized that the tutorial I was trying to learn from was outdated, and applets are really obsolete. What I'm trying to figure out (I'm searching but finding a lot more outdated info, hence my confusion) is what replaced applets, and if there is still a viable way to use my .jar file in a web app.
what replaced applets
The browser, as a runtime, has become powerful enough to make Java Applets unnecessary. Modern webapps with some amount of JavaScript on the frontend replaced Java Applets.
and if there is still a viable way to use my .jar file in a web app.
No, there isn't. Java Applets are dead and there is no viable way to run them for the vast majority of users on the public Internet.
If you are a software developer, you should abandon applets and start learning a modern full-stack framework. There are many to choose from.
May I suggest you taking a look at CheerpJ?
It allows for both old java applet to run and for java applications in general to be executed in the browser.
There is an extension for Chromium/Google Chrome that can be used for free to test the applet and our product.
Disclaimer: I work for Leaning Technologies, the company behind the CheerpJ project.

Java Swing, application or applet?

If I want to write a GUI program using Swing, my understanding is that I can either write a Swing desktop application, or write a Swing-based applet (which I can run using appletviewer or a browser). But it's not clear to me which one to use.
I don't have a particular program in mind; I'm trying to understand generally which is better under what circumstances. Any clarification on this would be appreciated.
Applets are meant to be executed inside a browser and have a few more restrictions to ensure that users can run any applet without major risk. While the concept of applets was revolutionary when it was introduced, it has never had as much success as it deserved. These days, applets are quite an exception.
Desktop apps have less restrictions than applets and in most cases it is probably what you want.
If you want easy distribution of your app, you should also have a look at Java Web Start though again, it does not have the traction it deserves.
There is no better or worse in this regard because an applet is run with Java Web Start using JNLP which is a way to deploy Java technology based applications.
It entirely depends on the intended architecture, distribution, security considerations, use cases, etc. of an application which way is optimal.
Web Start requires software on top of JRE but it is included in the default Java Runtime package since version 1.4.2.

Java Web Start (JNLP) advantages over Java Applet

What do you think are the advantages/disadvantages of a Java Web Start project against an Java Applet? We're trying to figure out what type we should use for our new application. We've already developed an Desktop App (JAR) and we're trying to make is useable from every machine, which has Java installed, without the need of installing it.
Any thoughts?
Applet/browser/JRE interaction problems. If you don't know what I mean, don't even have an inkling (from lost hair) then deploying applets will be a steep learning curve.
What does the browser bring to the deal? If the answer is JS interactivity, integration with an existing HTML based web app., or a few other related things, plenty. If not, then ask yourself what the advantage of deploying the app. wrapped in a browser window really is?
JWS Jar caching and update is more reliable (and can be taken under programmatic control, if needed).
The AppletContext provides some ability for an applet to interact with the environment, but the JNLP API goes beyond what the AC can achieve (mostly).
General usability. These may or may not be a problem for your use-case.
A free floating JWS deployed app. does not get closed when the browser gets closed, and does not suffer focus loss on tab change.
If 3 applets each with controls are embedded in 1 page with links, what gets focus? Since Sun never bothered to specify what should happen (according to them) it has been different across JREs over time. Now it is common for the JRE to grab focus for the applets. If it does, it it generally impossible to use the keyboard (alone) to get to the links and other focusable elements in the web page.
It is far easier to resize a desktop app.
A desktop app. (with splash screen, desktop shortcut with icon etc.) can look much more professional.
Of course, it should be mentioned that the lines become blurred:
Since JWS was introduced, it could launch applets
Since the Plug-In 2 architecture JRE, JWS could launch applets that remained embedded in a web page.
..we're trying to make is useable from every machine, which has Java installed, without the need of installing it.
I would sweep aside the 'without the need of installing it' requirement of that since there is always the passage of time and the need for updating plug-ins. On that note, use deployJava.js to handle JRE minimum version checking. The script will either embed an applet or write a link to a JNLP launch file after checking minimum Java is available.
See also
The Stack Overflow info. pages for tags:
Java Web Start
JNLP
Applet
Since 6u10 the significant difference is down to an applet appearing in (and being able to interact with) a web page (possibly opening windows that don't necessarily interact very well with the browser window) and WebStart applications being separate from the web browser. WebStart applications will automatically get their own process, which may be significant from a memory usage point of view, at the cost of a slower warm start. Applets have access to javax.jnlp.* since 6u10.
I think web start is what you should use. As far as I know it allows you to start full blown java applications.
JNLP can (and in some cases should) be used with applet.
Just finished integration of applet that read-write to user's file system.
Advantages of applet are obvious -- no installation on client machine.
Disadvantages:
not working in Chrome anymore;
additional configuration required -- each jar's manifest file must contain
Permission: all-permissions
line.

is there way to view a Swing app remotely?

I want to show my app conveniently without the hassle of carrying a laptop or distributing an obfuscated Java app.
Is there an easy way to view my Swing app in a browser. I do not necessarily need the command buttons to work (but it would be nice if they did), I just want to see the pixels from anywhere on the internet. I have graphs built from JChart2D.
Edit: The screen updates after a configurable period and 15 seconds is typical but if the desktop updates every 15 seconds and the browser image at a much slower rate, say, 1 minute, that would be okay.
Edit: What I have is primarily a desktop app in that it being a desktop app satisfies 98% of the requirements but if I can see it or use it remotely without a re-write that would give me the extra 2% (see it 1%, use it 1%).
For that purpose, the recent Webswing may be perfect. It seems fully functional. There are some glitches and I miss the cursors. Alas, the remote applications are displayed on the server, too, whether you want it or not.
I don't think I would recommend this (because it has security implications and firewall issues) but it is possible to run a Java / Swing application using a remote X11 server.
Here are some relevant links:
Remote X Apps mini-HOWTO
X Over SSH2 - A Tutorial
but there is probably more uptodate information in your Linux documentation.
Another idea is to make a demonstration movie.
There is not many solutions for it but this easisest way is JNLP.
JNLP is an XML-based technology for launching Java executables over the Web. Just imagine that you could specify the classpath resources in your application (images, JAR files, properties, files, etc.), scattered over the Web and giving their URLs, instead of relying on the local file system as normal Java applications do. This feature would give you the capability of deploying your application automatically (that is, installing needed application files and launching them properly) just by declaring where your files are on the Web. And it is far easier than Applets which can create a lot of troubles to you because of strict permissions at browser.
An example of JNLP is here and here.
One other possibility (not necessarily a good one, but easy to implement) might be to use the java.awt.Robot class.
Using this class, you could periodically take a snapshot of the screen, using #createScreenCapture(...), and write this out to disk using javax.imageio.ImageIO.
It would then be straightforward to create an HTML page that displayed this image, and auto-refreshed periodically. A little bit complicated and circuitous, but may let you re-use existing infrastructure.
VNCj (official page, SourceForge) is an older project which provides an implementation of AWT on a VNC server. Swing runs on top of that. Unlike WebSwing, no UI appears on the server when running VNCj.

Migrating Delphi App to Java or to Web App

We want to migrate UI rich application from delphi to java or Web Application.
Reason is that we want application to be portable on all Operating Systems.
Current Components and Modules of Application in Delphi :
In Delphi we are utilizing TWebBrowser component to display HTML content
We are playing mp3 that is extracted from FileStream on clicks in HTML.
All resources for HTML are retrieved from Embeded Database Firebird/Ms Access.
To sync some content we are doing HTTP post to PHP scripts to centralize the data on webserver.
Deployment:
- Application has to be deployed on CD and installed on Desktop computer on Mac OS, Linux, Windows.
I need your help how to approach this migration. Is better to go with Java UI or Web App that will be deployed with WAMP/XAMP and appropriate distributions on Linux and Mac's.
EDIT:
I have some specific requirements for audio functionality. Audio files are separate files distributed on CD or USB. Audio files are one solid file compiled from mp3's inside. Application will have to have ability to extract the mp3 based on offset and size of mp3 stored in index file and to play in real time... How this affects idea of Web App using this approach.
Why don't you give FreePascal a try? It uses the same language as Delphi, and can compile to a native application on Windows / Linux / Mac. Since you already have your app in Delphi, converting it shouldn't be too difficult.
Have a look at the freepascal website
If I had to deploy on a CD, I'd probably go with Adobe's AIR. It is really fulfilling the promise Java made 10 years ago in a reasonable way. It isn't perfect, but it does a pretty good job.
I've heard this internet thing is really taking off.
For all of the reasons that applications have gone online over the past 10 years, there really isn't much discussion to be had.
While Java is reliable, distributing and rolling out subsequent updates to those applications is heavy and time consuming.
I did Delphi development for over 9 years. I resisted the idea of distributing real applications over the web for quite some time. Today, I can't believe anyone would choose to continue in this way.
One nice thing, you can probably reuse some of your Delphi logic on the backend if you get creative. (I would only recommend this for the short term)
But, this answer doesn't really address your issue as you are saying that you must distribute it via CD.
The Java 6u10 release allows for distributing Java WebStart applications on media instead of from a Webserver, which might be exactly what you are looking for. You can also put the JRE installer for Windows on the CD too, if needed.
What exactly are your requirements crossplatformwise?
If most of the application is HTML-based, why not make it a full web application, using Ajax and Java?
I recommend NetBeans, and ICEFaces, which is a Java Server Faces implementation with Ajax support, including concurrent updates - if one user edits a record, all other users will see an update in their web page.
It is possible to package the whole application in a single jar file, including the servlet container (Jetty for example), so a simple java -jar myapp.jar will run the application.
NetBeans allows visual editing of the ICEFaces web pages, and even visual editing of the page relationships. The tutorials on NetBeans.org are excellent, and with tools like Maven, Hudson and others, code quality and development process can reach a very high level.
If you have some Delphi application using Datasnap : you can also re use your server made in Delphi with Datasnap in Delphi Prism and make Silverlight application.
And the same is true for DataAbstract

Categories

Resources