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:

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(
        at processing.core.PApplet.handleDraw(
        at processing.awt.PSurfaceAWT$12.callDraw(
        at processing.core.PSurfaceNone$
Caused by: java.lang.ClassNotFoundException: javax.bluetooth.BluetoothStateException
        at java.lang.ClassLoader.loadClass(
        at sun.misc.Launcher$AppClassLoader.loadClass(
        at java.lang.ClassLoader.loadClass(
        ... 4 more

My sketch file:

import wiiremotej.*;

void setup()
  WiiRemote remote = null;

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

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.