下面是源码:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.java.sip.communicator.launcher;import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import net.java.sip.communicator.impl.gui.GuiActivator;
import net.java.sip.communicator.service.contactlist.MetaContact;
import net.java.sip.communicator.service.contactlist.MetaContactListService;
/**
 *
 * @author libr
 */
public class ListenThread extends Thread{
    @Override
    public void run()
    {
       ServerSocket server = null;
       Socket you=null;
       byte[] b= new byte[1024];
       int len;
       DataOutputStream out = null;
       DataInputStream in =null;
       try {
            server=new ServerSocket(4331);
       } catch (Exception e) {
            System.out.print(e);             
       }
        try {
            System.out.println("waiting client call");
            you = server.accept();
            out = new DataOutputStream(you.getOutputStream());
            in = new DataInputStream(you.getInputStream());            while(true)
            {           
                len = in.read(b, 0, b.length);
                String s = new String(b,"UTF-8").trim();                
                //System.out.println(s);         
                if(s != null){
                    String[] array = s.split(",");
                    if("chat".equals(array[0]))
                    {
                            System.out.println("open chat form");
                            OpenChatform(array[1]);
                    }else if("audio".equals(array[0]))
                    {
                            System.out.println("open audio form");
                            OpenAudioform(array[1]);
                    }else if("vedio".equals(array[0]))
                    {
                            System.out.println("open vedio form");
                            OpenVedioform(array[1]);
                    }else if("sharedesktop".equals(array[0]))
                    {
                            System.out.println("sharedesktop");
                            Sharedesktop(array[1]);
                    }                    
                }
            }
        } catch (Exception e) {
            System.out.println("error!");
        }
    }
    
    public void OpenChatform(String somebody)
    {
        try{
             MetaContactListService mcls= GuiActivator.getContactListService();//注释掉这两句就没错
             MetaContact metacontact = mcls.findMetaContactByMetaUID("13315428578346794958");
             int t =0;
        }
        catch(Exception e)
        {
            
        }                    
    }     
}把OpenChatform这里面的code注释掉就没事了求解咋回事?

