Examples: Using environment variables (Java)

This example increments the environment variable $SeqNo by one and prints the result. (This program would not be reliable on a server for maintaining a system of sequential numbers.)

import lotus.domino.*;
class seqno extends NotesThread
{
  public static void main(String argv[])
    {
        seqno t = new seqno();
        t.start();
    }
  public void runNotes()
    {
    try
      {
        Session s = NotesFactory.createSession();
        int seq;
        if (s.getEnvironmentValue("SeqNo") == null)
          seq = 0;
        else
          seq = 
           ((Integer)s.getEnvironmentValue("SeqNo")).
               intValue();
        System.out.println(seq);
        seq++;
        s.setEnvironmentVar("SeqNo", new Integer(seq));
        System.out.println(s.getEnvironmentValue("SeqNo"));
      }                
    catch (Exception e)
      {
        e.printStackTrace();
      }
    }
}