Java API Yükleme.2 gündür yapamadım...

Başlatan Mr.Java, 29 Kasım 2013, 00:02:06

Mr.Java

Arkadaşlar merhaba.Java ile usb API'sini ne yaptıysam yükleyemedim.50 takla attım gene yapamadım.En baştan adım adım yazıyorum;

1-) usb4java.org sitesinden library indirdim.Netbeans ile yükledim.(Eclipse de nedense hata verdi... )
2-) Kodumu yazdım derlediğimde sorunsuz derledi.Fakat çalıştır dediğimde ise Exception in thread "main" javax.usb.UsbException: Properties file javax.usb.properties not found. hatası verdi.Sitesinde http://javax-usb.sourceforge.net/faq.html#what_is_properties_file hata ile ilgili dökümanlar var.Burada benim anladığım şudur.Anasayfasında belirtilen http://javax-usb.sourceforge.net/ sitesindeki linux kütüphanesini indirdim.Arşivi açınca içerisinde build.xml dosyası çıktı.Sonra ant kurdum ve dizin içerisinde ant all ile komut attığımda Error: JAVA_HOME is not defined correctly.
  We cannot execute /usr/lib/jvm/jdk1.7.0/bin/java/bin/java hatası verdi.JAVA_HOME ile ilgili sıkıntılar olduğunu belirtti.Ardından konsolda export JAVA_HOME= /usr/lib/jvm/jdk1.7.0/bin/java/bin/java deyip java home klasör yerini gösterdim fakat gene olmadı.Ardından sudo gedit /etc/environment içerisinde JAVA_HOME tanımladım reset attım gene derleyemedim.Sanırım ant ile .so dosyası oluşturup bunu kullanmamız gerekiyor ant ile.

Cevaplarınız ve yorumlarınızı bekliyor,iyi forumlar diliyorum...

Mr.Java

Bugün en baştan JDK,JRE kurdum. usb4java.org sitesinden API'leri indirdim.Şimdi burada;
-İçerisindeki tüm .jar dosyalarını

/usr/lib/jvm/java-7-openjdk-amd64/jre/lib


klasörüne taşıdım.

sudo gedit ~/.bashrc


dosyasına ise ;

export JAVA_HOME='/usr/lib/jvm/java-1.7.0-openjdk-amd64/'
PATH=$JAVA_HOME:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH='/usr/lib/jvm/java-1.7.0-openjdk-amd64/jre/lib'


ekledim.
Terminalden yerlerini göstermesini istediğimde


echo $JAVA_HOME && echo $CLASSPATH && echo $PATH


çıkan sonucumuz

/usr/lib/jvm/java-1.7.0-openjdk-amd64/
/usr/lib/jvm/java-1.7.0-openjdk-amd64/jre/lib
/usr/lib/jvm/java-1.7.0-openjdk-amd64/:/usr/lib/jvm/java-1.7.0-openjdk-amd64//bin:/usr/lib/jvm/java-1.7.0-openjdk-amd64//jre/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/fatih/bin:/usr/lib/jvm/jdk1.7.0/bin


Şimdi netbeans açıyorum ve java ile kodumu yazıyorum derlemede sorun yok fakat run dediğimde javax.usb.properties not fount veriyor.Çıktı aynen şudur.
Alıntı

   
Exception in thread "main" javax.usb.UsbException: Properties file javax.usb.properties not found.
       at javax.usb.UsbHostManager.setupProperties(Unknown Source)
       at javax.usb.UsbHostManager.getProperties(Unknown Source)
       at javax.usb.UsbHostManager.createUsbServices(Unknown Source)
       at javax.usb.UsbHostManager.getUsbServices(Unknown Source)


Ayrıca nette bulduğum usb4java.so dosyasınıda attım jre/lib klasörüne.
Netbeans'a java kütüphanesini
Alıntı Yap/usr/lib/jvm/java-7-openjdk-amd64/jre/lib
klasöründeki jar dosyalarını gösterdim.
Java USB için yazılan kod;

package usb;
import java.util.List;
import javax.usb.*;

public class Usb {

    private static void dump(UsbDevice device) {
        UsbDeviceDescriptor desc = device.getUsbDeviceDescriptor();
        System.out.format("%04x:%04x%n", desc.idVendor() & 0xffff, desc.idProduct() & 0xffff);
        if (device.isUsbHub()) {
            UsbHub hub = (UsbHub) device;
            for (UsbDevice child : (List<UsbDevice>) hub.getAttachedUsbDevices()) {
                dump(child);
            }
        }
    }

