[go] java Packaging apk, jar, war, Ear Package

Source: Internet
Author: User

apk, war, Ear Zip compression available, It looks like these four packages are zip/jar in a simple way to Generate.

------------------------------------------------------------------------

android-apk Packaging Process &adb common directives ( go to: http://15035554141.iteye.com/blog/2090198)

Android-apk.png

Procedures for Package & installation

Src: Jar file compiled as class file

Gen Under: auto-generated Files

Android-dx.png

Call Dx.bat to convert class file to Dex file

Generate signature

    1. 。 Convert Java files to. classes bytecode
    2. Convert. Classes files to Dex files using Dx.bat
    3. Package all the resources into a RESOURCES.AP_ file.
    4. Pack all the resources, dex, inventory files into apk files (apk nature is zip compressed File)
    5. The next step is Meta-inf's signature File. (APK generates Digital Signature)
    6. Next Abd debug the bridge and install the APK onto the virtual Machine.

If there is a problem with the program, you can view the project according to the process where error

How is the APK installed on your Android phone?

For example, window installation files, specifying the installation directory, the process is to copy the installation package files to the specified installation directory

Window unloads the files and deletes the files copied from the installation directory.

Android under Install App:

    1. Copy xx.apk to/data/app/xx-1.apk
    2. Create a folder under The/data/data directory with the folder name as the package name for the current application
    3. Uninstall/data/data file delete, delete/data/app/apk file

Android registry: stored as XML file, read files faster

/DATA/SYSTEM/PACKAGES.LIST-APK the corresponding Data directory

/packages.xml-package name corresponding location, digital signature and other information

--------------------------------------------------------------------------------

java-based Packaging of jar, war, ear package and the difference between the detailed turn from: http://blog.csdn.net/liu36032075/article/details/10615275
Jar WAR EAR
English Java Archive File Web Archive File Enterprise Archive File
Include content class, Properties file, is the smallest unit of file encapsulation, including Java class common library, resources, auxiliary files (auxiliary files), etc. servlets, JSP pages, jsp tag libraries, jar Library files, html/xml documents, and other common resource files, slices, audio files, etc. In addition to including jars and wars, EJB components are included
Deployment files Application-client.xml Xml Application.xml
Container Application Server (application Servers) Small Service Program Container (servlet Containers) EJB Container (EJB Containers)
Level Small In Big

1) Packaging of ear files

The ear file includes the entire project and contains multiple EJB module (jar files) and Web Module (war files).

The generation of the ear file can be generated using WinRAR as a zip compression or as a jar command from the command line.

Steps:

1>, first package into war and jar, and write good application.xml, put in Meta-inf directory.

2>, run the jar CF your_application.ear Your_war.war your_jar.jar meta-inf\application.xml (assuming All in the current directory).

of course, You can also use the Jar XF your_application.ear to Decompress.

Application.xml is used to describe the war and jar included in your ear.

Examples of the application.xml of WebLogic Petstore:

View Plain
  1. <! DOCTYPE application Public '-//sun microsystems, inc.//dtd java EE application 1.2//en ' http://java.sun.com/j2ee/dtds/ Application_1_2.dtd '>
  2. <application>
  3. <display-name>estore</display-name>
  4. <description>application description</description>
  5. <module>
  6. <EJB>customerejb.jar</ejb>
  7. </Module>
  8. <module>
  9. <EJB>mailerejb.jar</ejb>
  10. </Module>
  11. <module>
  12. <Web>
  13. <web-uri>petstore.war</web-uri>
  14. <context-root>estore</context-root>
  15. </Web>
  16. </Module>
  17. <module>
  18. <EJB>petstoreejb.jar</ejb>
  19. </Module>
  20. <module>
  21. <EJB>signonejb.jar</ejb>
  22. </Module>
  23. <module>
  24. <EJB>personalizationejb.jar</ejb>
  25. </Module>
  26. <module>
  27. <EJB>inventoryejb.jar</ejb>
  28. </Module>
  29. <module>
  30. <EJB>shoppingcartejb.jar</ejb>
  31. </Module>
  32. <security-role>
  33. <description>the Gold customer role</description>
  34. <role-name>gold_customer</role-name>
  35. </security-role>
  36. <security-role>
  37. <description>the customer role</description>
  38. <role-name>customer</role-name>
  39. </security-role>
  40. <security-role>
  41. <role-name>administrator</role-name>
  42. </security-role>
  43. </Application>

(2) use of war

1>, generate the war file using the following command: JAR-CVF Web1.war *
2>, See what files are in web1.war, you can use the Command: jar-tf Web1.war
3>, Unzip the Web1.war file, you can use the Command: jar-xvf Web1.war

In addition, you can use the WinRAR software to select the Zip compression method, and the compressed file suffix to the war can be compressed to generate a war file, also use the WinRAR software can forcibly open the war file, or forcibly extract the war file

The difference between using the jar command and the WinRAR software is that the Meta-inf folder, which contains the MANIFEST.MF file, is generated while the file is Compressed.

(3) when to use war or jar files

When your project is not fully completed, it is not appropriate to use the war file, because your class will often change because of debugging, such as to delete, Create a war file is very uncomfortable, preferably your project has been completed, do not change, then make a war package it, At this point a war file is equivalent to a web application, and a jar file encapsulates a class and some related resources into a package for easy reference in the Program.

the role, difference, and packaging of Java's packaged jar, war, ear package:

1. Function and Difference

I. Jar: usually the development time to refer to the generic (JAVA) class, into a package for easy storage management;

Ii. War: is to do a (web) application, usually a Web site, into a package deployed into the container;

Iii. ear: Enterprise applications, in fact, the ear package contains a war package and several Enterprise-level project configuration files, The general server select websphere, etc., will use the ear package. typically, an EJB is called into an ear packet.

2. Packing method

I. All packages are hit with jars, except that the target file has a different extension;

Ii. You can also use ant to build ancheng.

3, jet compiled into EXE

I. Jet is money to buy, and it is said that jet is not able to compile all the Java programs to execute files, performance also have to Discount. so, the best way to make the executable JAR file package is to keep the Java cross-platform feature.

Attention:

After the Web project is exported as a war, it is placed directly under the WebApps of the Tomcat container and the service is started, and the war package automatically extracts a folder with the same name.

[go] java Packaging apk, jar, war, Ear Package

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.