Question

java.lang.NoClassDefFoundError: com/mlawrie/yajtl/TUIOEvent
  at java.lang.Class.getDeclaredMethods0(Native Method)
  at java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
  at java.lang.Class.getMethod0(Class.java:2774)
  at java.lang.Class.getMethod(Class.java:1663)
  at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
  at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: com.mlawrie.yajtl.TUIOEvent
  at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
  ... 6 more
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)

I am trying to use the TUIO library for multitouch for java in my application. I( am using netbeans so i added the JAR files as Library files in Project Manager. I dont know why i am getting the above error. The Library is here

And my code is

package multitouch1;

import java.net.SocketException;
import com.mlawrie.yajtl.TUIOCursor;
import com.mlawrie.yajtl.TUIOEvent;
import com.mlawrie.yajtl.TUIOReceiver;



class Abc implements TUIOEvent
{
    @Override
            public void moveCursorEvent(TUIOCursor c) {
                System.out.println("Move cursor: " + c);
            }

            @Override
            public void newCursorEvent(TUIOCursor c) {
                System.out.println("New cursor: " + c);
            }

            @Override
            public void removeCursorEvent(TUIOCursor c) {
                System.out.println("Remove cursor: " + c);
            }
}
public class MultiTouch1 {

    /**
     * @param args the command line arguments
     * @throws java.net.SocketException
     * @throws java.lang.InterruptedException
     */
    public static void main(String args[]) throws SocketException, InterruptedException {
        TUIOReceiver tuio = new TUIOReceiver(800,600);

        TUIOEvent myEventHandler = new Abc();

        tuio.setHandler(myEventHandler);

        while (true) {
            //Do some stuff
            Thread.sleep(1000);
                        System.out.println("HEY123");
        }
    }

}

I just started it but it aint working from the start.

Edit::

Do i need the source files(.java) for including it as library? I added the main .java files in the classpath, and this error is now gone. But a library which is used by this library, i.e I am using YAJTL and it uses JavaOSC. Now i have included the JavaOSC Jar file. When i downloaded the JavaOSC files from github, it seems that it might have updated and certain classes arent there, and the packaging is done differently. The error i get now is

Exception in thread "main" java.lang.NoClassDefFoundError: com/illposed/osc/OSCListener
    at multitouch1.MultiTouch1.main(MultiTouch1.java:41)
Caused by: java.lang.ClassNotFoundException: com.illposed.osc.OSCListener
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 1 more
Java Result: 1
Was it helpful?

Solution

for this error "java.lang.NoClassDefFoundError: com/mlawrie/yajtl/TUIOEvent" create new package com in your project and copy com package from the downloaded github folder(find this package inside src folder) and then replace your com package with this com package.

for the next error "java.lang.NoClassDefFoundError: com/illposed/osc/OSCListener" you to download javaosc.jar and set your classpath.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top