Java There are many ways to deploy applications on desktop clients .Oracle JDK In fact, the official documents of the company contain explanations on various deployment methods ：Java Platform, Standard Edition Deployment Guide
One of the interesting options is ：Self-Contained Application Packaging, The main thing is to make the installation package of the application come with JRE（ Can be selectively streamlined ）.
So optics Java It's not enough. .
So I learned Java But it's not enough not to study hard .
In addition to the options given in the official guidelines above , There are several other ways to deploy Java application . Thinking is nothing more than ：
- Let users download and install by themselves JRE / JDK, And it may involve the configuration of environment variables
- Distribution package in application （distributable） Bring it in JRE / JDK Installation package , But let users install by themselves , And it may involve the configuration of environment variables
- Integration in the application's installation package JRE / JDK Installation , Just click to confirm JRE End user agreement for
- hold Java Programs are packaged as resources into executable program formats on the target platform , Give users an execution native Impression of procedure , But the app comes with it JRE / JDK To actually execute
- hold Java Program precompile （AOT） On the target platform native form , With a special runtime support system
（Java Web Start、Java Applet I don't want to talk about that. Yeah … Few people use it now , Users usually don't like to use .）
Note that these ideas are not completely mutually exclusive , You can choose to mix and match . For example, press both (1) Small installation package , Also press (3) The way to provide integration JRE Version of the installation package , And implement a native launcher Make it easier for users to start programs .
In the options above ,
(1)、(2) No technical problems , But users need to do more by themselves , And what developers use for users Java Version has no control . In fact, there are many Java This is how applications are deployed … So it's often difficult to make complaints about Tucao. .
oriented Java developer 、 Or maybe Java The developer's tools , It doesn't matter . Anyway, developers usually have to install JRE Or I know how to beat the drum JRE / JDK Put on .
Before speaking Apple stay Mac OS X Yes Java When there's official system level support ,(1) Actually, it's very convenient , If you need to use Java Application for but system level is not installed JRE, Then users will get a pop-up window to remind them to install when they try to start the application Java, Click a few buttons in it and it will automatically Apple Provided JRE Put on the .
Now, Mac OS X Remind users to go Oracle Of Java Website download and installation …
(3) It's a very convenient way , The cost is the distribution package of the application / The installation package will be larger . It's a headache for small apps , Big one 5MB-12MB It's very common … If the application itself is already hundreds of MB Maybe I don't care .
many Java development tool , for example Eclipse、IntelliJ IDEA、Netbeans etc. , All have their own JRE The version of the installation package can be downloaded .
(4) Follow (3) The biggest difference is Java Packaging method of program itself ,(3) Usually a native launcher（Windows Of exe And so on ）, but Java The program is still normal Class file 、JAR A format such as a package is stored as a separate file . and (4) Then put Class File or JAR The package is packaged into the executable file as a resource to store , So that users don't 、 Easy to see Class File or JAR package .“ Feeling ” Shanggeng native some . Be careful ： Do not use... For the purpose of protecting program logic (4), Because if a program really works and there's a market , People who want to do reverse analysis will soon find out (4) And extract the resources .
I know someone will Java Package the program into resources and then shell the executable program , As a means of security . I would like to remind you not to rely on this means to provide a high level of protection , And to accept this approach is just to guard against gentlemen and villains ; Make the worst assumptions , All code deployed to the client will eventually be cracked if it has enough value , That's the real idea .
(5) The biggest difference from the above is ： It usually means it can't be used Oracle JDK/JRE This “ standard ”（ Or most common ） The implementation of the , And use a special JVM（ Or more complete JVM More streamlined runtime）. But the compiled program is a native Program ,JVM That's what's integrated into this native In the program .
Which products implement the above options .(1) and (2) Obviously, no “ product ”, It's the developers who write the application themselves README nothing more .
(3) It is also mentioned in the official document at the beginning of this answer . It's worth noting that , Official JRE The installation package can be installed silently ：How do I arrange a silent (unattended) Java installation?
(3) and (4) There are some out of the box support packages , for example install4j、JWrapper etc.
(5) stay x86 The most famous product on Excelsior JET, And then there are other options , for example GCJ And so on . On other platforms ,AOT Maybe deployment Java The main way , For example, in iOS On . For a more detailed list, please skip the portal ：Java Similar to NGen Tools for （AOT compiler ） Do you ？ - RednaxelaFX Answer
It must be said that some people think it's done Java Program as long as JRE Just fine , Why should I mention this JDK.
That's because some applications either involve Java Development function , So need JDK Development tools in , For example, various IDE; Or maybe some of them use only JDK And JRE Application without provided function , For example, using javax.tools.JavaCompiler The program . They all need JDK Tools or libraries .
Speaking of Eclipse, It has many different hairstyles , among IBM There is a very interesting version available ：
developerWorks : Technical Topics : Java technology : IBM Developer kits : IBM Development Package for Eclipse
This version of Eclipse Bring their own IBM JDK, contains IBM J9 VM, Is in Windows Get on the J9 VM One of the most important ways .
Reminded , Think of the hot Java Packaging tools Capsule. Interested students can also go to see what functions it has achieved .
Based on my many years of working experience and learning experience , Recorded a new set of Java Focus on video tutorials , If you are learning now Java, At the beginning of learning Java There is no systematic learning course in the process , You can add QQ Group 654631948 Collect the learning materials , Interview questions , Development tools, etc , There are senior people in the group java The teacher answers questions , Every day, there will also be live lectures on the basic part and architecture , You can also add my wechat renlliang2013 In depth communication , As long as I really want to learn Java People welcome .
java Basic course ：https://ke.qq.com/course/149432?tuin=57912c43
Java Distributed Internet Architecture / Microservices / High performance /springboot/springcloud：