2017-07-19 4 views
0

を使用してチャットクライアントを作る最初の段階で立ち往生私はピシャリとEclipseでJavaを使用してチャットクライアントを構築するために始めていたので、私は次のコードを書き始めた:がピシャリ

import org.jivesoftware.smack.XMPPConnection; 

public class A { 

// Create a connection to the igniterealtime.org XMPP server. 
    XMPPConnection connection = new XMPPConnection("myserver.com"); 
    // Connect to the server 
    connection.connect(); 
    // Most servers require you to login before performing other tasks. 
    connection.login("admin2", "123"); 
public static void main(String[] args) { 
    // TODO Auto-generated method stub 
    A a= new A(); 

} 

} 

をしかし、私は取得しています2つのエラー以下:

Syntax error on token "connect", Identifier expected after this token 

Syntax error on token ".", @ expected after this token 

誰がここに私を助けることができますか?

答えて

2

Uは、メソッド本体から文(例:connection.connect())を挿入できません。

このような何か試してみてください:私はここにも基本的に手探りしていますように思える、

public class A 
{ 
    public void start() 
    { 
     XMPPConnection connection = new XMPPConnection("myserver.com"); 
     // Connect to the server 
     connection.connect(); 
     // Most servers require you to login before performing other tasks. 
     connection.login("admin2", "123"); 
    } 
    public static void main(String[] args) 
    { 
     // TODO Auto-generated method stub 
     A a= new A(); 
     a.start(); 
    } 
} 
+0

あなたに感謝を –

関連する問題