Tips Tricks Samples

Extract Imported Class Files from an Agent

If you have lost the source code for a Java agent which has only class files stored in it use the following code to extract the class files:

Dim sess As New NotesSession
Dim db As New NotesDatabase("myserver", "mydatabase.nsf")
Dim agent As NotesAgent
Dim doc As NotesDocument
Dim strUNID As String

Set agent = db.GetAgent("MyAgent")
strUNID = Left$(Right$(agent.NotesURL, 42), 32)
Set doc = db.GetDocumentByUNID(strUNID)
Call doc.Send(False, sess.EffectiveUserName)

You will receive a mail from yourself which contains each of the class files as an attachment. These can then be detached to your hard disk and a Java Decompiler used to extract the source code from them. I would recommend the DJ Java Decompiler (http://members.fortunecity.com/neshkov/dj.html).