logo

Your Own Custom Java Console in Notes Client

When writing Java Agents that run in the Notes client you can use the Java Console to see the result of any System.out.println() calls. Useful for debugging and dumping stack traces to when there's an error.

image

To display the Java Console you need to look inside the Tools menu of the Notes client. Not something an average user would know to do and not something you could expect them to do.

The Java Console is therefore best used by us developers and isn't much use when it comes to displaying text to an actual user, which is what I needed to do this week and so I wrote a simple Java class to let me report back to the user, like so, as an Agent progresses.

image

The class is called OutputWindow (I've never been much good at naming things) and a sample usage looks like this:

public class JavaAgent extends AgentBase {

    private OutputWindow output;
    
    public void NotesMain() {

      try {
          output = new OutputWindow();
          output.show();
          
          output.println("About to run the code...");
          
          for(int i=0; i<=100; i++ ){
              output.println( Integer.toString( 1 / ( 20 - i ) ) );
          }

      } catch(Exception e) {
          output.showErrorMessage("There was an error! See main window for more details");
          output.append(Utils.getStackTraceAsString(e));
          e.printStackTrace();
       } finally {
           output.setCloseable(true);
       }
      
   }
}

Notice that is has a "showErrorMessage" helper method which results in this:

image

If it's of use to you then the code is here. I'm not saying it's perfect code, but it does a job.

Comments

  1. Useful to have a console meant for users and not only developers

    Had same idea some years a go :-)

    A Java and LotusScript console:

    http://nevermind.dk/nevermind/blog... ..-have-an-output-console-for-java-and-lotusscript-agents.

    PS In Swing you should always update the GUI in its own thread.

      • avatar
      • Jake Howlett
      • Tue 27 Mar 2012 05:59 AM

      Great minds think alike ;-)

      • avatar
      • Chris C
      • Tue 27 Mar 2012 12:13 PM

      Jesper,

      Your blog is awesome! I can't believe I've never seen or heard about it before today. I'm adding it to my RSS feeds.

      Show the rest of this thread

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Tue 27 Mar 2012

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content