File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Java and USB Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Java and USB" Watch "Java and USB" New topic
Author

Java and USB

eddy johns
Ranch Hand

Joined: Feb 16, 2010
Posts: 67
Hi all,

I need to read a USB device from my java code. Is there any good solution at all?

I looked at jsr80. I installed the jsr80.jar and the jsr80_ri.jar, and I'm trying to run the generic code you find on the net:



I keep getting the following error:




Any ideas?

Thanks,
Eddy
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35249
    
    7
class com.ibm.jusb.os.windows.WindowsUsbServices was not found

Is that class in the classpath?


Android appsImageJ pluginsJava web charts
eddy johns
Ranch Hand

Joined: Feb 16, 2010
Posts: 67
Hi Ulf,

Following your reply I checked my jsr80-windows.jar and it turns out the WindowsUsbServices is in com.mcreations.usb.windows. So I changed my properties file and now I get this error:




I looked on the net and it seems like many people get similar errors with jsr80 and no one was able to go through and get this to work. But I may be missing something. Hopefully I'm missing something.. Any suggestions?

Thanks,
Eddy
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35249
    
    7
If all you did for installation was to add the 2 jar files to your classpath, then yes - something is bound to be missing. Any low-level I/O library will require a native library. You should be able to get that somewhere around here: http://sourceforge.net/apps/trac/libusb-win32/wiki
eddy johns
Ranch Hand

Joined: Feb 16, 2010
Posts: 67
I looked there and got to http://sourceforge.net/projects/libusb-win32/files/ but the package there doesn't include LibusbJava.dll... Ulf, have you been able to make this work?

Thanks,
(The Desperate) Eddy
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35249
    
    7
No; I've never used it. Maybe it's better to get it all in one place anyway; http://javax-usb.cvs.sourceforge.net/viewvc/javax-usb/javax-usb-libusb/lib/ looks promising
eddy johns
Ranch Hand

Joined: Feb 16, 2010
Posts: 67
Thanks Ulf, after much crap of moving dll's around -- using the code from link you gave in the previous message -- it's working for me. The last step was to change the name of usbJava.dll to LibusbJava.dll and install it in C:\Windows\system32. I figured it out only once the runtime complained it can't read from LibusbJava.dll.

http://libusbjava.sourceforge.net/wp/ has the best explanation on how to install all the elements. Once they're installed, http://www.cafeaulait.org/books/javaio2/ioexamples/23/index.html has great examples on how to use the API.

Thanks again,
Eddy
Amol Bhanushali
Greenhorn

Joined: Nov 01, 2011
Posts: 3
eddy johns wrote:Thanks Ulf, after much crap of moving dll's around -- using the code from link you gave in the previous message -- it's working for me. The last step was to change the name of usbJava.dll to LibusbJava.dll and install it in C:\Windows\system32. I figured it out only once the runtime complained it can't read from LibusbJava.dll.

http://libusbjava.sourceforge.net/wp/ has the best explanation on how to install all the elements. Once they're installed, http://www.cafeaulait.org/books/javaio2/ioexamples/23/index.html has great examples on how to use the API.

Thanks again,
Eddy




Hi eddy johns can you give me the sample code for the file transfer i am stuck in that from so many days.. i would be very much thankfull to you.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Welcome to the Ranch, Amol!

Eddy hasn't been active on the Ranch for quite a while, so I don't think he'll be able to give you any sample codes.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Amol Bhanushali
Greenhorn

Joined: Nov 01, 2011
Posts: 3
Rob Spoor wrote:Welcome to the Ranch, Amol!

Eddy hasn't been active on the Ranch for quite a while, so I don't think he'll be able to give you any sample codes.



Hi Rob Spoor,

can you help me on the same topic it is very urgent!!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Please EaseUp. There's no such thing as urgent around here. And no, I cannot help you, as I haven't worked with the combination of Java and USB before.
Amol Bhanushali
Greenhorn

Joined: Nov 01, 2011
Posts: 3
Rob Spoor wrote:Please EaseUp. There's no such thing as urgent around here. And no, I cannot help you, as I haven't worked with the combination of Java and USB before.



Sorry Rob Spoor,

But I am searching this for almost last 1 week and i have downloaded all the library which eddy johns mentioned. and run the code also. Talked with many of my freind, but suddenly today i found my path to the solution on this blog so i thought it might help me to give us right direction for further procedure. we dont want the complete code as we will manage to do so but as we are new to this and there is less help available specially for java with USB so i thought let us try to put some effort here and get the right path to walk on. this is also from past history that we have found many small things working for us from this blog specially for java collections.

hope i satisfied to your comment. as some time communication barrier creates lots diffrence in understanding each ohter.
thanks for the reply. i still hope will get the answers from this blog.
thank you once again
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

There's no problem at all with your request. You have a valid problem, and asking for sample code or directions is just fine. If I could have provided any I would have gladly given it to you.

I also understand that you may need an answer as soon as possible, but the FAQ entry that the EaseUp words link to explains why we prefer that you simply don't mention that.
Steve Thomas
Greenhorn

Joined: Feb 20, 2012
Posts: 1
eddy johns wrote:Thanks Ulf, after much crap of moving dll's around -- using the code from link you gave in the previous message -- it's working for me. The last step was to change the name of usbJava.dll to LibusbJava.dll and install it in C:\Windows\system32. I figured it out only once the runtime complained it can't read from LibusbJava.dll.

http://libusbjava.sourceforge.net/wp/ has the best explanation on how to install all the elements. Once they're installed, http://www.cafeaulait.org/books/javaio2/ioexamples/23/index.html has great examples on how to use the API.

Thanks again,
Eddy


I don't know if you're still interested but I just spent ages on the same quest as you. Finally I found the location of the highly sought after LibusbJava.dll right under my nose:-
http://sourceforge.net/projects/libusbjava/files/libusbjava-snapshots/20080218/

why don't people just label things a bit better?

I have only just found this comment about renaming the usbJava.dll file (although I havn't tried it) but if it worksit would have save me a pile of trouble too.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java and USB
 
Similar Threads
Device Access from Java
error on TreeMap
don't know how to handle different params in a command.
java.rmi.NotBoundException
USB Modem stuck while submitting data