Thursday, April 24, 2008

javax usb under Ubuntu 7.10


I have tried to build javaxusb from the CVS source under Ubuntu 7.10. I can
build javax-usb and java-usb-ri without a problem with the Java 6.0 package
included in Ubuntu. But I could not build the package javax-usb-ri-linux.

mcuee@ubuntu710:~/Desktop/build/javaxusb
/javax-usb-ri-linux$ ant jars
Buildfile: build.xml

compile:
[echo] Compiling class files.
[echo] Compiling JNI library.
[javah] Error: A required super class
com.ibm.jusb.os.AbstractUsbServices could not be found.

BUILD FAILED
/home/mcuee/Desktop/build/javaxusb/javax-usb-ri-linux/build.xml:114:
compilation failed

Total time: 1 second

Luckily, Google found this and it works for me.
http://www.mail-archive.com/javax-usb-devel@lists.sourceforge.net/msg00101.html

mcuee@ubuntu710:~/Desktop/build/javaxusb/javax-usb-ri-linux$
javah -d jni -classpath src:$CLASSPATH com.ibm.jusb.os.linux.JavaxUsb
(This will produce the file com_ibm_jusb_os_linux_JavaxUsb.h in the jni directory)
mcuee@ubuntu710:~/Desktop/build/javaxusb/javax-usb-ri-linux$ cd jni/
mcuee@ubuntu710:~/Desktop/build/javaxusb/javax-usb-ri-linux/jni$
export JAVA_HOME=/usr/lib/jvm/java-6-sun
mcuee@ubuntu710:~/Desktop/build/javaxusb/javax-usb-ri-linux/jni$ make all
(This will create the file libJavaxUsb.so)
mcuee@ubuntu710:~/Desktop/build/javaxusb/javax-usb-ri-linux/jni$
mcuee@ubuntu710:~/Desktop/build/javaxusb/javax-usb-ri-linux/jni$ cd ..
mcuee@ubuntu710:~/Desktop/build/javaxusb/javax-usb-ri-linux$ gedit build.xml
Remove the following part.
.JavaxUsb">
destdir="${jsr80.linux.jni.src.dir}"
verbose="${jsr80.linux.verbose}"
classpath="${java.class.path}:${jsr80.linux.src.dir}"/>

}" failonerror="yes">
.library}"/>

mcuee@ubuntu710:~/Desktop/build/javaxusb/javax-usb-ri-linux$ ant jars
Buildfile: build.xml

compile:
[echo] Compiling class files.
[echo] Compiling JNI library.

jars:
[echo] Creating JAR files.
[copy] Copying 1 file to
/home/mcuee/Desktop/build/javaxusb/javax-usb-ri-linux/lib

BUILD SUCCESSFUL
Total time: 0 seconds

After this, I can build the examples and they seem to run fine.


5 comments:

Anonymous said...

Thanks Xiaofan,
This post helped me compile all the JavaxUsb jars. In particular, adding JAVA_HOME envar.

A suggestion:
it might not be obvious to some, but clarify the section of the build.xml to comment out. its actually both entire clauses as follows(all opening html brackets removed):
javah
class="com.ibm.jusb.os.linux.JavaxUsb"
destdir="${jsr80.linux.jni.src.dir}" verbose="${jsr80.linux.verbose}"
classpath="${java.class.path}:${jsr80.linux.src.dir}"/>

exec executable="make" dir="${jsr80.linux.jni.src.dir}" failonerror="yes">
arg line="${jsr80.linux.jni.library}"/>
/exec>"

Anyway, thanks again for the post!

Timothy Aanerud said...

I think the reason the JNI javah stuff fails to build is because ant-optional hasn't been installed.

I found that after installing ant-optional with this command:

sudo apt-get install ant-optional

The jni stuff built.

Harry said...

Hi,

I'm trying to install FSUSB into Ubuntu 9.10 so I can use the bootloader to work with me PIC18F4550 and I am having great difficulties. Searching on google doesn't help and the link to the mircochip forum is dead.

I was wondering if you can help me.

Thanks.

Xiaofan said...

Hello Harry, please post the comment to the correct post. Blogspot makes it difficult to find the comments.

The link is still valid.
http://www.internetking.org/fsusb/

More discussions here:
http://www.microchip.com/forums/tm.aspx?m=106426

I also uploaded the file to the above forum thread,

rike said...

root@Tenorio-LINUX:/home/tenorio/usb/javax-usb-ri-linux/jni# make all
gcc -I/usr/java/jdk.1.6.0_33/include -I/usr/java/jdk.1.6.0_33/include/linux -Wall -fPIC -c JavaxUsbKernel.c
In file included from JavaxUsb.h:14,
from JavaxUsbKernel.c:11:
com_ibm_jusb_os_linux_JavaxUsb.h:2: fatal error: jni.h: Arquivo ou diretório não encontrado
compilation terminated.
make: ** [JavaxUsbKernel.o] Erro 1