# Importing java libraries

**URL:** <https://discourse.processing.org/t/importing-java-libraries/18959>\
**Category:** Libraries\
**Created:** [March 23, 2020, 10:30pm UTC](https://discourse.processing.org/t/importing-java-libraries/18959 "2020-03-23T22:30:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pingu](https://avatars.discourse-cdn.com/v4/letter/p/a9a28c/32.png) [@Pingu](https://discourse.processing.org/u/Pingu)\
**Post date:** [March 23, 2020, 10:30pm UTC](https://discourse.processing.org/t/importing-java-libraries/18959/1 "2020-03-23T22:30:43Z")

</div>

I would like to use processing to connect to my Wiimote. To do this I have installed the Wiiremotej jar from their [page](https://github.com/micromu/WiiRemoteJ). 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:

```auto
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:

```auto
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!");
}

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [April 1, 2020, 2:45am UTC](https://discourse.processing.org/t/importing-java-libraries/18959/2 "2020-04-01T02:45:13Z")

</div>

> java.lang.NoClassDefFoundError: javax/bluetooth/BluetoothStateException

Not sure. Have you tried:

```auto
import javax.bluetooth.BluetoothStateException;

```

---

<div class="post-metadata">

**Author:** ![Litotitus](https://avatars.discourse-cdn.com/v4/letter/l/f19dbf/32.png) [@Litotitus](https://discourse.processing.org/u/Litotitus)\
**Post date:** [February 8, 2021, 12:27am UTC](https://discourse.processing.org/t/importing-java-libraries/18959/3 "2021-02-08T00:27:32Z")

</div>

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.
