java - Getting error Error: Could not find or load main class JavaFixHistoryMiner, Don't know how to fix -
everything in code seems fine. not understand why giving me error.
using eclipse ide (juno), i've clicked "run" , got following message on console:
error: not find or load main class javafixhistoryminer
this imported file, added external library
/** * example of how request , process historical rate data java api * * @author rkichenama */ public class javafixhistoryminer implements igenericmessagelistener, istatusmessagelistener { private static final string server = "http://www.fxcorporate.com/hosts.jsp"; private static final string test_currency = "eur/usd"; private fxcmloginproperties login; private igateway gateway; private string currentrequest; private boolean requestcomplete; private arraylist<collateralreport> accounts = new arraylist<collateralreport>(); private hashmap<utcdate, marketdatasnapshot> historicalrates = new hashmap<utcdate, marketdatasnapshot>(); private static printwriter output = new printwriter((outputstream)system.out, true); public printwriter getoutput() { return output; } public void setoutput(printwriter newoutput) { output = newoutput; } /** * creates new javafixhistoryminer credentials configuration file * * @param username * @param password * @param terminal - terminal login into, dependent on type of account, case sensitive * @param server - url, 'http://www.fxcorporate.com/hosts.jsp' * @param file - local file used define configuration */ public javafixhistoryminer(string username, string password, string terminal, string file) { // if file not specified if(file == null) // create local loginproperty this.login = new fxcmloginproperties(username, password, terminal, server); else this.login = new fxcmloginproperties(username, password, terminal, server, file); } /** * creates new javafixhistoryminer credentials , no configuration file * * @param username * @param password * @param terminal - terminal login into, dependent on type of account, case sensitive * @param server - url, 'http://www.fxcorporate.com/hosts.jsp' */ public javafixhistoryminer(string username, string password, string terminal) { // call proper constructor this(username, password, terminal, null); } public javafixhistoryminer(string[] args) { // call proper constructor this(args[0], args[1], args[2], null); } /** * attempt login credentials supplied in constructor, assigning self listeners */ public boolean login() { return this.login(this, this); } /** * attempt login credentials supplied in constructor * * @param genericmessagelistener - listener object trading events * @param statusmessagelistener - listener object status events * * @return true if login successful, false if not */ public boolean login(igenericmessagelistener genericmessagelistener, istatusmessagelistener statusmessagelistener) { try { // if gateway has not been defined if(gateway == null) // assign new gateway created factory gateway = gatewayfactory.creategateway(); // register generic message listener gateway gateway.registergenericmessagelistener(genericmessagelistener); // register status message listener gateway gateway.registerstatusmessagelistener(statusmessagelistener); // if gateway has not been connected if(!gateway.isconnected()) { // attempt login local login properties gateway.login(this.login); } else { // attempt re-login api gateway.relogin(); } // set state of request incomplete requestcomplete = false; // request current trading session status currentrequest = gateway.requesttradingsessionstatus(); // wait until request complete while(!requestcomplete) {} // return process successful return true; } catch(exception e) { e.printstacktrace(); } // if error occurred, return process failed return false; } /** * attempt logout, assuming supplied listeners reference self */ public void logout() { this.logout(this, this); } /** * attempt logout, removing supplied listeners prior disconnection * * @param genericmessagelistener - listener object trading events * @param statusmessagelistener - listener object status events */ public void logout(igenericmessagelistener genericmessagelistener, istatusmessagelistener statusmessagelistener) { // attempt logout of api gateway.logout(); // remove generic message listener, stop listening updates gateway.removegenericmessagelistener(genericmessagelistener); // remove status message listener, stop listening status changes gateway.removestatusmessagelistener(statusmessagelistener); } /** * request refresh of collateral reports under current login */ public void retrieveaccounts() { // if gateway null attempt login if(gateway == null) this.login(); // set state of request incomplete requestcomplete = false; // request refresh of collateral reports currentrequest = gateway.requestaccounts(); // wait until reqports have been processed while(!requestcomplete) {} } /** * send formed order api , wait response. * * @return market order number of placed trade, none if trade did not execute, null on error */ public string sendrequest(itransportable request) { try { // set completion status of requst false requestcomplete = false; // send request message api currentrequest = gateway.sendmessage(request); // wait until api answers on particular request // while(!requestcomplete) {} // if there value return, passed currentresult return currentrequest; } catch(exception e) { e.printstacktrace(); } // if error occured, return no result return null; } /** * implementing istatusmessagelistener capture , process messages sent api * * @param status - status message received api */ @override public void messagearrived(isessionstatus status) { // check status code if(status.getstatuscode() == isessionstatus.statuscode_error || status.getstatuscode() == isessionstatus.statuscode_disconnecting || status.getstatuscode() == isessionstatus.statuscode_connecting || status.getstatuscode() == isessionstatus.statuscode_connected || status.getstatuscode() == isessionstatus.statuscode_critical_error || status.getstatuscode() == isessionstatus.statuscode_expired || status.getstatuscode() == isessionstatus.statuscode_loggingin || status.getstatuscode() == isessionstatus.statuscode_loggedin || status.getstatuscode() == isessionstatus.statuscode_processing || status.getstatuscode() == isessionstatus.statuscode_disconnected) { // display status message output.println("\t\t" + status.getstatusmessage()); } } /** * implementing igenericmessagelistener capture , process messages sent api * * @param message - message received processing api */ @override public void messagearrived(itransportable message) { // decide child function send cast instance of message try { // if instance of collateralreport, process collateral report if(message instanceof collateralreport) messagearrived((collateralreport)message); // if instance of marketdatasnapshot, process historical data if(message instanceof marketdatasnapshot) messagearrived((marketdatasnapshot)message); // if instance of marketdatarequestreject, process historical data request error if(message instanceof marketdatarequestreject) messagearrived((marketdatarequestreject)message); // if message instance of tradingsessionstatus, cast , send child function else if(message instanceof tradingsessionstatus) messagearrived((tradingsessionstatus)message); } catch(exception e) { e.printstacktrace(output); } } /** * separate function handle collateral report requests * * @param cr - message interpreted instance of collateralreport */ public void messagearrived(collateralreport cr) { // if report result of direct request waiting process if(currentrequest.equals(cr.getrequestid()) && !accounts.contains(cr)) { // add trading account account list accounts.add(cr); // set state of request completed if last collateral report // requested requestcomplete = cr.islastrptrequested(); } } /** /** * separate function handle trading session status updates , pull trading instruments * * @param tss - message interpreted tradingsessionstatus instance */ public void messagearrived(tradingsessionstatus tss) { // check see if there request main application session update if(currentrequest.equals(tss.getrequestid())) { // set request complete waiting thread requestcomplete = true; // attempt set historical market data request try { // create new market data request marketdatarequest mdr = new marketdatarequest(); // set subscription type ask snapshot of history mdr.setsubscriptionrequesttype(subscriptionrequesttypefactory.snapshot); // request response formated fxcm style mdr.setresponseformat(ifixdefs.msgtype_fxcmresponse); // set intervale of data candles mdr.setfxcmtiminginterval(fxcmtimingintervalfactory.min15); // set type set data candles mdr.setmdentrytypeset(marketdatarequest.mdentrytypeset_all); // configure start , end dates date = new date(); calendar calendar = (calendar)calendar.getinstance().clone(); calendar.settime(now); calendar.add(calendar.day_of_month, -1); date beforenow = calendar.gettime(); // set dates , times market data request mdr.setfxcmstartdate(new utcdate(beforenow)); mdr.setfxcmstarttime(new utctimeonly(beforenow)); mdr.setfxcmenddate(new utcdate(now)); mdr.setfxcmendtime(new utctimeonly(now)); // set instrument on want historical data mdr.addrelatedsymbol(tss.getsecurity(test_currency)); // send request sendrequest(mdr); } catch(exception e) { e.printstacktrace(); } } } /** * separate function handle rejection of market data historical snapshot * * @param mdrr - message interpreted instance of marketdatarequestreject */ public void messagearrived(marketdatarequestreject mdrr) { // display note consisting of reason request rejected output.println("historical data rejected; " + mdrr.getmdreqrejreason()); // set state of request complete requestcomplete = true; } /** * separate function handle receipt of market data snapshots * * current dealing rates retrieved through same class historical requests. difference * historical requests 'answers' specific request. * * @param mds */ public void messagearrived(marketdatasnapshot mds) { // if market data snapshot part of answer specific request try { if(mds.getrequestid() != null && mds.getrequestid().equals(currentrequest)) { // add snapshot historicalrates table synchronized(historicalrates) { historicalrates.put(mds.getdate(), mds); } // set request complete if continuous flaf @ end requestcomplete = (mds.getfxcmcontinuousflag() == ifixdefs.fxcmcontinuous_end); } } catch (exception e) { // todo auto-generated catch block e.printstacktrace(); } } /** * display historical rates captured */ public void displayhistory() { // give table header output.println("rate 15 minute candle history " + test_currency); // give table column headings output.println("date\t time\t\tobid\tcbid\thbid\tlbid"); // keys historicalrates table sorted list sortedset<utcdate> candle = new treeset<utcdate>(historicalrates.keyset()); // define format dates simpledateformat sdf = new simpledateformat("dd.mm.yyyy hh:mm:ss z"); // make date formatter above convert gmt est sdf.settimezone(timezone.gettimezone("est")); // go through keys of historicalrates table for(int = 0; < candle.size(); i++) { // create single instance of snapshot marketdatasnapshot candledata; synchronized(historicalrates) { candledata = historicalrates.get(candle.toarray()[i]); } // convert key date date candledate = ((utcdate)candle.toarray()[i]).todate(); // print out historicalrate table data output.println( sdf.format(candledate) + "\t" + // date , time formatted , converted est candledata.getbidopen() + "\t" + // open bid candle candledata.getbidclose() + "\t" + // close bid candle candledata.getbidhigh() + "\t" + // high bid candle candledata.getbidlow()); // low bid candle } // repeat table column headings output.println("date\t time\t\tobid\tcbid\thbid\tlbid"); } public static void main(string[] args) { try { // create instance of javafixhistoryminer javafixhistoryminer miner = new javafixhistoryminer("rkichenama", "1311016", "demo"); // login api miner.login(); // retrieve trader accounts ensure login process complete miner.retrieveaccounts(); // display nore history display delayed // partially theatrics, partially ensure rates collected output.println("displaying history in"); // wait ~ 2.5 seconds for(int = 5; > 0; i--) { output.println(i + "..."); thread.sleep(500); } // display collected rates miner.displayhistory(); // log out of api miner.logout(); } catch (exception e) { e.printstacktrace(); } } }
Comments
Post a Comment