Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

Objective: The objective of this blog is to elaborate on the procedure to change / edit an existing JAVA mapping using NWDS. The target audience for this blog is the SAP PI developers who are new to the concept of JAVA mapping.

  1. Find the imported archive (JAVA mapping) or the .jar file in ESR which you want to change and then download it to your desktop locally. The .jar file would normally contain two or more files, .class file (generated after the .java file is compiled in any JAVA IDE) and .java file which would normally contain the JAVA code for mapping logic.

Go to the Tools->Export Archive


2.      The .jar file is nothing but an archive like .zip which contains multiple files. To see the files within .jar file, use a tool like WinZip or 7-zip file manager.              Now open the 7-zip file manager and open the .jar files.

    Now by right clicking on the .java file, copy it from .jar archive to your desktop locally. This .java file can be opened using notepad also to view the           JAVA code for mapping.


3.      Now to edit the .java file, open NWDS, create a new JAVA project. Specify the project name and choose the relevant JRE (JAVA runtime environment          – specific to your machine).


   The NWDS would ask you to open the JAVA perspective for the code change. Click on yes and proceed.


4.    Copy the .java file (not the content) from your desktop and paste it on the src folder in your java project. Expand the src node within the project and                 the .java file can be seen underneath. Double click on the .java file to see the JAVA code on the right hand side window.

5.     Another way to import the .java file to your JAVA project is to import the .jar file directly in NWDS. To do this right click on the JAVA project and click                  on import. Then expand the general node and double click on Archive File.


  Browse the .jar file from your local desktop and click on finish.




6.     Now change the JAVA code in the .java file as per the change requirement and save it. A small red cross mark can be seen with the JAVA mapping               which means that the JAVA code has still some errors within.


  In my scenario I needed to import some external .jar libraries.

  Get access to these external .jar libraries and store them on your desktop locally.

  Right click on the JAVA project, Build path->Add External Archive



7.    Once added, the external .jar library can be seen under Referenced Libraries and the red cross mark disappears and is replaced by a yellow warning              sign meaning the java code doesn’t have any errors now and only has warnings.



8.      Ensure to check the option of Build automatically (which is default) from the project menu bar.



9.    Now export the .jar file for this JAVA project to your desktop which would again contain the newly generated .class file and the changed .java file.

Right click on the JAVA project, click on export, expand the JAVA node and click on JAR file.



10.    Ensure following while exporting the .jar file.

    1. The correct JAVA project is selected.
    2. The .classpath and .project files are unchecked (As they were not part of the original .jar file.  But these might be needed if they were part of the original .jar file which you downloaded from ESR as specified in step no 1.
    3. The checkboxes are ticked which would generate files for .class (first check box) and .java (third checkbox).
    4. Specify the target .jar file name which would be downloaded to your desktop.

11.    Click on finish and .jar file is downloaded on your desktop.

   Now go back to change mode of imported archive in ESR and import the new .jar file.

   Save and activate the imported archive.

   Also ensure to double click the .java file and verify whether the new JAVA code changes reflect there or not.

Hope it helps.

1 Comment
Labels in this area