[Aglets-users] compile problem
Status: Beta
Brought to you by:
cat4hire
From: Lucas K. <luc...@ho...> - 2002-08-17 17:08:12
|
Hi everyone, I have just installed the AgletSDK 2.0.2 on XP and Having problem to use it with Java SDK1.4.1 I was trying to compile a sample code below I downloaded from javaworld but the compiler does not recognise the aglet package. Is there anyway I can set a permanent path so I can compile a java program that imports the aglet package and run it? Thank you for your help. Lucas // Searcher.java // Bret Sommers, 970220 import aglet.*; public class Searcher extends Aglet { // State private Document desiredDocument; // Event handlers public void onCreation(Object init) { // Create a new document for which this agent will search. if (init == null) { desiredDocument = new Document(); } else { desiredDocument = new Document((String)init); } // Subscribe to Publisher NewDocumentAlert messages. try { subscribeMessage("NewDocumentAlert"); } catch (Exception e) { e.printStackTrace(); } report("Created (keyword: " + desiredDocument.getKeyword() + ")."); } public boolean handleMessage(Message msg) { // Handle newly published documents. if (msg.kind.equals("NewDocumentAlert")) { testDocument((Document)msg.getArg("Document")); return true; } return false; } // Behaviors public void testDocument(Document newDocument) { // Compare the newly published document with the // document for which the agent is searching. if (newDocument.matches(desiredDocument)) { // If they match, report so and go away. // In a real system, the creator of the Searcher agent // might be notified via email or other means. report("Found desired document (keyword: " + newDocument.getKeyword() + ")."); try { dispose(); } catch (InvalidAgletException e) { e.printStackTrace(); } } } // Utility methods public void report(String message) { System.out.println(getIdentity() + ": " + message); } public String getIdentity() { String identity = ""; try { identity = "Searcher " + getIdentifier(); } catch (InvalidAgletException e) { e.printStackTrace(); } return identity; } } |