Installation best practices for a web application - java

I have a simple web application which will be running on machines which don't have internet connectivity.
I would like to support the ability to install, remove and support migration of WAR at a later stage. This would be our deployment scenario:-
The machines might not have Java and we would probably have to install it before deploying the application.
The web application (WAR) runs on top of jboss application server.
The application server needs to be run as a Windows service
The entire application will be shipped in a CD.
I don't want to spend too much time on building an installer, but what should we do support the above scenario? Are there any tools which help in handling this?

I recommend using a MSI package with an EXE bootstrapper which supports prerequisites. This should cover all your requirements.
Regarding a setup authoring tool, it depends on what you want (free or commercial, with a GUI or with scripting etc.). You could use a Visual Studio setup project and Orca, but a commercial tool will be easier.

Related

Is it still realistic to deploy a JavaFX application using Maven in a Web Browser

I read here that it's possible to deploy a JavaFX application into a Web Browser:
embed-a-javafx-application-in-a-html-webpage
Now I got stuck at the beginning when he talks about using the java packager to create an executable .jar file. I'm using Maven which uses JavaFX 18, so I followed this tutorial on how to package a java project
java-packager-with-jdk11
Here I got confused with the tools he uses. I downloaded the listed tools and moved the jpackager files into the according directories. Still in cmd it gives me an "Error during initialization of boot layer": jdk.packager not found.
It's pretty worth it knowing how to create a Package from a Java Project, but is this the proper way?
tl;dr
No, not realistic.
You have a choice of alternatives.
Legacy technologies
That page uses legacy technologies, Java Web Start and Java applets.
Java applets have been phased out by all web browser makers, so Oracle consequently decided to phase out the technology. Java applets were first deprecated in Java 9, and later deprecated for removal in Java 17.
Oracle no longer expects end-users to have a standalone JRE or JDK installed on their computer. So Java Web Start is no longer available by default for the consumer market. Java Web Start is no longer included in Java 11+.
However, an open-source implementation continues in the OpenWebStart project. For some environments, such as corporations or schools where the installed base of computers is centrally managed, OpenWebStart may be a useful way to distribute apps.
Ship your app with JVM bundled
Oracle now expects desktop apps and mobile apps to bundle a JVM within their product. This does mean the app must be built in editions, one edition for each supported chip architecture and OS, but also allows the app to be tested with the same JVM that will eventually run the app.
For more info, see the Oracle white paper (PDF format), Java Client Roadmap Update of 2020-05.
New tooling is available to support this JVM-within-app packaging:
Java Platform Module System (JPMS) in Java 9+.
jlink in Java 9+.
jpackage in Java 16+.
Search Stack Overflow to learn more about packaging JavaFX/OpenJFX apps for distribution. Many Questions and Answers have already been posted on the topic. The topic is rapidly evolving, including cutting-edge approaches such as using GraalVM for ahead-of-time compilation to run native.
Vaadin Flow
If you want to build a single-page web app written in pure Java without you needing to learn HTTP, HTML, CSS, JavaScript, WebSockets, Push, etc., consider using Vaadin Flow. This open-source framework is based on venerable Jakarta Servlet technology.
You write Java code similar to that in JavaFX, defining forms by specifying widgets arranged with layout managers. Vaadin Flow then auto-generates the needed HTML+CSS+JavaScript to render the user interface remotely in the web browser while maintaining the state of your app on the server. Pure Java on server, no Java on client.

How to deploy Java Swing Application on Web Browser?

I've found exactly the same question I just made but it is 7 years old; so I'd like to have an "updated" answer if it is possible. Thanks.
Old days
As commented by TrogDor, there were previously two ways to deploy a Swing app through the web:
Java Applet technologyYour app would appear within a rectangle on the web page, within the browser.
Java Web Start technologyClicking a link on a web page would download a copy of your Swing app to the user’s local machine, where your app would then be launched locally using a locally-installed JVM. So your app runs separate from the web browser. This click-to-download-and-run process is defined by Java Network Launching Protocol (JNLP).
Both of these are being phased out.
➥ For details, see the white paper Java Client Roadmap Update published by Oracle, updated 2020-05-11.
Nowadays
The modern approach is to build a Swing and/or JavaFX app, then deploy by using a packaging tool to include a JVM. You end up with a complete self-contained self-launchable application.
This means you need multiple builds, one app for each platform your users may deploy on (macOS, Linux, BSD, Windows, and so on). While that is an additional burden to you, the flip-side is that you control exactly what version of Java is being used to run your app.
Because of the Java Platform Module System (JSR 376) in Java 9 and later, you can now strip down the bundled JVM and libraries to include only the parts actually used by your particular app.
The build tools for packaging your app have been rapidly evolving in recent years. So be sure to do your research to find the most robust and modern tooling.
Alternatives
You might consider any of these alternatives:
Remote execution
OpenWebStart A re-implementation of Java Web Start
GraalVM Ahead-of-time native-code compilation of your Java app
Vaadin Flow Using Java to build desktop-style apps delivered as web apps
Remote executions
Some vendors may offer a product or service to execute your Swing app remotely while displaying the user-interface within a web browser.
One such company is WEBSWING Ltd. with their Webswing product.
OpenWebStart
You might be interested in a separate implementation of Java Web Start technology.
While Oracle is phasing out Java Web Start, there is an open-source implementation of JSR 56: Java Network Launching Protocol and API called OpenWebStart. See GitHub. This project is currently maintained by the company Karakun, based on the IcedTea-Web core functionality developed at Adoptium (née AdoptOpenJDK).
GraalVM
A cutting-edge alternative is to build an entirely native-code ahead-of-time compiled version of your app using GraalVM.
Vaadin Flow
An entirely different way to build a web app by using Java is the Vaadin Flow framework.
You specify your user-interface layouts with widgets in a manner quite similar to Swing, specifying an arrangement of widgets (buttons, fields, labels, etc.). You can do so using your choice of straight Java code, an XML-based description language, or a visual design tool.
At run-time, Vaadin automatically automatically generates the HTML, CSS, and JavaScript necessary to render your app remotely on the client user’s machine within a web browser. So, you have pure Java on the server-side, and no Java on the client-side, just Web standards technologies built into all modern browsers.
More info
All of this has been covered many times already on Stack Overflow. So search to learn more.
For tips on obtaining a JVM to bundle with your app, see How to get java 11 run-time environment working since there is no more jre 11 for download?.
Nowadays you can run Swing app on server with UI in the browser. You can find example here: https://github.com/JetBrains/projector-demo.
Update: JetBrains ceased development of Projector as a separate product. See their notice. They have incorporated the technology for their own use in their Gateway product for remote execution of their IDE products.

