Some weeks ago I wrote a little Java program showing a real time plot chart (i.e. records with tracking of current time), with a modest 25 kbps streaming rate, 20fps framing rate, and no relevant user interaction. Thinking on its eventual deployment as a Mobile App, a Web Server chart or simply as a PC as a program, being Java a perfect selection for me.
Before starting now the Web version of this program, i started to investigate and according the 2016 Oracle White Paper Migrating from Java Applets to Plugin Free Java Technologies:
The deprecated plugin technology will be completely removed from the
Oracle Java Development Kit (JDK) and Java Runtime Environment (JRE) in a
future Java release (TBD). Java Web Start applications do not rely on a
browser plugin and will not be affected by these changes.
And according 2019 OpenWebStart:
Java Web Start (JWS) was deprecated in Java 9, and starting with Java
11, Oracle removed JWS from their JDK distributions
And then I get lost.
Hence, which is the way to go with a Java program like this? Which is the proper sustainable Java way to do this (and not subject to something like what happened to Java Web Start)?.
Or should I simply move to another way to do it, now that the program is in its infancy, considering I am not precisely a fan of Phyton, considering PHP is not precisely the way for programming these kind of numerical things, and considering I am not so willing to give Microsoft technologies a chance?
It is not a problem for me to adapt and rewrite my current code if necessary, but possibly not doing this every 5 years.
Which article would you recommend me to get back to the proper path?
Thanks in advance.
The easiest and highest-performance option is TeaVM, a transpiler that converts Java classes into JavaScript. Your code then runs in the browser natively without any plugin.
Read an introductory article here: https://blogs.oracle.com/javamagazine/java-in-the-browser-with-teavm
TeaVM's main site is here: http://teavm.org/
Thinking on its eventual deployment as a Mobile App, a Web Server
chart or simply as a PC as a program, being Java a perfect selection
for me.
(..)
Hence, which is the way to go with a Java program like this? Which is
the proper sustainable Java way to do this (and not subject to
something like what happened to Java Web Start)?
Two lines of Java
What happened is that our old friend, the Java Standard Edition, split into two lines:
Oracle Java SE ("commercial Java"): needs paid license for commercial use for releases since April 16th, 2019
OpenJDK ("open source Java"): open source (GPLv2 with linking exception), does not contain Oracle's Java Web Start implementation
The Oracle Java SE version keeps Java Web Start and Java FX available and supported only for Java SE 8. Newer Java versions, esp. Java SE 11 do not carry these anymore.
It is not a complete client / desktop technology removal, because Oracle, according to the Java Client Roadmap Update 2018, continues to support AWT and Swing for at least 5 more years on both Java SE 8 and Java SE 11.
You can continue deployment via Java Web Start
Open source Java got a decent implementation of Java Web Start, which is free and available for Java SE 8 and newer Java versions like Java SE 11.
This is Karakun's OpenWebStart based on Red Hat's IcedTea-Web, now beyond version 1.0, which you already found.
Continued support is not guaranteed but seems likely. So you might continue on this track.
Or you might deploy via an app store
Oracle's explanation for dropping Java Web Start was, that they want to change the deployment model to applications with bundled runtime:
As client application development continues to shift from the old
“plugin” world to modern deployment, the need for a standalone Java
Runtime Environment (JRE) that is installed centrally, separately from
Java applications has diminished. Using the ‘jlink’ tool introduced
with JDK 9 will make it even easier for application developers to
package and deploy dedicated runtimes rather than relying on a
pre-installed system JRE.
(Source: Faster and Easier Use and Redistribution of Java SE)
Deployment, according to Oracle, would occur via some app store like the iTunes Store:
No doubt this was true, but the OSes have shifted hard and fast away
from this model. The "app store" model is now it. macOS has been
ratcheting this down hard for several years now. MSFT -- even in the
enterprise market -- has signaled this direction as well. For sure we
need to find options to support the legacy, but the future here is limited.
(Source: OpenJDK discussion mailing list)
Note that Java Start Web Start handled the updating of available new versions of applications on the client machines, and so do typical app stores.
Of course you can serve a version of your app with bundled runtime on your web site, but then you usually have to implement some mechanism to handle updates of your application on the machines of your users yourself.
What to choose?
It is true that the separate JRE installation has disadvantages, e.g. I changed my JRE recently and suddenly the IDE for Java did not work anymore. :-)
Moving deployment from a web site you control to an app store controled by the OS vendor or mighty players like Valve, has its own challenges. E.g. access restrictions, fees, release delays because of the review process, or they might not like your app for some reason and will not publish it.
Then adoption: Personally I have seen private use of app stores mostly on mobile devices and macs, but no use in companies yet. This might be a factor in your decision which road to pursue.
I've missed the Java on browser too. Because of curiosity I just developed an "JVM-Server", which precompiles the Java-Classes to native JavaScript and serves them to a WebBrowser.
Look here is a Hello World example application which is running on Browser:
https://github.com/neo-expert/jsjvm_helloworld
There is also a Library which implements WebGL bindings. In the above Example is a WebGL demo included, where a 3D cube will be rendered. The code is written in pure Java.
Is it a swing app? Will have to map that to a web (html) app to make it work on a browser nowadays.
You cannot run any of those programs from a browser directly.
Java used to java applets and java web start - where the browser helped you install a java app on local system but user had to seperately have installed JRE (Java run time) to run it locally.
Now all we have are web apps. basically apps that might have a a session, login, authenticaiton and authorition but in the end the app outputs HTML, Javascript, images and text data (JSON. XML etc) that is rendered on the web page.
Look at J2EE. I'm a java fan. but it takes longer to develop, but i think it runs better. Especially with a good framework like Spring Boot (it includes MVC see https://dzone.com/articles/7-best-java-frameworks-for-2016)
But learning curve is there. Buy a book or do a course online like udemy or similar.youtube has free videos. but not sure of the order/ quality.
If you choose php - many free and cheap servers like x10hosting to start with and learning curve is less too. Good framework - packages like drupal and wordpress.
On the browser HTML, Javacript run. There are frameworks for this too. Like gogole's angular https://angular.io/ this too needs a book/seperate study. Old days we used to use simple Javascript ...
For mobiles - sometimes can get away with using a URL OR there are frameworks that wrap a web page in an 'app' for android, iphone etc OR make a native app - but then will have different code bases.
I know someone who used a game engine to make a mostly single code base (some classes are specific to each platform like android, iphone) but used to render business graphs and a few interaction use cases (about 40). He used https://libgdx.badlogicgames.com/
As your research already revealed, Java is not a relevant web frontend technology anymore. Prefer Javascript and CSS for browser frontends, instead. Feed the frontend code with data served by Java backend services. The Java Servlet Specification is still the base for server-side Java. Many frameworks (like Spring or Jersey, to name a few) are build on top of it. Either chose one of these frameworks, or - for really simple use-cases - build an application only with plain servlets. Any servlet needs to be deployed in a servlet container (e.g. Apache Tomcat).
Your Java code needs probably some refactoring in order to provide an API for the web. As you are asking for near-realtime communication, you should have a look at the WebSockets standard which is designed for bidirectional and fast client-server-communication on the Internet and supported by all modern browsers (nice intro explaining the difference to WebRTC and arguing why WebSockets are often the better choice). To plot your data in a browser with Javascript and SVG, have a look on the D3.js library. A quick search brings you to demos like this one: D3 Real Time Chart. Also, there are other libraries that are built on top of D3, for example plotly.js.
Summary:
Java is fine for web backend services.
Your code needs refactoring to serve a backend API, preferably WebSockets. (introduction on how to start in Java at https://www.baeldung.com/java-websockets)
Get familiar with a Javascript browser plot library, such as D3.js.
Related
My application is developed in java Swings which is 20 years old. For this huge application we are migrating the same on JAVA 10 now and will migrate the same on java 11 or upcoming versions. This application is working fine with java Webstart and as per the java 11 features, java Web Start application will not be supported in java 11 and other coming versions.
Please let me know the best way to run my application on java 10 with out webstart.
There is OpenWebStart start project. It says:
we decided to create OpenWebStart, an open source reimplementation of
the Java Web Start technology. Our replacement will provide the most
commonly used features of Java Web Start and the JNLP standard, so
that your customers can continue using applications based on Java Web
Start and JNLP without any change.
At the moment the project is alpha phase. Download is available. Beta should be available by the end of the year:
Our goal is to have beta tests and a release candidate ready in
Q3/2019
One solution might be the WebStart replacement that Karakun is currently working on: https://dev.karakun.com/webstart/
Currently it is not clear when and how this will come since it is based on a kind of crowd-founding but since everyone can get involved (even with low cost) this is a very good possibility.
Since this is a duplicate of Applet/JNLP on Java 11 migration I just copied my answer
Use Getdown which is a system for deploying Java applications to end-user computers, as well as keeping those applications up to date.
It was designed as a replacement for Java Web Start due to limitations in Java Web Start's.
You can read more on https://github.com/threerings/getdown
You will have to find an alternative technology to JWS/JNLP to run your system, as JWS/JNLP will no longer be available.
I don't have a clear cut alternative, the few companies still using JWS tend to be working to develop their own replacements for internal use.
I know this may not be what you want to hear (that there is no out of the box replacement available) but that's the way it is. Project I'm working on is in a similar conundrum, we also have several JWS components that will need to be reworked in the near future.
A long time ago I made an applet, when I tried to a open it few days ago in website and it says that there is a security problem and it can not open it.
I Googled it and saw that I need to register it.
I tried to register it but nothing helped.
Can you explain what could make this problem?
The applet is fine and working when I run it from eclipse.
With recent updates to Java, security is much more strict. Your applet needs to be running the same java version and have a certificate. It's a very strict system...I can't open many java applets myself.
To make it run as an exception, copy the URL that the applet is on. Then open up your Java Control Panel, go to the Security Tab, and at the bottom hit Edit Site List at the bottom. From there, hit Add and paste in your link.
That'll allow it to run as an exception.
tl;dr
Java Applets are gone. You can modify your applet to run as a local app instead.
Today you can build local GUI apps in Java using your choice of three frameworks:
Swing (now in maintenance mode)
JavaFX (actively developed, led by Oracle and Gluon)
SWT (developed by the Eclipse Foundation)
For remote apps written in pure Java but delivered to users as a web app, see Vaadin Flow.
Yes, Java Applets are dead
Oracle has deprecated Java Applet technology, having proven too difficult to integrate securely into web browsers.
All the major web browser makers (Mozilla, Apple, Google, Microsoft, etc.) have phased out support for Java Applets.
Long live Java GUI apps
See white paper by Oracle, Java Client Roadmap Update, 2020-05.
Oracle’s vision for local Java GUI apps is for the developer to deliver a "double-clickable" app bundled with its own JVM slimmed down to include only needed parts. Modern tooling includes jlink and jpackage. Oracle no longer sees Java being generally bundled with operating systems, nor generally being installed by users.
While Java Applets are dead, Swing is still maintained as a required part of every Java implementation. People continue to write Swing apps for use on a local computer. You just cannot run a Swing app within a browser any longer. If you have source code for a Swing-based Applet, you can easily modify it to run as a local Swing app.
Swing’s replacement, JavaFX, is under very active development in the open-source project OpenJFX, a subproject hosted on the OpenJDK project. Releases arrive every six months, around the same time as Java releases.
The Eclipse Foundation continues to offer Standard Widget Toolkit (SWT) as a third platform (besides Swing & JavaFX) for writing Java GUI apps on a local computer.
For an open-source implementation of Java Web Start, see OpenWebStart. Oracle has dropped support for the technology, but others continue to find it a handy way to deliver and launch local Java desktop apps.
If you want to write web apps in pure Java using a Swing/JavaFX style of coding, see Vaadin Flow. Your app executes server-side in a JVM while the user-interface is automatically rendered remotely in the web browser by way of standard web technologies (HTML, CSS, JavaScript/ECMAScript/TypeScript, Web Components).
I would like to replace Java Applet which currently needs to use client's resources, i.e. external readers, and to communicate with a server via socket.
Reason:
1. I have thousands of client machines using this Java Applet program, and most of them are running out-dated JRE. When the Java Applet program is updated / added new features, all client machines will need updating the latest JRE.
Expected Solution:
The Java Applet program would be expected to be replaced by a web-based application, which allows to compile and run source code at client's side such that the new web-based application could still use client's resources and communicate with server via socket.
Can I use JavaScript to achieve it?
I would very appreciate your help/suggestion for this problem. Thank you!
JavaScript is a scripting language that gets evaluated in the browser.
I would not describe it as compiling and running but yes, it does mean you can run code in the client and is commonly used to create applications that run in the browser.
There's a staggering amount of frameworks that you can use to write your application. Take a look at the TodoMVC site to see the same TODO app created using several different frameworks.
If you come from Java applets, GWT may be interesting to look at.
If you wish to let the JavaScript client listen for messages from the server, take a look at websockets.
The smart card reader is going to be a problem, though!
See Architectures to access Smart Card from a generic browser? Or: How to bridge the gap from browser to PC/SC stack?
By the way:
The real issue with outdated JREs is not that your code will not run on old JREs, you can create perfectly fine applets using java 1.4 or java 5. Any libraries you may need you can deploy alongside your applet. The pain is a security problem. Anything but the latest version Java plugin is getting actively exploited and puts the user at risk. Occasionally, even the latest version is not safe.
try socket.io
I think this is the latest technology you can use to communicate with client browsers. it support the latest browsers and mobile browsers too.
hope this will help you.
Javascript has become very powerful with HTML 5.0. Here is a list of new elements that you can use to access all kinds of resources, including local files, audio, video, GPU rendering (canvas + WebGL) and GPU compute (WebCL). Here are even more things you can do, including database connections and networking. You can even create offline Javascript applications.
jQuery and jQuery layout make robust GUI development a lot easier. Rich tool suites, such as Google Closure offer optimization and a compiler for improving performance and detecting obvious mistakes early in the development process.
W3 offers useful stats for making an informed decision on how many users on average have access to which features. Note that the most annoying guy in that list arguably is IE8 due to it's lack of proper HTML 5.0 support.
In case you want to stick with Java, then one alternative would be to use my http://bck2brwsr.apidesign.org project. It's goal is to create small Java that can run in 100% of modern browsers without any plugin installed.
There are Java bindings to HTML (via knockout - one of the four most popular frameworks for HTML5) and that is why one can code whole business logic in Java and just render it via HTML. Should be enough to replace most of the applet UI.
In addition to that there is an experimental API to render on HTML canvas. People use it to write Java games that run in a pure browser.
There is a simple way to communicate with server via JSON REST API or via WebSockets. A live example is here.
If I am getting it right from what I am reading, JavaFX 2.0 allows you to code all your logic using Java and design screens with FXML. Then, web apps run as an applet on the client side.
But:
Are all browsers and mobiles devices capable of running applets?
Is it efficient (i.e., nice user experience)?
In other words, how portable are JavaFx 2.0 web applications on the client side? Anyone has experience to share?
From How to run Applets on Android?, it seems like android is not capable of running applets.
So, it seems like JavaFX 2.0 is ok on most browsers, but not for portable devices such as smartphones.
JavaFX produces Java applets. So what I say here applies for Java applets.
Most browsers for desktop machines are Java compatible: IE, Firefox, Chrome, Safari, Opera on Windows, Mac, Linux and Solaris. For smartphones, it seems a lot more complicated. I think it must be a definitive no for iOS, Blackberry and Android. For Windows Phone, it might be possible, but probably too complicated for the mainstream user.
Efficient is a broad idea. It has advantages (performance once started, openess to the rich Java ecosystem) and drawbacks (time to startup, size, all applets running in the same JVM instance). Java 7 improves the experience, as you can read here: http://www.oracle.com/technetwork/articles/java/javaclient-484666.html
JavaFX applications can be packaged in a numerous amount of ways. They can run as applets in a web page, they can be launched through java web start, they can even be distributed as os native applications. So yes, JavaFX is as portable as portable can be. Other people in this thread has already talked about JavaFX applets, which is what governs your question. So I shall not elaborate on that. However, I feel you might have missed the fact that JavaFX clients must not only be distributed as an applet in a browser in order to talk to the back end. Indeed I would not even consider that as an alternative, judging by my own past experience of applets and how ugly they look in the context of a web page.
As an alternative to applets, you can write a JavaFX stand alone application who talks to the back end using a SOAP- or REST based web service. Internet is full of these examples. Moreover, you can have the application be launched through Java Web Start and do dependency injection to get hold of proxy objects to resources on the server. This last part is not talked about by blog posters and Oracle articles. Indeed I haven't found a standardized way of doing that. But if you package a regular Java SE application in a EAR package you can inject resources in this application's Main class and let the thread startup a new JavaFX application and forward those resources. Here is a tutorial I wrote that takes you through the entire process:
http://blog.martinandersson.com/the-enterprise-side-of-javafx-the-missing-part/
I'm wondering if there is a standard method for deploying applications originally written in Java, to iOS4 devices.
I assume that the application in original format cannot be deployed - is there perhaps an emulation layer that I can use, or a stable compiler that compiles Java to ObjectiveC?
Option 1:
Use one of several cross compilers, compiling Java to ObjectiveC:
http://www.xmlvm.org/overview/
http://www.flexycore.com/ispectrum-overview.html
Option 2:
Package custom JVM with java application, with restrictions that meet the latest agreement (including no byte-code download capability and no JIT compilation). No JVM specifically designed for the iPhone is currently (Oct 2010) available, though the IKVM might run on top of Monotouch, and Oracle may build a version of the Java SE for the iPhone eventually.
Option 3:
Cross compile Java to one of the existing interpreters that are already accepted on the iPhone (eg, cross compile Java to C# and run the app on monotouch)
With the new current iOS SDK agreement and App store rules, it may be possible for you to embed a Java applet with your own JVM interpreter and runtime engine (but no byte-code download capability and no JIT compilation allowed).
Another seldom mentioned possibility for deploying any non media or graphic intensive networked app, such as many typical Java applets, is to run a customized RDP or VNC viewer on the iPhone and and view a Java app that is being hosted and run remotely.
Mechanically translating some of your code will likely work pending finding a cross compiler / translator. Trying to run a Java based GUI on iPhone is just plain stupid in my opinion. So the smart thing would be to port the GUI by hand.
The problem of course is if the app is mostly GUI you might as well write the whole thing over. Likewise if the app uses APIs that there is not a simple translation for you again might as well rewrite the entire app.
In a nut shell I think Steve J. Was right here, the route you are comtemplating just leads to poor user experiences. It actually makes me wonder why you would even think that a Java based app would be successful on iPhone.