Bitcoin Forum
April 25, 2024, 10:36:13 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: BitcoinJ Simple Error. java.lang.NoClassDefFoundError  (Read 2842 times)
Anonymous
Guest

December 13, 2011, 10:15:24 PM
Last edit: December 13, 2011, 10:32:43 PM by macintosh264
 #1



Okay. When running my app that uses the bitcoinj jar file, I run into the following error:
Code:
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
Code:
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
Code:
BitcoinHandler bh = new BitcoinHandler();
bh.testnet = true;
bh.openWallet("wallet");

And one last thing
Code:
File walletFile = FileLocationManager.bitcoinFile(walletName, "wallet");
Is
Code:
return new File("data/bitcoin/" + name + "." + extension);

Thanks,
macintosh264
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
ovidiusoft
Sr. Member
****
Offline Offline

Activity: 252
Merit: 250


View Profile
December 13, 2011, 10:26:43 PM
 #2

You are missing this: http://www.slf4j.org/ . The dependency is documented on the BitcoinJ wiki here: https://code.google.com/p/bitcoinj/wiki/GettingStarted .
Anonymous
Guest

December 13, 2011, 10:29:18 PM
 #3

You are missing this: http://www.slf4j.org/ . The dependency is documented on the BitcoinJ wiki here: https://code.google.com/p/bitcoinj/wiki/GettingStarted .
Thanks! (I didn't even see the wiki  Grin)
What's your address.
Anonymous
Guest

December 13, 2011, 10:30:56 PM
 #4

You are missing this: http://www.slf4j.org/ . The dependency is documented on the BitcoinJ wiki here: https://code.google.com/p/bitcoinj/wiki/GettingStarted .
How do I add this to my eclipse project.
ovidiusoft
Sr. Member
****
Offline Offline

Activity: 252
Merit: 250


View Profile
December 13, 2011, 10:34:35 PM
 #5

PM'ed my address. I am sorry, I don't know Eclipse that well, I think there is a Maven plugin for it, but not much more.
ovidiusoft
Sr. Member
****
Offline Offline

Activity: 252
Merit: 250


View Profile
December 13, 2011, 10:36:46 PM
 #6

I have received the bounty from OP. Thank you!
Anonymous
Guest

December 13, 2011, 10:42:01 PM
 #7

Okay, now one more problem.

org.bouncycastle.util.encoders.Hex is missing. Where do I get that?
ovidiusoft
Sr. Member
****
Offline Offline

Activity: 252
Merit: 250


View Profile
December 13, 2011, 10:52:56 PM
 #8

I think it's here: http://www.bouncycastle.org/ . But you should probably use Maven to install any other dependencies.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!