Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Java USB detection

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Java USB detection

    Hello

    Currently, I am trying to use JD2XX class to retrieve a listing of the USB devices on my computer, but I cannot get past a certain point. When I try to run TestingUSB, I get the following error:

    Exception in thread "main" java.lang.UnsatisfiedLinkError: E:\NY\NY eclipse indigo\workspace\jd2xx\JD2XX.dll: Can't find dependent libraries
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at jd2xx.JD2XX.<clinit>(JD2XX.java:506)
    at TestingUSB.main(TestingUSB.java:8)
    I have uploaded a .zip file of my Project, called "The Project". TestingUSB is supposed to do is display a list of USB devices connected to your computer by description.

    Also, I am using Eclipse Indigo.

    Basically, my question is: How do I get Eclipse to recognize the JD2XX.dll file that is in the \src folder for The Project?

    Sorry, I just realized this was put in the wrong forum, can I get a mod to move it please?
    Attached Files Attached Files
    Last edited by wrightm96; October 11th, 2011 at 02:29 PM.


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Java USB detection

    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  3. The Following User Says Thank You to JavaPF For This Useful Post:

    wrightm96 (October 12th, 2011)

  4. #3
    Junior Member
    Join Date
    Oct 2011
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Java USB detection

    Thanks a lot. I got it working! Only problem now is the jd2xx isn't actually getting USB devices. Do you know if jd2xx class gets just USB, or also USB 2.0?

  5. #4
    Junior Member
    Join Date
    Jul 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java USB detection

    Hello friends!

    I got your project.zip for list the Devices usb
    I'm trying get the printer usb but, I have very difficulty ...

    When executed your project, I got Exception like you .
    Exception in thread "main" java.lang.UnsatisfiedLinkError: E:\NY\NY eclipse indigo\workspace\jd2xx\JD2XX.dll: Can't find dependent libraries
    Would you like to help please ?

    What's the dependent library is that ?

    Thks!
    Best Regards

  6. #5
    Member
    Join Date
    Jul 2012
    Posts
    119
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default Re: Java USB detection

    Quote Originally Posted by jhieiy View Post
    Hello friends!

    I got your project.zip for list the Devices usb
    I'm trying get the printer usb but, I have very difficulty ...

    When executed your project, I got Exception like you .


    Would you like to help please ?

    What's the dependent library is that ?

    Thks!
    Best Regards
    You both probably don't truly understand the JAVA environment concept. This concept is simple and easy to forget.
    a) JVM and its library: Here are the bin and lib must be set in your PATH and CLASSPATH
    b) YOUR environment: Your compiled classes must be included in CLASSPATH and your NON-Java codes (e.g. dll) in PATH
    c) the OS environment: The OS conventions (e.g. backslash, pathseperator, etc.)

    Now to your problem: see the following setting
    D:\Test>set CLASSPATH=.\classes;.\classes\jd2xx;c:\program Files\Java\jre6\lib;
     
    D:\Test>javac -g:none -nowarn  -d .\classes  *.java
     
    D:\Test>java -Djava.library.path=.\classes\jd2xx TestingUSB
    Created jd2xx.JD2XX!
    Getting devices!
    Got devices!
    Displayed devices!
     
    D:\Test>
    the 1st line: set the JVM and Your environment CLASSPAT
    the 2nd line: compiling
    the 3rd line: exceute the code
    the rest: outputs....

  7. #6
    Member
    Join Date
    Jul 2012
    Posts
    119
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default Re: Java USB detection

    ...-Djava.library.path=.\classes\jd2xx tells JVM where to look for the requested .dll. This is usefull if you don't want to set PATH=...

Similar Threads

  1. Canny Edge Detection
    By tiny in forum Object Oriented Programming
    Replies: 1
    Last Post: March 6th, 2012, 01:54 PM
  2. Java Pitch Detection and Replacement?
    By Stratgtar565 in forum Java Theory & Questions
    Replies: 1
    Last Post: September 12th, 2011, 03:34 AM
  3. Collision Detection difficulties
    By Uritomi in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 20th, 2011, 10:10 AM
  4. 2D Collision Detection
    By Cuju in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 3rd, 2010, 10:39 AM
  5. How to detect brightest spot among all spots?
    By BharatT in forum Java Theory & Questions
    Replies: 4
    Last Post: February 6th, 2009, 09:12 PM

Tags for this Thread