可以啊,我以前试过的.我一直在dos环境下使用MSN

解决方案 »

  1.   

    我在win2000 server下运行,这样消息发不出去,你能给我一个能运行的完整的(即登录成功后马上给某人发一条消息)的代码,感激不尽!
      

  2.   

    http://www.javayou.com/dlog/showlog.asp?log_id=586
      

  3.   

    一下是一个可以运行的具体例子:
    public class JMsnTest extends Thread {
    private static MSNMessenger msn; public static void main(String[] args) {
    msn = new MSNMessenger("[email protected]", "password");
    msn.setInitialStatus(UserStatus.ONLINE);
    msn.addMsnListener(new MSNAdapter(msn));
    msn.login();

    MimeMessage me = new MimeMessage("ok");
    me.setKind(MimeMessage.KIND_MESSAGE);

    try {
    Thread.currentThread().sleep(1500); 
    msn.doCall("[email protected]");
    } catch (Exception e) {
    e.printStackTrace();
    }
    System.out.println("Waiting for the response....");
    Runtime.getRuntime().addShutdownHook(new JMsnTest());

    }

    public void run() {
    msn.logout();
    System.out.println("MSN Logout OK");
    }
    }
    class MSNAdapter extends MsnAdapter {
        public void switchboardSessionStarted(SwitchboardSession switchboardsession) {
    MimeMessage hello = new MimeMessage("hello");
    hello.setKind(MimeMessage.KIND_MESSAGE);
    try {
    boolean sendok = messenger.sendMessage(hello,switchboardsession);
    switchboardsession.sendMessage(hello);
    System.out.println("sendok = " + sendok);
    } catch (Exception e) {
    e.printStackTrace();
    }

        }}