How to use smack?

hello @ all.

i cant compile my own exapmle.

the javac show me this errors:

javac Test.java

Test.java:5: cannot find symbol

symbol : class XMPPConnection

location: class smack.jar.Test

XMPPConnection connection = new XMPPConnection(“jabber.org”);

^

Test.java:5: cannot find symbol

symbol : class XMPPConnection

location: class smack.jar.Test

XMPPConnection connection = new XMPPConnection(“jabber.org”);

^

2 errors

how can i import the smack.jar in to my source file? i mean “import **” or package **, that all doesnt work.

help me please!.

Hi,

are you using an IDE to develop your program or an editor like vi?

Did you add smack.jar to your classpath?

LG

i use an editor, how can i adding smack to classpath?

PS: i use linux as OS.

that is my code

public class Test{

public static void main(String[] args){

// Create a connection to the jabber.org server.

XMPPConnection conn1 = new XMPPConnection(“jabber.ru”);

}

}

$bash: env

MANPATH=/usr/local/share/man:/usr/share/man:/usr/share/binutils-data/x86_64-pc-l

/man:/etc/java-config/system-vm/man/

SSH_AGENT_PID=5004

TERM=xterm

SHELL=/bin/bash

WINDOWID=44040224

ANT_HOME=/usr/share/ant-core

XTERM_SHELL=/bin/bash

USER=djung

LIBGL_DRIVERS_PATH=:/usr/lib/dri:/usr/lib64/dri:/usr/lib32/xorg/modules/dri/:/us

PRELINK_PATH_MASK=/usr/lib/gstreamer-0.10:/usr/lib/klibc

GDK_USE_XFT=1

SSH_AUTH_SOCK=/tmp/ssh-uYJDWQ5003/agent.5003

SESSION_MANAGER=local/xen:/tmp/.ICE-unix/5007

PAGER=/usr/bin/less

CONFIG_PROTECT_MASK=/etc/java-config/vms/ /etc/env.d/java/ /etc/gconf /etc/termi

PATH=/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.1.

PWD=/home/djung/zhab

JAVA_HOME=/home/djung/.gentoo/java-config-2/current-user-vm

JAVAC=/home/djung/.gentoo/java-config-2/current-user-vm/bin/javac

EDITOR=/bin/nano

XCURSORS_THEME=Jimmac

XTERM_VERSION=XTerm(215)

JDK_HOME=/home/djung/.gentoo/java-config-2/current-user-vm

SHLVL=3

HOME=/home/djung

LESS=-R -M --shift 5

G_FILENAME_ENCODING=UTF-8

PYTHONPATH=/usr/lib/portage/pym

LOGNAME=djung

CVS_RSH=ssh

GCC_SPECS=

CLASSPATH=.

LESSOPEN=|lesspipe.sh %s

INFOPATH=/usr/share/info:/usr/share/binutils-data/x86_64-pc-linux-gnu/2.16.1/inf

DISPLAY=:0.0

OPENGL_PROFILE=ati

G_BROKEN_FILENAMES=1

CONFIG_PROTECT=/usr/share/X11/xkb

_=/usr/bin/env

OLDPWD=/home/djung

and after javac Test.java

Test.java:4: cannot find symbol

symbol : class XMPPConnection

location: class Test

XMPPConnection conn1 = new XMPPConnection(“jabber.ru”);

^

Test.java:4: cannot find symbol

symbol : class XMPPConnection

location: class Test

XMPPConnection conn1 = new XMPPConnection(“jabber.ru”);

^

2 errors

or so:

javac -classpath /home/djung/zhab/smack.jar Test.java

but the output of javac is equals to the top ^.

import org.jivesoftware.smack.XMPPConnection;

will help a lot to get this compiled.

And you may want to add also smackx.jar and smack-debug.jar to your classpath.

LG

javac -classpath /home/djung/zhab/smack/smackx.jar Test.java

Test.java:6: unreported exception org.jivesoftware.smack.XMPPException; must be caught or declared to be thrown

XMPPConnection conn1 = new XMPPConnection(“jabber.ru”);

^

1 error

import org.jivesoftware.smack.XMPPConnection;

public class Test{

public static void main(String[] args){

// Create a connection to the jabber.org server.

XMPPConnection conn1 = new XMPPConnection(“jabber.ru”);

}

}

what i do wrong?? =(

Hi,

do you want to learn java this way?

LG

try {

con= new XMPPConnection(…);

}catch (XMPPException e) { }

}

javac -classpath /home/djung/zhab/smack/smackx.jar Test.java Test.java:6: cannot find symbol

symbol : class XMPPException

location: class Test

try {XMPPConnection conn1 = new XMPPConnection(“jabber.ru”);}catch (XMPPException e) { }

^

1 error

Hi,

do you really want to learn java this way?

Get an IDE like Eclipse or JDeveloper and it will assist you. In this case you need to import also org.jivesoftware.smack.XMPPException or something like this.

LG

i have netbeans installed, , but i can find any information of adding an package. can you help me?

hi,

If you are using netbeans,

please try to add the class lib under Tools/Library Manager.

and in your java app, under Project, click on Lib, and add library you just add in.

Message was edited by: txloner