    public UsbDevice findDevice(UsbHub hub, short vendorId, short productId) {
        for (UsbDevice device : (List<UsbDevice>) hub.getAttachedUsbDevices()) {
            UsbDeviceDescriptor desc = device.getUsbDeviceDescriptor();
            if (desc.idVendor() == vendorId && desc.idProduct() == productId) {
                return device;
            }
            if (device.isUsbHub()) {
                device = findDevice((UsbHub) device, vendorId, productId);
                if (device != null) {
                    return device;
                }
            }
        }
        return null;
    }

    public static void main(String[] args) throws UsbException {
        UsbServices services = UsbHostManager.getUsbServices();
        UsbHub rootHub = services.getRootUsbHub();
        dump(rootHub);

    }

}

Fakat aşamadım bir türlü şu APIyi sorunsuz kullanmayı.Bu apiyi nasıl kullanacağım sorunsuz ? Arkadaşlar lütfen acil yardım bekliyorum.

Dipnot:Bu arada http://javax-usb.sourceforge.net/ linux için olanı indirdim ve ant ile ant all diye build etmeye çalıştım fakat hata verdi.İçerisine baktığımda ise classpath'te javax.usb.properties'i göstermen lazım falan diyordu.Terminal sonucları


 
  Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-7-openjdk-amd64/lib/tools.jar
    Buildfile: build.xml

    clean:
         [echo] Cleaning everything.
         [exec] rm -f libJavaxUsb.so JavaxUsbKernel.o JavaxUsbLog.o JavaxUsbTopologyUpdater.o JavaxUsbTopologyListener.o JavaxUsbActive.o JavaxUsbDeviceProxy.o JavaxUsbPipeRequest.o JavaxUsbInterfaceRequest.o JavaxUsbControlRequest.o JavaxUsbBulkRequest.o JavaxUsbInterruptRequest.o JavaxUsbIsochronousRequest.o JavaxUsbError.o com_ibm_jusb_os_linux_JavaxUsb.h *.o *.so

    compile:
         [echo] Compiling class files.
        [javac] Compiling 17 source files to /home/fatih/İndirilenler/usb4java-1.0.0/javax-usb-ri-linux/src

    BUILD FAILED
    /home/fatih/İndirilenler/usb4java-1.0.0/javax-usb-ri-linux/build.xml:107: Unable to find a javac compiler;
    com.sun.tools.javac.Main is not on the classpath.
    Perhaps JAVA_HOME does not point to the JDK.
    It is currently set to "/usr/lib/jvm/java-7-openjdk-amd64/jre"

    Total time: 0 seconds


Ayrıca JSR80 API'sini build etme ve yüklemede şöyle not düşünülmüş;
Alıntı Yap*********
* Build *
*********

The ANT tool uses XML buildfiles to create the project.  Run ant in
the toplevel directory to list all available targets.

To build JavaDOC including the API and common RI source as well, set your environment variable
JSR80_LINUX_JDOC_PATH to both the API and common RI src/ directories separated with ":".

****************
* Installation *
****************

Add lib/jsr80_linux.jar to your CLASSPATH.
Add the directory containing javax.usb.properties to your CLASSPATH.
Add the directory containing libJavaxUsb.so to your LD_LIBARRY_PATH or /etc/ld.so.conf file.

This implementation uses the "usbfs" filesystem to access the USB topology.  You will need
permission to access the device nodes in that filesystem in order to use javax.usb.  Specifically
you need read-write access to the nodes /proc/bus/usb/NNN/NNN where NNN is a 0-9 digit.  To
change the permissions of the device nodes, you can remount the filesystem with the option
"devmode=666".  If you have an entry in your /etc/fstab file for usbfs (or usbdevfs) then you
can add the option to that file.  If not, your distribution probably explictly mounts the
filesystem in a startup script, so you may have to re-mount it by hand with the devmode option,
or edit a startup script to remount it with the devmode option.

NOTE that by changing the permissions of this filesystem to 666 you are allowing ANYONE on
your system full access to all of your USB devices.  To improve security you should set the
permissions more restrictive and give read-write access to only a specific user or specific group.