jeudi 1 janvier 2015

Trouble getting java file to run


I'm a beginner to Java Programming and I'm having a little trouble getting this file to run. I'm pretty sure the main problem lies in the "import" statement at the top. ` // MotorTest.java // Andrew Davison, ad@fivedots.coe.psu.ac.th, October 2011


/* Class for opening and closing the Kinect Sensor's motor USB info from http://ift.tt/13ZoMGw */


import java.io.; import ch.ntb.usb.;


public class MotorTest { private static final short VENDOR_ID = (short)0x045e; private static final short PRODUCT_ID = (short)0x02b0; // the IDs were obtained by looking at the kinect motor using USBDeview


public static void main(String[] args) {



// find the device using the vendor and product IDs
Device dev = USB.getDevice(VENDOR_ID, PRODUCT_ID);
if (dev == null) {
System.out.println("Device not found");
System.exit(1);
}

System.out.println("Opening device");
try {
dev.open(1, 0, -1);
// open device with configuration 1, interface 0 and no alt interface
System.out.println("Opened device");
}
catch (USBException e) {
System.out.println(e);
System.exit(1);
}

System.out.println("Closing device");
try {
if (dev != null)
dev.close();
}
catch (USBException e) {
System.out.println(e);
}


} // end of main()


} // end of MotorTest class`


When I try to run the program, I get this:


MotorTest.java:10: error: package ch.ntb.usb does not exist import ch.ntb.usb.*; ^ MotorTest.java:24: error: cannot find symbol Device dev = USB.getDevice(VENDOR_ID, PRODUCT_ID); ^ symbol: class Device location: class MotorTest MotorTest.java:24: error: cannot find symbol Device dev = USB.getDevice(VENDOR_ID, PRODUCT_ID); ^ symbol: variable USB location: class MotorTest MotorTest.java:36: error: cannot find symbol catch (USBException e) { ^ symbol: class USBException location: class MotorTest MotorTest.java:46: error: cannot find symbol catch (USBException e) { ^ symbol: class USBException location: class MotorTest


The ch.ntb.usb is a jar file. Am I not connecting that file to the program in the right way? Any input is appreciated!





Aucun commentaire:

Enregistrer un commentaire