Compile java program on linux with external libraries -
i trying compile java file using smack xmpp libraries. in folder of java file have included libs directory including *.jar files smack when try
javac filename
i output:
smackccsclient.java:6: error: package org.jivesoftware.smack not exist import org.jivesoftware.smack.connectionconfiguration; ^ smackccsclient.java:7: error: package org.jivesoftware.smack.connectionconfiguration not exist import org.jivesoftware.smack.connectionconfiguration.securitymode; ^ smackccsclient.java:8: error: package org.jivesoftware.smack not exist import org.jivesoftware.smack.connectionlistener; ^ smackccsclient.java:9: error: package org.jivesoftware.smack not exist import org.jivesoftware.smack.packetinterceptor; ^ smackccsclient.java:10: error: package org.jivesoftware.smack not exist import org.jivesoftware.smack.packetlistener; ^ smackccsclient.java:11: error: package org.jivesoftware.smack not exist import org.jivesoftware.smack.xmppconnection; ^ smackccsclient.java:12: error: package org.jivesoftware.smack not exist import org.jivesoftware.smack.xmppexception; ^ smackccsclient.java:13: error: package org.jivesoftware.smack.filter not exist import org.jivesoftware.smack.filter.packettypefilter; ^ smackccsclient.java:14: error: package org.jivesoftware.smack.packet not exist import org.jivesoftware.smack.packet.defaultpacketextension; ^ smackccsclient.java:15: error: package org.jivesoftware.smack.packet not exist import org.jivesoftware.smack.packet.message; ^ smackccsclient.java:16: error: package org.jivesoftware.smack.packet not exist import org.jivesoftware.smack.packet.packet; ^ smackccsclient.java:17: error: package org.jivesoftware.smack.packet not exist import org.jivesoftware.smack.packet.packetextension; ^ smackccsclient.java:18: error: package org.jivesoftware.smack.provider not exist import org.jivesoftware.smack.provider.packetextensionprovider; ^ smackccsclient.java:19: error: package org.jivesoftware.smack.provider not exist import org.jivesoftware.smack.provider.providermanager; ^ smackccsclient.java:20: error: package org.jivesoftware.smack.util not exist import org.jivesoftware.smack.util.stringutils; ^ smackccsclient.java:21: error: package org.json.simple not exist import org.json.simple.jsonvalue; ^ smackccsclient.java:22: error: package org.json.simple.parser not exist import org.json.simple.parser.parseexception; ^ smackccsclient.java:23: error: package org.xmlpull.v1 not exist import org.xmlpull.v1.xmlpullparser; ^ smackccsclient.java:52: error: cannot find symbol xmppconnection connection; ^ symbol: class xmppconnection location: class smackccsclient smackccsclient.java:53: error: cannot find symbol connectionconfiguration config; ^ symbol: class connectionconfiguration location: class smackccsclient smackccsclient.java:306: error: cannot find symbol public void connect(string username, string password) throws xmppexception { ^ symbol: class xmppexception location: class smackccsclient smackccsclient.java:58: error: cannot find symbol class gcmpacketextension extends defaultpacketextension { ^ symbol: class defaultpacketextension location: class smackccsclient smackccsclient.java:77: error: cannot find symbol public packet topacket() { ^ symbol: class packet location: class smackccsclient.gcmpacketextension smackccsclient.java:70: error: method not override or implement method supertype @override ^ smackccsclient.java:78: error: cannot find symbol return new message() { ^ symbol: class message location: class smackccsclient.gcmpacketextension smackccsclient.java:117: error: cannot find symbol gcm_namespace, new packetextensionprovider() { ^ symbol: class packetextensionprovider location: class smackccsclient smackccsclient.java:116: error: cannot find symbol providermanager.getinstance().addextensionprovider(gcm_element_name, ^ symbol: variable providermanager location: class smackccsclient smackccsclient.java:145: error: cannot find symbol packet request = new gcmpacketextension(jsonrequest).topacket(); ^ symbol: class packet location: class smackccsclient smackccsclient.java:276: error: cannot find symbol return jsonvalue.tojsonstring(message); ^ symbol: variable jsonvalue location: class smackccsclient smackccsclient.java:294: error: cannot find symbol return jsonvalue.tojsonstring(message); ^ symbol: variable jsonvalue location: class smackccsclient smackccsclient.java:307: error: cannot find symbol config = new connectionconfiguration(gcm_server, gcm_port); ^ symbol: class connectionconfiguration location: class smackccsclient smackccsclient.java:308: error: cannot find symbol config.setsecuritymode(securitymode.enabled); ^ symbol: variable securitymode location: class smackccsclient smackccsclient.java:319: error: cannot find symbol xmppconnection.debug_enabled = true; ^ symbol: variable xmppconnection location: class smackccsclient smackccsclient.java:321: error: cannot find symbol connection = new xmppconnection(config); ^ symbol: class xmppconnection location: class smackccsclient smackccsclient.java:324: error: cannot find symbol connection.addconnectionlistener(new connectionlistener() { ^ symbol: class connectionlistener location: class smackccsclient smackccsclient.java:353: error: cannot find symbol connection.addpacketlistener(new packetlistener() { ^ symbol: class packetlistener location: class smackccsclient smackccsclient.java:397: error: cannot find symbol }, new packettypefilter(message.class)); ^ symbol: class packettypefilter location: class smackccsclient smackccsclient.java:397: error: cannot find symbol }, new packettypefilter(message.class)); ^ symbol: class message location: class smackccsclient smackccsclient.java:400: error: cannot find symbol connection.addpacketinterceptor(new packetinterceptor() { ^ symbol: class packetinterceptor location: class smackccsclient smackccsclient.java:405: error: cannot find symbol }, new packettypefilter(message.class)); ^ symbol: class packettypefilter location: class smackccsclient smackccsclient.java:405: error: cannot find symbol }, new packettypefilter(message.class)); ^ symbol: class message location: class smackccsclient smackccsclient.java:447: error: cannot find symbol } catch (xmppexception e) { ^ symbol: class xmppexception location: class smackccsclient 42 errors
how compile correctly? there command needed smack library?
update:
i have created following folder structure:
root ->bin ->src ->lib
i have tried compiling different javac commands like:
javac -d bin -sourcepath src -cp :lib src/smackccsclient.java
i have tried various variations keep getting same output every time.
update 2:
running command:
javac -d bin -sourcepath src -cp lib/*.jar src/smackccsclient.java
gave following output:
javac: invalid flag: lib/smack-android-4.1.1-javadoc.jar usage: javac <options> <source files> use -help list of possible options
i following different tutorials cannot figure out how correctly.
a correct command (assuming needed .jar
files in lib/
folder, , sources in src/
folder):
javac -d bin -sourcepath src -cp $(find lib -iname *.jar | xargs | tr " " ":") src/smackccsclient.java
the tricky part (within $( )
) building a.jar:b.jar:c.jar
(no spaces, separated :
) jar-files in lib/
folder. attempt using -cp lib/*.jar
failed because there spaces instead of :
separating jar-files, , javac thought second jar-file found java source wanted compile. , complained did not know how compile jar-files.
a simpler version (that relies on there being no sub-directories in lib/
)
javac -d bin -sourcepath src -cp $(echo lib/*.jar | tr " " ":") src/smackccsclient.java
Comments
Post a Comment