Solved

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

Posted on 2006-10-24
28
250 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:Jaziar
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
import matrix.util.Version; Allways errors here - says class not found on import
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Jaziar
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
EBOMQuery ebomQuery = new EBOMQuery(); errors -> class not found
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I think this problem has been answered, I am now working on the Java code
0
 
LVL 46

Expert Comment

by:Sjef Bosman
Comment Utility
Well done! And thanks!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now