IBM Support

Managing IBM JZOS jar file dependencies using Maven and Visual Studio Code

How To


Summary

Developing Java applications for z/OS and utilizing the Java™ Batch Launcher Toolkit for z/OS® (JZOS) libraries will require the use of the IBM JZOS jar files. The IBM JZOS jar files are part of the Java™ Batch Launcher and Toolkit that is installed on the host, however due to license restrictions they may not be copied to local client side workstations. To develop your Java applications locally on your workstation, you will need the IBM JZOS jar files. IBM makes available a limited version of the IBM JZOS jar file that when added to your Java project will resolve JZOS library dependencies. This limited JZOS jar file is available via Maven. This set of instructions will allow you to integrate Maven into your Visual Studio Code (VS Code) Java project and link in the limited IBM JZOS jar library.

Note: The limited IBM JZOS jar file from Maven will only allow you to build and compile your Java program and resolve your JZOS dependencies. Your java program will not run locally because it needs access to mainframe resources.

Steps

1.  Verify you have a JDK installed and take note the version.

From Windows Command Prompt:

java -version

2.  Download and Install VS Code if it is not already installed. 

https://code.visualstudio.com/download

3.  Check if you have Maven Installed and it is accessible from within VS Code.

               a)  Start VS Code

               b)  Terminal -> New Terminal

               c) 

mvn --version

              

               (If you get a Maven Version returned then Maven is installed and accessible.  Proceed to Step 7)

4.  Download Apache Maven.

https://maven.apache.org/download.cgi

5.  Unzip it somewhere on your workstation.

6.  Add the Maven bin directory location to your windows path.

a)  Windows-> System -> About -> Advanced System Settings -> Environment Variables -> Edit Path entry and add the Maven bin location.  A restart of VS Code is required if VS Code was already open.

b) Check if Maven Installed and its accessible in VS Code:

               a)  Start VS Code

               b)  Terminal -> New Terminal

               c)

mvn --version

7.  Chack if the Maven Plugin Extension is integrated with VS Code.  It’s a good idea to install the “Extension Pack for Java” which contains the Maven extension as part of the package.

Extensions -> Extension Pack for Java -> Install   (Proceed to Trust the install)

image-20240220155140-31

8.  Download Sample Projects that use the JZOS Toolkit.

Find JZOS Samples then download and unzip it to a directory.

https://www.ibm.com/docs/en/sdk-java-technology/8?topic=components-jzos-batch-launcher-toolkit

9.  Create a new Java Maven Project.

a)  Select:  Create Java Project Button

b)  Select Wizard:  Maven  create from archetype

image-20240220155140-32

c)  Select maven-archetype-quickstart

image-20240220155140-33

d)  Select latest Version:  1.4 (at time of writing)

image-20240220155140-34

e)  Input your Java project a group id:  eg  com.ibm.jzos.sample

image-20240220155140-35

f)  Input your java application name as the artifact Id:  (lower case only)

image-20240220155140-36

h)  Select a destination folder where this project will be created under:  eg Maven Java Projects

I)  When prompted, Trust the authors by selecting the checkbox followed by Yes.   (you created it)

image-20240220155140-37

J)  Now you should have a Java and Maven Project in your File Explorer

image-20240220155140-38

k)  Expand and open Main.  Notice you now have a pom.xml file which is the Maven project management file.

image-20240220155140-39

l)  Edit the Main.java file then copy and paste some code from one of the samples you found in the JZOS samples zip file.  Make sure it uses one some functions from the com.ibm.jzos libraries.

m)  Rename the Main.java file to correspond with the name of the java sample you are using.  Eg CatalogSearchSample.java

image-20240220155140-40

n)  Notice that you have several unresolved dependencies for com.ibm.jzos .  We will use Maven to locate and download the missing dependencies.

image-20240220155140-41

o)  Determine which JZOS library you need to include in your project depending on the Java version you have installed.

image-20240220155140-42

p)  Click on Maven Dependencies under the Java Projects folder then click the +  (Add dependencies button)

image-20240220155140-43

q)  Enter either ibm.jzos or ibmjzos in the search field depending on the Java version you are using.

image-20240220155140-44

r)  Select the appropriate JZOS jar file and notice that your project pom.xml file will open up and the JZOS library will have been added.  SAVE your pom.xml file.

image-20240220155140-45

s)  Once you save the pom.xml file a build and synchronize process will begin.  Select Yes

image-20240220155140-46

t)  Now your dependencies should be resolved.

image-20240220155140-47

u)  You can compile your project using Maven commands.

Right click on your Maven project -> Run Maven Commands -> Compile

image-20240220155140-48

v)  You may need to edit the Java compiler version that Maven uses:

image-20240220155140-49

Additional Information

Getting the IBM jzos.jar file without using Maven
1.  Maven downloads dependency jar files to your local PC in Maven repository called .m2.  The default location in Windows is:

C:\Users\<username>\.m2\repository

2.   You can also search and download jar files directly from the Maven web site: 

https://central.sonatype.com/

image-20240220154909-26

image-20240220154909-27

image-20240220154909-28

image-20240220154909-29

1.  If the Maven View is not visible, then you can perform: 

Ctrl+Shipt+P  -> maven  -> Execute Maven Commands

image-20240220154909-30

Document Location

Worldwide

[{"Type":"MASTER","Line of Business":{"code":"LOB35","label":"Mainframe SW"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSK5UBS","label":"IBM watsonx Code Assistant for Z"},"ARM Category":[{"code":"a8m3p0000006xktAAA","label":"Z Open Editor-\u003EWatsonx Code Assistant for Z"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions"}]

Document Information

Modified date:
20 February 2024

UID

ibm17121508