解决方案 »

  1.   

    把这几个类也贴出来一下。。import net.java.sip.communicator.impl.gui.GuiActivator;
    import net.java.sip.communicator.service.contactlist.MetaContact;
    import net.java.sip.communicator.service.contactlist.MetaContactListService;
      

  2.   

    不用贴了,我估计是ant的原因,用的netbeans第一个target运行不出错,第二个target运行就出错了! 不懂ant ,哪个设置导致的区别?<?xml version="1.0" encoding="UTF-8"?>
    <!-- Created by Brian Burch on August 25, 2005
         Netbeans debug targets are now held in this file.
        -->
    <project basedir=".." name="SIP Communicator-IDE">
        <import file="../build.xml"/>
        <target depends="deploy-os-specific-bundles" description="Starts felix and runs sip-comunicator gui (use latest build)." name="debug-nb-wholeApp">
            <nbjpdastart addressproperty="jpda.address" name="SIP Communicator" transport="dt_socket">
                <classpath refid="debug.class.path"/>
                <sourcepath refid="project.source.path"/>
            </nbjpdastart>
            <!-- we allow users to pass command line args using the "args" system
                 property. However we need to manually set that prop to an empty
                 string here (in the normal case the user will not have defined
                 any - otherwise the application would find an argument with
                 the value ${args} )-->
            <property name="args" value="--multiple"/>
            <!-- fork=true no longer prevents debug break points latching... -->
            <java classname="net.java.sip.communicator.launcher.SIPCommunicator" failonerror="true" fork="true">
                <classpath refid="debug.class.path"/>
                <jvmarg value="-Xdebug"/>
                <jvmarg value="-Xnoagent"/>
                <jvmarg value="-Djava.compiler=none"/>
                <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
                <!-- Sets the charset for the messages -->
                <!--sysproperty key="icq.custom.message.charset" value="windows-1252"/-->
                <!-- Tell felix to run sip-communicator-->
                <sysproperty key="felix.config.properties" value="file:${lib}/felix.client.run.properties"/>
                <!-- Tell java.util.logging about our logging preferences -->
                <sysproperty key="java.util.logging.config.file" value="${lib}/logging.properties"/>
                <sysproperty key="java.net.preferIPv6Addresses" value="false"/>
                <!--sysproperty key="net.java.sip.communicator.SC_HOME_DIR_LOCATION"
                        value="${user.home}/schome"/-->
                <!-- Setting properties necessary for dependencies on native libs.-->
                <sysproperty key="java.library.path" path="${ld.library.path}:${path}:${dyld.library.path}"/>
                <!-- pass l10n properties from ant call for
                     easy translation debugging -->
                <sysproperty key="user.language" value="${user.language}"/>
                <sysproperty key="user.country" value="${user.country}"/>
                <sysproperty key="user.variant" value="${user.variant}"/>
                <env key="LD_LIBRARY_PATH" path="${ld.library.path}"/>
                <env key="PATH" path="${path}"/>
                <env key="DYLD_LIBRARY_PATH" path="${dyld.library.path}"/>
                <!-- make sure that we automatically enable system.out when running
                     SIP Communicator from Ant-->
                <arg line="--debug"/>
                <!-- pass to SC args that have been specified by the user -->
                <arg line="${args}"/>
            </java>
        </target>
        <!-- TODO: edit the following target according to your needs -->
        <!-- (more info: http://www.netbeans.org/kb/articles/freeform-config.html#debugj2se) -->
        <target depends="deploy-os-specific-bundles" description="Starts felix and runs sip-comunicator gui (use latest build)." name="debug-nb">
            <!-- we allow users to pass command line args using the "args" system
                 property. However we need to manually set tha prop to an empty
                 string here or otherwise the application would get an argument with
                 the value ${args}-->
            <property name="args" value=""/>
            <!-- Jitsi on Mac OS X uses a JVMTI agent to handle kAEGetURL
                 AppleScript events. -->
            <condition else="" property="jvmarg.line" value="-agentlib:AEGetURLEventHandlerAgent -Xdock:name='Jitsi' -Xdock:icon='resources/images/logo/sc_logo_128x128.icns'">
                <isset property="is.running.macos"/>
            </condition>
            <condition else="" property="jvm.maxheapsize" value="-Xmx256m">
                <os arch="i386"/>
            </condition>
            <!-- forking prevents from debugging -->
            <nbjpdastart addressproperty="jpda.address" name="jitsi" transport="dt_socket"/>
            <java classname="net.java.sip.communicator.launcher.SIPCommunicator" classpathref="project.class.path" failonerror="true" fork="true">
                <!-- Sets the charset for the messages -->
                <!--sysproperty key="icq.custom.message.charset" value="windows-1252"/-->
                <!-- Tell felix to run Jitsi -->
                <sysproperty key="felix.config.properties" value="file:${lib}/felix.client.run.properties"/>
                <!-- Tell java.util.logging about our logging preferences -->
                <sysproperty key="java.util.logging.config.file" value="${lib}/logging.properties"/>
                <sysproperty key="java.net.preferIPv6Addresses" value="${java.net.preferIPv6Addresses}"/>
                <sysproperty key="gtalktesting" value="${gtalktesting}"/>
                <!--sysproperty key="net.java.sip.communicator.SC_HOME_DIR_LOCATION"
                    value="${user.home}"/>
                <sysproperty key="net.java.sip.communicator.SC_HOME_DIR_NAME"
                    value="schome"/-->
                <sysproperty key="smack.debugEnabled" value="${smack.debugEnabled}"/>
                <!--sysproperty key="smack.debuggerClass"
                    value="org.jivesoftware.smack.debugger.ConsoleDebugger"/-->
                <!-- Setting properties necessary for dependencies on native libs.-->
                <sysproperty key="java.library.path" path="${ld.library.path}:${path}:${dyld.library.path}"/>
                <sysproperty key="jna.library.path" path="${ld.library.path}:${path}:${dyld.library.path}"/>
                <env key="LD_LIBRARY_PATH" path="${ld.library.path}"/>
                <env key="PATH" path="${path}"/>
                <env key="DYLD_LIBRARY_PATH" path="${dyld.library.path}"/>
                <!-- pass l10n properties from ant call for
                     easy translation debugging -->
                <sysproperty key="user.language" value="${user.language}"/>
                <sysproperty key="user.country" value="${user.country}"/>
                <sysproperty key="user.variant" value="${user.variant}"/>
                <!-- make sure that we automatically enable system.out when running
                     Jitsi from Ant-->
                <arg line="--debug"/>
                <!-- pass to SC args that have been specified by the user -->
                <arg line="${args}"/>
                <sysproperty key="org.osgi.framework.bootdelegation" value="${profiler.bootdelegation}"/>
                <sysproperty key="felix.auto.start.68" value="${profiler.autostart}"/>
                <!-- add some eventual profiler args, prevent server-class
                     detection because -server uses much more memory for 32-bit OS
                     (64-bit always used -server) -->
                <jvmarg line="${profiler.args} ${jvmarg.line}               -client ${jvm.maxheapsize}"/>
                <sysproperty key="apple.laf.useScreenMenuBar" value="true"/>
                <jvmarg value="-Xdebug"/>
                <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
            </java>
        </target>
    </project>