Importing java libraries

I would like to use processing to connect to my Wiimote. To do this I have installed the Wiiremotej jar from their page. On their page they mention that the library has a dependency, it needs a bluetooth library to manage the protocol, from what I understood. I thus downloaded the bluecove jar. Now the issue is that this should work if I were to compile with java, but in processing I am unsure of where to place these jars. Here is what I have:

I have placed the jars into the directory code of the sketch as to be able to use them:
/home/user/Documents/Other/wiitestprocessing/sketch_200323b/code/bluecove-gpl-2.1.0.jar
/home/user/Documents/Other/wiitestprocessing/sketch_200323b/code/WiiRemoteJ.jar

But when launching a test program, I get this error, which suggests that the WiiRemoteJ.jar is unable to find the bluecove library:

java.lang.NoClassDefFoundError: javax/bluetooth/BluetoothStateException
        at sketch_200323b.setup(sketch_200323b.java:35)
        at processing.core.PApplet.handleDraw(PApplet.java:2432)
        at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1547)
        at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:313)
Caused by: java.lang.ClassNotFoundException: javax.bluetooth.BluetoothStateException
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 4 more
Finished.

My sketch file:

import wiiremotej.*;
import com.intel.bluetooth.*;

 
void setup()
{
  WiiRemote remote = null;

  while (remote == null) {
      try {
          remote = WiiRemoteJ.findRemote();
      }
      catch(Exception e) {
          remote = null;
          e.printStackTrace();
          println("Failed to connect remote. Trying again.");
      }
  }
  println("Success!");
}

1 Like

java.lang.NoClassDefFoundError: javax/bluetooth/BluetoothStateException

Not sure. Have you tried:

import javax.bluetooth.BluetoothStateException;

Did you find a solution to this? I am trying to run a wiimote as well. I found a library called wrj4P5 but it wasn’t updated since 2010 and also gives me errors:

NoSuchMethodError: You may be using a library that’s incompatible with this version of Processing.