How do I integrate source version control with a web server?

I understand the concept of source version control and how it applies to self-contained projects like a Windows application. But for web development, most files are stored on the web server. This has become a headache for development with many people just copying and renaming files and then pushing files over to production is another mess.
I need some kind of source version control that is relatively not too difficult to learn and must be GUI-based or have a GUI as an option. The people who will use this have little or no knowledge of the command line.
How can I integrate source version control with web server files? What software is available for such an endeavor? And is it possible to have the source version control software administer both the production and development web servers or I may only have two separate source version control installs for each web server and manually push over changes?
The web servers are Windows-based and also use Tomcat for Java/JSP.
Any help would be appreciated. Thank you.
I think you are not clear on the idea of version control. Version control is about managing your code. It is about putting your code in a remote server (may be in a central location) and accessing it using a client tool. This way a number of people can work on different part of the code and than push their work to version control server. It has nothing do with the type of the project.
The project can be a windows application, web server application or any application.
While using version control, in regular intervals or whenever needed you build your code from the version control server and deploy it to the web server which means you are deploying code that is already build (a .war for a web application).
You first deploy to your development server and later deploy the same war to the production server.
You can use SVN server for your version control server and Tortoise SVN as client.
You have to split in mind two different but interacting things - Version Control and Deploy Tools:
VCS has to do with any evolving over time items, which you want to have under control
Deploy just deliver correct object into the correct place at the correct time and convert "set of something" into Product.
Deploy isn't a problem per se (almost any job can be automated), main problem in multiDEV environment (2+) with central STAGE (less with PROD) server is question of communication between Devs and synchronizing of their operations, i.e. - workflow and management:
just imagine 2 (or more) devs, performing diferent unrelated tasks, which want to test latest own (and only own) changes on common STAGING server (because they haven't functional local environment). If 1-st deploy "some WIP" on server, he don't want to have own tests be interrupted and code poisoned by deploying third-party changes. They must to communicate and coordinate actions, it can't be dumb "copy to..." in post-commit hook
And is it possible to have the source version control software administer both the production and development web servers
Yes. But VCS does not "administer" web-servers in common sense, rather it's "communicates" or "take into account"

Deploying Java projects to other users

I am new to Java and is using Eclipse.
Whenever I have build a Java (JFrame) project successfully on my PC and when I deploy the java project files to other users, I have to compile the projects on other ppl's PC before they can really use it.
Is there any convenient way to tackle this? i.e. When I placed those Java files to a shared folder, all other users (new/existing) can execute it on their PC.. (juz like .exe in MS Window) Actually how is the practice outside?
The best way to distribute a desktop app. to users is Java Web Start. It requires some extra work from us the developer, but is a breeze for the end user.
Java Web Start (JWS) is the Oracle Corporation technology used to launch rich client (Swing, AWT, SWT) desktop applications directly from a network or internet link. It offers 'one click' installation for platforms that support Java.
JWS provides many appealing features including, but not limited to, splash screens, desktop integration, file associations, automatic update (including lazy downloads and programmatic control of updates), partitioning of natives & other resource downloads by platform, architecture or Java version, configuration of run-time environment (minimum J2SE version, run-time options, RAM etc.), easy management of common resources using extensions..
You can use Eclipse to create a JAR file for your project, and it will generate an executable JAR that the others can run. For more on creating JARs in Eclipse, see this.

Should I use Eclipse wizard to deploy web application?

I use Eclipse "Dynamic Web Project" to create and test web application. It will publish my application on application server in convenient way. I don't need to write script, just wizard.
However, I am wondering it is a decent way to deploy a web application. What's your opinion? Thanks!
(I used to use Ant script to deploy my application, it's standard way.)
plus: Dynamic Web Project uses its specific directory layout which is different with Maven standard directory layout.
This is fine for deploying to a dev or test server. Its a convenient way to quickly deploy to have a look at changes you've made and to do tests.
I would definitely not allow this for any other environment, eg live, pre-production etc. You should have an established process (eg documented change control) to deploy to these environments.
I have heard it's still recommended to cold deploy and restart the server for not having a trouble with memory leaks, dynamic class loaders. For myself I think comfortable to deploy from Eclipse to most environments. Basically Eclipse WTP server adapter can run the same deploy command as the other processes. When I use clouds like GAE or Beanstalk I do deploy from Eclipse plugin, it is the same like command line.

Categories

Resources