How are Java applications deployed in the “real world”?

As a novice in the Java programming world, this problem always bothers me I first thought that all java files were compressed into applets and then run, but I soon realized that this was not always the case Can someone explain to me how we actually interweave our Java applications into real products of daily life?

TL; Dr: how do we implement the actual use of our code?

Solution

It depends on the application There are many options depending on how users use your application Usually it is packaged in cans or special cans (war, ears)

In theory, you can use Class file compresses the original directory structure and provides shell scripts / instructions for users to run Java commands I don't recommend this because it is unprofessional and requires you to maintain a shell script for each operating system on which you want to run the program

Jar files is used to package libraries, but you can also display a manifest file in it that says, "run this class when someone double clicks / performs this operation." This class can launch GUI or headless tasks as response parameters, etc

You can have applets, as you said These programs run in the user's browser

You can use war file, which is a way to package web applications You provide it to the web server, which knows how to deploy it so that you can access web pages An example of a web server / container is Tomcat or jetty

You can have an ear file that can contain other war files This is for applications that require other parts of Java EE functionality (EJBs, JMS queues, etc.) An example of an application server is JBoss or GlassFish

There are also Java Web start applications These are applications that can be run by accessing web pages, but they will be downloaded to your computer and run on the user's computer (not on the back end of the server, such as in war / ears)

And JavaFX I don't know what By skimming the FAQ, which seems to be Java's answer to Adobe's flex You can configure UI components using XML configuration I don't know what format JavaFX applications use, but it does say, "deploy on the desktop or in a browser."

Since Sotirios delimanolis mentioned in the following comments, you can build these files using a build system such as ant or Maven You can also build them "manually" using the tools included with the Java / Java EE SDK For example, if you installed SDK, you should have a jar command in your path Here are some details of these build systems:

> Maven

>Advanced (you tell it what to build, not how to build it) > not just build the system There are also dependency Management > comments (it uses conventions over configuration, generates 1 artifact per configuration file, etc.)

Ants

>Low level (you tell it how to build things) > flexible > configuration file can do whatever you want, build as many artifacts as you want > easy to learn

>SDK tools

>Always keep up to date Eg: rarely, Maven / ant may not be able to set configuration options. It is difficult to remember the command > very low level > itself is not repeatable (eg: unless you build a script, you must type the jar command yourself every time)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>