How do I run something as simple as TickerDemo.java under BTC-E?
I am new to java and cannot get the code to run.
I am running this:
ubuntu@ip-172-31-28-169:~/XChange/xchange-examples/src/main/java$ javac com/xeiam/xchange/examples/btce/BTCEExamplesUtils.java
And I get:
com/xeiam/xchange/examples/btce/BTCEExamplesUtils.java:24: error: cannot find symbol import com.xeiam.xchange.Exchange; ^ symbol: class Exchange location: package com.xeiam.xchange com/xeiam/xchange/examples/btce/BTCEExamplesUtils.java:25: error: cannot find symbol import com.xeiam.xchange.ExchangeFactory; ^ symbol: class ExchangeFactory location: package com.xeiam.xchange
How do I get started? Thanks!
Tim, this product looks great - I just sent you some bitcoin to help with your bounties.
@mahrens917 Thanks for the BTC! I'll put it to good use.
If you're brand new to Java, you'll need to spend some time learning the basics. You'll need to learn the difference between the commands java and javac and what the classpath is. XChange has a bunch of dependencies and you'll need them to be on the classpath.
Here's the command I've used to test the last 1.10.0 release:
cd ~/workspaces/workspace_xeiam_oss/XeiamReleaseTest/lib
java -cp xchange-examples-1.10.0.jar:xchange-core-1.10.0.jar:xchange-mtgox-1.10.0.jar:slf4j-api-1.7.5.jar:rescu-1.5.0.jar:Java-WebSocket-1.3.0.jar:jackson-databind-2.1.1.jar:jackson-annotations-2.1.1.jar:jackson-core-2.1.1.jar:joda-money-0.9.jar:xchart-2.2.1.jar:jsr311-api-1.1.1.jar com.xeiam.xchange.examples.mtgox.v2.service.marketdata.polling.MtGoxOrderBookChartDemo
It won't work anymore of course since MtGox is dead, but it shows the correct command setup.
You'll also want the latest 2.0.0-SNAPSHOT jars as the 1.10.0 version is quite outdated. You can find them here: https://oss.sonatype.org/content/groups/public/com/xeiam/xchange/
Good luck.
In case anyone else has the same issue as I do here are the steps I did to get this working:
- Install Eclipse
- Install Maven through the Eclipse Marketplace under the Eclipse Help menu
- Open Eclipse
- File -> New -> Project… -> Maven/Maven Project
- Check create simple project. You could use default location or uncheck checkbox and select new location.
- Write something to groupId and artifactId. Also you could fill Name & Description fields. Click finish.
- Open pom.xml file Add next code below
<version/>tag and within<dependencies>:
<dependency>
<groupId>com.xeiam.xchange</groupId>
<artifactId>xchange-core</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.xeiam.xchange</groupId>
<artifactId>xchange-examples</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.xeiam.xchange</groupId>
<artifactId>xchange-bitstamp</artifactId>
<version>2.0.0</version>
</dependency>
- Click save
- Select project - right click and choose Maven -> Update Project… and select Force Update before you hit OK.
- Now under the Maven dependencies folder you could open xchange-example-2.0.0.jar and find examples (for example, in com.xeiam.xchange.examples.bitstamp.marketdata you could see TickerDemo.class. You could look it source or run it (right click on the TickerDemo.class, select Run As -> Java Application).
- You could create your classes inside src/main folder. Copy TickerDemo.class and remove the package line and rename the class the filename of the class file created under src/main/java
@mahrens917 Yes, that's exactly right! I formatted your above comment to display the XML properly. Would it be OK if I added your above instructions to out Wiki to better help others?
Yes, of course, that would be great!
I finally got around to doing putting a guide together: https://github.com/timmolter/XChange/wiki/Getting-Started-with-XChange-for-Noobies