Okay. When running my app that uses the bitcoinj jar file, I run into the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.google.bitcoin.core.Wallet.<clinit>(Wallet.java:37)
at com.macintosh264.bitcoinproc.BitcoinHandler.openWallet(BitcoinHandler.java:11)
at com.macintosh264.bitcoinproc.Application.loadBitcoin(Application.java:40)
at com.macintosh264.bitcoinproc.Application.launch(Application.java:23)
at com.macintosh264.bitcoinproc.Application.applicationLoop(Application.java:10)
at com.macintosh264.bitcoinproc.BPEMain.main(BPEMain.java:12)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 6 more
And the code I have is this
package com.macintosh264.bitcoinproc;
import java.io.*;
import com.google.bitcoin.core.Wallet;
import com.google.bitcoin.core.*;
public class BitcoinHandler {
public boolean testnet = false;
public void openWallet(String walletName) {
Wallet wallet;
File walletFile = FileLocationManager.bitcoinFile(walletName, "wallet");
try {
wallet = Wallet.loadFromFile(walletFile);
} catch (IOException e) {
wallet = new Wallet(this.getParams());
wallet.keychain.add(new ECKey());
try {
wallet.saveToFile(walletFile);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
private NetworkParameters getParams() {
return this.testnet ? NetworkParameters.testNet() : NetworkParameters.prodNet();
}
}
And it is called by this
BitcoinHandler bh = new BitcoinHandler();
bh.testnet = true;
bh.openWallet("wallet");
And one last thing
File walletFile = FileLocationManager.bitcoinFile(walletName, "wallet");
Is
return new File("data/bitcoin/" + name + "." + extension);
Thanks,
macintosh264