Solved

Step by Step for writing a Java Method in a Lotus Client

Posted on 2006-10-24
28
258 Views
Last Modified: 2013-12-18
This question has been asked before, but I was side tracked on a differnt project.  So now I am needing to be able to get this to work.

1.  I want to run an agent that will parse a jar file sitting on the server.  
2.  The jar file gets information from a differnt system and return values.  
3.  I want to take those values and create new documents.

Is writing a Shared script library /new java library the way to do this?  If that is the case, I need to figure out a way to include(setup) a class path?
can you do something like that with Lotus Script?  or Java Script?  

If the jar file is sitting on the same server as the nsf file, is that considered local?
0
Comment
Question by:Jaziar
  • 15
  • 13
28 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17795750
Parse a jar-file? Or is it XML?

State your business requirements first, we can dive into the design details later on.
0
 

Author Comment

by:Jaziar
ID: 17795874
It is a executable jar file.

Basically, I am wanting to get part infomation from a differnt system.  I want to have a agent runs every 15 minutes that goes and queries the other system (jar file has query) return the information to notes, notes will create a document for each part.
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 500 total points
ID: 17795970
The jar-file is fixed, it contains one or more classes with methods? Basically, you want to create and use objects as defined in the jar-file? Or is it a Java executable, that runs in a command-screen, with
    Java -jar yourprog.jar
and you want to use the output?
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:Jaziar
ID: 17796163
Yes - fixed with class and method
Yes - I want to create / objects in defined in the jar fil
It is not a executable that run in the command-screen.
Yes - I need to be able to use the output.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17797168
Do you have the interface to the classes defined in the jar-file? Is there a Java test program you can use as an example? Documentation etc?

My first approach would be to create a small agent that just creates an object from a class in the jar-file. That's the biggest hurdle.
0
 

Author Comment

by:Jaziar
ID: 17797331
Is there a Java test program you can use as an example?

Do you mean code?  I can show you the test java program
0
 

Author Comment

by:Jaziar
ID: 17797358
this is the test java code

package com.company.apps.lotusquery;

import matrix.util.Version;


public class EBOMQuery {

    public EBOMQuery() throws Exception {
    }
   

    /**
     * !! The actual functionality here is only a stub for prototyping !!
     * Returns a list of parts, in tab-delimited format, contained within
     * the specified EBOM.  The EBOM is specified by the top-level part
     * name.  The latest revision of the specified EBOM will be retrieved.
     * @param   ebomName    the name of the top-level part for this EBOM
     */
    private String getTabDelimEBOMPartList(final String ebomName) throws Exception {

        /* Use a class from the eMatrixServletRMI.jar file */
        Version version = new Version();
        System.out.println("Application: " + version.application + "\nVersion: " + version.number + "\n");

        String tdpl = "Arm\t3000895\tA\t35004.36845.11282.30693\nGear\t3000954\tA\t35004.36845.15714.59706\nSensor\t3000883\tA\t35004.36845.14669.476\n";
        return tdpl;
    }


    public static void main(String[] args) throws Exception {
        EBOMQuery ebomQuery = new EBOMQuery();
        String tabDelimPartList = ebomQuery.getTabDelimEBOMPartList("3000440");
        System.out.println(tabDelimPartList);
    }

}
0
 

Author Comment

by:Jaziar
ID: 17797411
Do you mean interface documentation?  If so, then yes, we have Java Docs that list all of the packages, classes, and methods in the jar file.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17797481
Ah, great! That should mean that you could try some code on your PC, in a client agent or so.

Your first attempt might be to create a Java agent and run it. Just the default agent content would do, I think.

Then add the lines
    package com.company.apps.lotusquery;

    import matrix.util.Version;

to the agent, and compile it. The jar-file should have been copied to some directory that can be found by the Designer. Or add it to the CLASSPATH in the environment settings of your PC.

Once you get that done, you're at 60%...
0
 

Author Comment

