JAR - Java Archive
A JAR (Java Archive) is a platform-independent file format used to aggregate many Java class files, associated metadata, and resources (text, images, etc.) into a single file for distribution and deployment. On z/OS, JARs are the standard packaging mechanism for deploying Java applications, libraries, and components that run within a z/OS Java Virtual Machine (JVM) environment.
Key Characteristics
-
- Standard Java Packaging: It is the universal standard for packaging Java code and resources, making Java applications highly portable across different operating systems, including z/OS.
- Contents: A JAR file typically contains compiled Java
.classfiles, aMETA-INFdirectory (which includes theMANIFEST.MFfile), and other application resources like property files, images, or configuration files. - Executable JARs: A JAR can be made executable by specifying a
Main-Classentry in itsMANIFEST.MFfile, allowing it to be run directly using thejava -jarcommand. - Deployment on z/OS UNIX: JAR files are stored within the z/OS UNIX System Services (z/OS UNIX) file system (either HFS or zFS) and are accessed by JVMs running on z/OS.
- Classpath Integration: JVMs on z/OS use the
CLASSPATHenvironment variable or JCL parameters to locate and load classes and resources from specified JAR files. - Security: JAR files can be digitally signed for security purposes, allowing the JVM to verify their origin and integrity, which is particularly relevant in secure enterprise environments.
Use Cases
-
- Batch Java Applications: Packaging Java programs intended to run as traditional z/OS batch jobs, invoked via JCL that starts a z/OS JVM to execute the JAR.
- CICS Java Applications: Deploying Java applications that run within a CICS region, often utilizing CICS JVM servers or the CICS Liberty profile, where application logic is contained within JARs.
- z/OS UNIX Utilities: Creating and deploying Java-based command-line utilities or background processes that operate directly within the z/OS UNIX environment.
- DB2 Stored Procedures and UDFs: Implementing DB2 stored procedures or user-defined functions (UDFs) in Java, where the compiled Java code is packaged in a JAR and registered with DB2.
- WebSphere Liberty Profile on z/OS: Deploying microservices and Java EE applications (often packaged as WARs or EARs, which internally contain JARs) to a WebSphere Liberty profile server running on z/OS.
Related Concepts
JARs are fundamental to Java execution on z/OS, working in conjunction with the Java Virtual Machine (JVM), which is the runtime environment that executes the code within a JAR. They are stored in the z/OS UNIX System Services (z/OS UNIX) file system, making them accessible to various z/OS components. JCL is frequently used to invoke the JVM and specify the JAR to be executed, often through utilities like BPXBATCH or direct JAVA program calls, while CLASSPATH configuration is crucial for the JVM to locate all necessary JARs.
- Optimize CLASSPATH: Minimize the number of JARs and directories in the
CLASSPATHto improve JVM startup performance and reduce memory consumption, especially in resource-constrained environments like CICS JVM servers. - Separate Application and Library JARs: Package application-specific code into its own JAR and external dependencies into separate library JARs for better modularity, easier maintenance, and reduced redeployment scope.
- Manage z/OS UNIX Permissions: Ensure that JAR files and their containing directories have appropriate read permissions for the user ID under which the JVM process runs, preventing file access errors.
- Version Control and Deployment: Integrate JAR files into a robust version control system and establish clear deployment procedures to manage updates and rollbacks effectively in the z/OS environment.
- Performance Tuning: Monitor the performance of Java applications running from JARs on z/OS and tune JVM parameters (e.g., heap size, garbage collection settings) to optimize resource utilization and throughput.