Exception when run the code collect tweets in java -
Exception when run the code collect tweets in java -
this question has reply here:
java.lang.noclassdeffounderror main (wrong name : com/leslie/quiz/main) 1 replyi used next code collect tweets. when compile there no error. when compile programme shows exceptions.
package com.crowley.simplestream; import twitter4j.filterquery; import twitter4j.status; import twitter4j.statusdeletionnotice; import twitter4j.statuslistener; import twitter4j.twitterstream; import twitter4j.twitterstreamfactory; import twitter4j.user; import twitter4j.conf.configurationbuilder; import twitter4j.stallwarning; public class simplestream { public static void main(string[] args) { configurationbuilder cb = new configurationbuilder(); cb.setdebugenabled(true); cb.setoauthconsumerkey("*********************"); cb.setoauthconsumersecret("*******************"); cb.setoauthaccesstoken("********************"); cb.setoauthaccesstokensecret("*********************"); twitterstream twitterstream = new twitterstreamfactory(cb.build()).getinstance(); statuslistener listener = new statuslistener() { @override public void onexception(exception arg0) { // todo auto-generated method stub } @override public void ondeletionnotice(statusdeletionnotice arg0) { // todo auto-generated method stub } @override public void onscrubgeo(long arg0, long arg1) { // todo auto-generated method stub } @override public void onstatus(status status) { user user = status.getuser(); // gets username string username = status.getuser().getscreenname(); system.out.println(username); string profilelocation = user.getlocation(); system.out.println(profilelocation); long tweetid = status.getid(); system.out.println(tweetid); string content = status.gettext(); system.out.println(content +"\n"); } @override public void ontracklimitationnotice(int arg0) { // todo auto-generated method stub } @override public void onstallwarning(stallwarning warning){ } }; filterquery fq = new filterquery(); string keywords[] = {"ireland"}; fq.track(keywords); twitterstream.addlistener(listener); twitterstream.filter(fq); } }
the exception getting when run programme follows.
exception in thread "main" java.lang.noclassdeffounderror: simplestream (wrong name: com/crowley/simplestream/simplestream) @ java.lang.classloader.defineclass1(native method) @ java.lang.classloader.defineclass(classloader.java:791) @ java.security.secureclassloader.defineclass(secureclassloader.java:142) @ java.net.urlclassloader.defineclass(urlclassloader.java:449) @ java.net.urlclassloader.access$100(urlclassloader.java:71) @ java.net.urlclassloader$1.run(urlclassloader.java:361) @ java.net.urlclassloader$1.run(urlclassloader.java:355) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:354) @ java.lang.classloader.loadclass(classloader.java:423) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:308) @ java.lang.classloader.loadclass(classloader.java:356) @ sun.launcher.launcherhelper.checkandloadmain(launcherhelper.java:472)
i used jwitter4j. not contains packages classloader.java. can do? please help me.
how project set up? compiling , running command line or in ide? when have class named simplestream
package com.crowley.simplestream;
statement @ top, com.crowley.simplestream.simplestream
qualified name of class. javac
compiler emit .class
file in current directory default, expects class found in com/crowley/simplestream/simplestream
when run it.
normally maintain source com.crowley.simplestream.simplestream
in file com/crowley/simplestream/simplestream.java
in project, typically underneath src
or src/main/java
directory, , ide (such eclipse or idea) build source files in directory parallel output directory construction .class
files. sounds may building command line, of course of study can do, must take business relationship qualified name of class , java expects find it.
for example, set source appropriate directory , type total path when invoking javac
, or utilize -d
switch javac
tell set .class
file, , utilize qualified name of class when running it:
java com.crowley.simplestream.simplestream
java
Comments
Post a Comment