Is there a modern way to run java applications in browser? - java

Is there a modern way to run java application on the web? As far as I know, java applets and java web start both are deprecated.
I have an android app, written in java, which I want to run on server (of course, altered in some way). While java is cross-platform there is no problem to transfer it to desktop (no matter, javafx, swing or etc.).
Apparently, it would be great not to re-write it in some other language.

Nowadays, we're using GWT at work. Well.. It's efficient, it's fast and compatible with all browsers. And it's so easy to build a web page with GWT. You can check tutorials from this link.
And you can look up for Spring MVC. Not the most flexible choice for UI, I know. But give it a shot. link
But.. If you're open to new things, I'll totally recommend React Js. It's flexible,it's super fast with perfect UI. If you ever think of using Java just for back end, React js is a great deal for UI. link

There is an HelloWorld Example Java-Program which is running in a browser:
https://github.com/neo-expert/jsjvm_helloworld
After compiling you can just run the jar file which starts a webserver where the program will be served. (port 8080)

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.

Can Electron apps be integrated with java code?

As node.js still lacks important functionality which exists in Java, I would like to use Java instead of node.js, and create the client using a web language (html, js, css..).
Electron is cross platform and so does java so it seems fit to have a solution getting the best of both worlds.
Does someone know of a way to integrate electron with java or have a different solution to the problem?
I made something similar, Java back-end with Electron GUI.
You can do it in more ways, it depends on what you need.
You can create a jar file and then execute it like terminal:
https://nodejs.org/api/child_process.html
Or you can open a socket communication and talk on a Port. (A lot of documentation:
Java (web)socket - Node.js client.io)
In this second way, you can do everything you want, but you have to create your communication protocol.
Your path is not foolish, I am very satisfied of the communication and usage in my work with Java + Electron .
I've created a small PoC where Java process is integrated with Electron front-end: https://github.com/jreznot/electron-java-app There you will find a simple TODO List application built with Vaadin/Jetty and Electron.
Personally i made my back-end java communicate with the front-end by creating a file with te data then sending it to the main.js to be processed.
DBus and winDbus seems to be an option here.
It creates nice abstraction and separation between "frontend" and backend
https://sourceforge.net/projects/windbus/
I'm going to test it on my own soon

Is there a way to run a Java Applet in node.js, at server side?

Is there a way to run a Java Applet in node.js, at server side?
It may sound crazy, but I am looking for a way to run a third party java applet on my node.js app server.
It is used to do a weird calculation that I am not willing to migrate to JavaScript code. Is this possible in any way? Any suggestions? I am in need to send the result of this calculation as a web page to the user, based on a request param.
I was initially thinking of how can I communicate between node.js and an Java Applet running standalone. Googled a bit but no success at all. Can someone suggest how to better google for it or point some good resources???
Using JNI will not help you as applets will not run in a headless environment. Applets are directly dependant on AWT so require a GUI environment to run.
Presuming that the license issues of the applet allow you to reuse the code, then my solution is to decompile the classes for the applet and use the generated java to create a normal java class with main that will run the desired calculations and return the result.
Unless the code is obfuscated, it's relatively simple to understand the decompiled code and should be relatively painless to adapt for what you wish to do.
Once you have your java code working from the command line you can then use the node-java project to call the java code from node.js and get your result.

Develop desktop applications view with HTML, as a web application

I am used to develop web applications in Java (Struts, Spring, JSP...). But now I want to develop a desktop one. I never liked to design windows in Java (AWT, Swing, SWT): too much work for an ugly interface. So I think it could be a good idea if could take advantage of my web-app skills. One option is to modify the SWT Browser and make calls to a Java function instead of HTTP requests. A very good add-on would be use of JSP. Finally, I thought that probably there is some framework or tool for this.
Do you think that what I propose is a good idea?
There is available some framework for this?
I need this for light applications. So I think that embedding an Tomcat server and using it with HTTP requests is not a good idea.
Edit: One example application could be a folder comparer: you specify two folders and the app shows you which folders and files are different. In this case, I think opening an external browser is ugly. Bloated application (with its server, MVC, etc) wouldn't be the best choice.
If you have used the JavaScript library - ExtJs - then you can use it with Adobe AIR to build good looking desktop based web app.
Building app's in Adobe AIR is also simple and elegant with the flex builder ide.
If your option goes to embed a light server, check winstone is not fully J2EE compliant but should be enough for what you need.
About the browser, I am not a big fan of swt myself, it complicates a lot cross-platform deployment, so probably worth to keep an eye on jwebpane, not quite ready yet, but probably the solution you'll need.
I wouldn't discount embedding a web server. I've done this before with a web start application embedding Jetty.
The download was pretty fast, the server starts up and you can use BrowserLauncher to immediately drive your browser to the embedded server, and hence your application. Jetty is designed to be modular and have a small footprint, so you can probably cut it down to the bare necessities.
There are several options: You can use the plugin API of Firefox and develop your app in there. You can use HTML, JavaScript, the built-in database, all the browser features and access the OS level.
Or you could try PyQt (Python and Qt) which allows to write simple applications very quickly.
[EDIT] The main problem you're facing is security: For security reasons, JavaScript apps (running in a HTML page) can't access local OS resources. So unless your browser allows you to write plugins in JavaScript (which is only true for FF AFAIK), there is no way to write an application which uses HTML as the "view" without the help of something else.
Moreover, HTML is very limited when it comes to features for applications. HTML is designed to be a "static document view" not an "application". You can do things like GMail but if you compare GMail to any real mail app (Outlook, Thunderbird, Notes), you'll see quickly that real desktop apps offer a lot more features.

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