by:Jaziar
ID: 17797533
Will the designer be able to find the jar file if it is setting on the same server as the nsf file?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17797581
Let's first try to make this work on your PC, if that's at all possible. In a later stage (you wanted it step by step, didn't you? ;-) we could try the agent (tested and working on your system) on the server. But you're right, you'd have to place the jar-file on the server as well, also in a directory the server can find (e.g. using the CLASSPATH environment variable).
0
 

Author Comment

by:Jaziar
ID: 17797612
Since users are using this database. I had the jar file placed on the same server as the notes .nsf file.  Is there a way in the client to set the class path?
0
 

Author Comment

by:Jaziar
ID: 17797705
import matrix.util.Version; Allways errors here - says class not found on import
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17799813
In order to test it on a client, everything must be present on the client! Java compilation is also done locally. The classpath MUST be set on the local system as well, in the configuration somewhere (as it used to be in autoexec.bat). It should be in the Configuration settings, System, Advanced, Environment variables.

I suppose matrix.util.Version isn't required for the test, so try only with the package.
0
 

Author Comment

by:Jaziar
ID: 17803244
Good Morning Bosman

Here is my question.  My client is indeed sitting on my local machine, but the database that I am working in, is sitting on a server.  Do I need to do this testing on a local database?  I did add the path to the jar in my local Enviroment settings.  I will remove the matrix.util.Version and try to recompile.
0
 

Author Comment

by:Jaziar
ID: 17803260
After removing the above, this compiles fine


package com.company.apps.lotusquery;

import lotus.domino.*;

public class JavaAgent extends AgentBase {

      public void NotesMain() {

            try {
                  Session session = getSession();
                  AgentContext agentContext = session.getAgentContext();

                  // (Your code goes here)

            } catch(Exception e) {
                  e.printStackTrace();
            }
      }
}
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17804970
Good! Now try this:

package com.company.apps.lotusquery;

import lotus.domino.*;

public class JavaAgent extends AgentBase {

     public void NotesMain() {

          try {
               Session session = getSession();
               AgentContext agentContext = session.getAgentContext();

               EBOMQuery ebomQuery = new EBOMQuery();
               String tabDelimPartList = ebomQuery.getTabDelimEBOMPartList("3000440");
               System.out.println(tabDelimPartList);

          } catch(Exception e) {
               e.printStackTrace();
          }
     }

    /**
     * !! The actual functionality here is only a stub for prototyping !!
     * Returns a list of parts, in tab-delimited format, contained within
     * the specified EBOM.  The EBOM is specified by the top-level part
     * name.  The latest revision of the specified EBOM will be retrieved.
     * @param   ebomName    the name of the top-level part for this EBOM
     */
    private String getTabDelimEBOMPartList(final String ebomName) throws Exception {

        /* Use a class from the eMatrixServletRMI.jar file */
        Version version = new Version();
        System.out.println("Application: " + version.application + "\nVersion: " + version.number + "\n");

        String tdpl = "Arm\t3000895\tA\t35004.36845.11282.30693\nGear\t3000954\tA\t35004.36845.15714.59706\nSensor\t3000883\tA\t35004.36845.14669.476\n";
        return tdpl;
    }

}
0
 

Author Comment

by:Jaziar
ID: 17805138
EBOMQuery ebomQuery = new EBOMQuery(); errors -> class not found
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17805224
Excuse me 1000 times. I made several big mistakes in the code and we proved nothing at all (except that my Java isn't very good...).

Firstly, the code doesn't seem to be a test program. The program itself is called EBOMQuery so it references nothing from the jar-file. Do you have a real test program that you can compile and run with Java? Or can you find, in the documentation, some class you can create an object from?

0
 

Author Comment

by:Jaziar
ID: 17811318
Question

My client is running on my computer
The Database is setting on a server
My Jar File is setting on a server
My Java code in setting in the database on the server

Where is the java?  When I click the compile button, where is the java running?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17812512
If YOU click on a button, the code that's running is on YOUR computer, even if the database is on the server. That's what client-server computing is all about.  Therefore, the jar-file must also be on YOUR computer, in such a place that it can be found by the Notes-client.

So, it would be the easiest way to install everything locally, maybe even the database (either a local replica or a local copy, just for testing purposes). If necessary, you can have a look in the jar-file with a utility like WinRAR, so you can find out what the structure of the classes in it is.
0
 

Author Comment

by:Jaziar
ID: 17812545
I have tested about 3 java programs.  They all compile and work.  

example

import lotus.domino.*;
import java.util.Vector;

public class JavaAgent extends AgentBase {

      public void NotesMain() {

            try {
                  Session session = getSession();
                  AgentContext agentContext = session.getAgentContext();

                  Database db = agentContext.getCurrentDatabase();
                  Document memo = db.createDocument();
                  
                  // set the field values
                  memo.appendItemValue("Form", "A Person");
                  memo.appendItemValue("Subject", "You've Got Mail");
                  RichTextItem body = memo.createRichTextItem("Body");
                  body.appendText("Here is the attachment:");
                  body.addNewLine(2);
                  body.embedObject(EmbeddedObject.EMBED_ATTACHMENT, null, "c:\\autoexec.bat", "autoexec.bat");
                  
                  // add all the recipients you want
                  Vector v = new Vector();
                  v.addElement(session.getUserName());
                  v.addElement("Someone Else");
                  
                  // and send it off
                  memo.send(true, v);

            } catch(Exception e) {
                  e.printStackTrace();
            }
      }
}

So I am guessing the next step is I need to make sure I can see the jar file on my local system from the client.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17812678
Indeed. The easiest way is to find out if the thing compiles with just one reference to a class in that jar-file. So: get your documentation or a test program, and find out where the first object is created that is based on a class in the jar-file. Try to create a similar object, only the creation, and nothing else.
0
 

Author Comment

by:Jaziar
ID: 17814657
I have a java program (agent) that is using the jar file on the server.  If my Java program writes the output to a flatfile, how do I know where the file goes?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17814751
If it's a scheduled agent that runs on the server, the output will also be written in a file on the server. I think...
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17825039
Found this somewhere:

To tell Notes where the Java classes are, include the following line in your Notes.ini file:
    JavaUserClasses = <classpath1>;<classpath2>; ... <classpathn>

For example, if the Java classes are in one directory, such as E:\LSI\test\java, the Notes.ini file would include the following line:
    JavaUserClasses=E:\LSI\test\java
0
 

Author Comment

by:Jaziar
ID: 17852113
I think this problem has been answered, I am now working on the Java code
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17875777
Well done! And thanks!
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question