[Tinyos-help] Java / JavaComm on Fedora Core 2

Vlado Handziski handzisk at tkn.tu-berlin.de
Tue Oct 5 13:18:15 PDT 2004


I suggest using the latest RXTX release (rxtx-2.1-7pre17) that does not 
require the Sun JavaComm. In the sources you can find a script called 
ChangePackage.sh that should be used to change the namespace from gnu to 
javax. 

Vlado

On Tuesday 05 October 2004 21:33, Kim Nico wrote:
> I have found a workaround for using the Java tools on Fedora Core 2.
> This was an issue because the IBM version of Java either didn't
> compile, crashed (SIGSEGV), or in my case locked up my entire system.
> I believe the reason IBM's Java is recommended for Linux (RedHat)
> users is that Sun does not provide a reference implementation for
> JavaComm, the interface for using the serial and/or parallel ports.
> 
> There is a Linux "port" of JavaComm which works with Sun's JVM.
> However, it also had some snags with Fedora Core 2.  After finding the
> relevant helpful web pages and archived email list messages, I'm
> sharing my experience getting as far as I have with using the TinyOS
> Java tools on Fedora Core 2.
> 
> What you need:
> I & II. rpm versions of *both* Java SDK 1.4.1_05 and JDK 1.5.0, available 
from
> the Sun web site. 
> III. tar.gz of Java Comm implementation for Solaris/x86
> IV. rxtx version 2.0-5
> 
> Detailed instructions on getting these and installing them properly are
> below.
> 
> Or, follow directions on
> Java Comm Serial API How-To for Linux:
> http://wass.homelinux.net/howtos/Comm_How-To.shtml
> 
> and in this email message: [Rxtx] rxx and Fedora Core 2
> http://marc.theaimsgroup.com/?l=rxtx&m=108963250816383&w=2
> 
> I. Get the Java SDK 1.4.1_05 from Sun
> 
> Go to
> http://java.sun.com/j2se/1.4.2/download.html
> 
> Don't get distracted by all the options.  Pick 
> J2SE v 1.4.2_05  SDK
> 
> Accept the license agreement, then choose
> RPM in self-extracting file (j2sdk-1_4_2_05-linux-i586-rpm.bin, 33.60 MB)
> 
> When this is downloaded, you need to add execute permissions to it:
> chmod +x j2sdk-1_4_2_05-linux-i586-rpm.bin
> 
> and then execute it:
> ./j2sdk-1_4_2_05-linux-i586-rpm.bin
> 
> It should create
> j2sdk-1_4_2_05-linux-i586.rpm
> in the current directory.
> 
> Change to root and install it:
> su
> <type the root password and hit enter>
> rpm -Uvh j2sdk-1_4_2_05-linux-i586.rpm
> exit
> 
> and you will find it in
> /usr/java/j2sdk1.4.2_05/
> 
> I. Get the Java SDK 1.4.1_05 from Sun
> 
> Go to
> http://java.sun.com/j2se/1.5.0/download.jsp
> 
> Don't get distracted by all the options.  Pick 
> J2SE 5.0 JDK
> 
> Accept the license agreement, then choose
> Linux RPM in self-extracting file  (jdk-1_5_0-linux-i586-rpm.bin, 42.50 MB)
> 
> When this is downloaded, you need to add execute permissions to it:
> chmod +x jdk-1_5_0-linux-i586-rpm.bin
> 
> It should create
> jdk-1_5_0-linux-i586.rpm
> in the current directory.
> 
> Change to root and install it:
> su
> <type the root password and hit enter>
> rpm -Uvh jdk-1_5_0-linux-i586.rpm
> exit
> 
> and you will find it in
> /usr/java/jdk1.5.0/
> 
> III.  Get JavaComm.  
> 
> Go to
> http://java.sun.com/products/javacomm/downloads/index.html
> 
> Select "Download Version 2.0 for Microsoft Windows and Solaris/x86"
> (That's right, there isn't a Linux version.  But we're only using it 
> for its comm.jar file.)
> 
> Accept the license agreement, then choose
> Solaris x86 Platform (javacomm20-x86.tar.Z, 353.46 KB)
> 
> When this is downloaded, you can unpack it:
> tar zxvf javacomm20-x86.tar.Z
> It will create a directory called commapi.
> 
> Change directories into commapi
> cd commapi
> 
> Become root and copy comm.jar into both java installations:
> su
> <type the root password>
> cp comm.jar /usr/java/j2sdk1.4.2_05/jre/lib/ext/.
> cp comm.jar /usr/java/jdk1.5.0/jre/lib/ext/.
> 
> IV.  Get RXTX.
> Go to www.rxtx.org.
> 
> Go to the Download page.  Scroll down below "Latest Binaries" until you
> see the heading "Older versions of RXTX are also available."  Download
> rxtx-2.0-5.tar.gz, which is available as a link on the Download page:
> 
> Date:         Oct 17, 2002
> Formats:      rxtx-2.0-5.tar.gz
> 
> RXTX 2.0 is in Package javax.comm.  If you need package gnu.io please 
download RXTX 2.1 above.
> 
> When you have downloaded it, unpack it:
> tar zxvf rxtx-2.0-5.tar.gz
> It will create a directory rxtx-2.0-5
> 
> Create a file called javax.comm.properties and make it contain this line:
> Driver=gnu.io.RXTXCommDriver
> 
> 
> Become root and copy this file to
> /usr/java/j2sdk1.4.2_05/jre/lib/javax.comm.properties and also to
> /usr/java/jdk1.5.0/jre/lib/javax.comm.properties:
> 
> su
> <type the root password>
> cp 
javax.comm.properties /usr/java/j2sdk1.4.2_05/jre/lib/javax.comm.properties
> cp javax.comm.properties /usr/java/jdk1.5.0/jre/lib/javax.comm.properties
> exit
> 
> Add the 1.4.2 java to your path (these instructions are for tcsh; adapt for
> your shell)
> setenv PATH /usr/java/j2sdk1.4.2_05/bin:${PATH}
> rehash
> 
> Verify:
> which java
> should give /usr/java/j2sdk1.4.2_05/bin/java
> 
> Build the RXTX libraries.  Change directories into rxtx-2.0-5.
> cd rxtx-2.0-5
> ./configure
> make
> su
> <type the root password>
> make install
> exit
> 
> Some of these steps may take a while.  When it is finished, you will
> have built rxtx under Java 1.4.2_05.  
> 
> Copy the rxtx jar file from 1.4.2 to 1.5:
> 
cp /usr/java/j2sdk1.4.2_05/jre/lib/ext/jcl.jar /usr/java/jdk1.5.0/jre/lib/ext/.
> 
> Copy the rxtx library files from 1.4.2 to 1.5:
> 
cp /usr/java/j2sdk1.4.2_05/jre/lib/i386/librxtx*.la /usr/java/jdk1.5.0/jre/lib/i386/.
> 
cp /usr/java/j2sdk1.4.2_05/jre/lib/i386/librxtx*-2.0.5.so /usr/java/jdk1.5.0/jre/lib/i386/.
> 
> Make the necessary soft links:
> cd /usr/java/jdk1.5.0/jre/lib/i386
> ln -s librxtxParallel-2.0.5.so librxtxParallel.so
> ln -s librxtxSerial-2.0.5.so librxtxSerial.so
> 
> Change your Java version back to 1.5.0:
> setenv PATH /usr/java/jdk1.5.0/bin:${PATH}
> rehash
> 
> Verify:
> which java
> should give /usr/java/jdk1.5.0/bin/java
> 
> Verify that javacomm is working by going back to commapi:
> 
> cd <wherever you unpacked commapi>/commapi/samples/BlackBox
> java -classpath BlackBox.jar:${CLASSPATH} BlackBox
> 
> It should launch a Java app with a UI.
> 
> >From now on, never use Java 1.4.2_05.  Always use Java 1.5.0.  In fact, you
> can even uninstall 1.4.2_05.
> 
> Now, go to your tinyos Java tools directory:
> cd /opt/tinyos-1.x/tools/java
> 
> Edit the Makefile.include file to change the following lines:
> # general rule for java files
> %.class: %.java
> 	$(JAVAC) $<
> 
> to be:
> # general rule for java files
> %.class: %.java
> 	$(JAVAC) -source 1.4 $<
> 
> Now build (or rebuild) all of your classes:
> make clean
> make
> 
> You will get 5 warnings relating to bug:
> 
http://sourceforge.net/tracker/index.php?func=detail&aid=1040869&group_id=28656&atid=393934
> and several warnings relating to bug:
> 
http://sourceforge.net/tracker/index.php?func=detail&aid=1040856&group_id=28656&atid=393934
> 
> This is okay.  
> 
> Install the getenv library.  This really has nothing to do with getting
> javacomm running, but it needs to be done anyway.
> 
> cd /opt/tinyos-1.x/tools/java/jni
> install libgetenv.so /usr/java/jdk1.5.0/jre/lib/i386/
> 
> Now everything should be okay with javacomm.  As of this writing, I still
> have problems with 
> 
> [kim at gold java]$ java net.tinyos.tools.Listen
> Built a Packet source for unknown
> Could not find a platform specific version of TOSMsg
> java.lang.ClassNotFoundException: net.tinyos.message.unknown.TOSMsg
> java.lang.ClassNotFoundException: net.tinyos.message.unknown.TOSMsg
>         at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
>         at java.lang.Class.forName0(Native Method)
>         at java.lang.Class.forName(Class.java:164)
>         at 
net.tinyos.message.MessageFactory.instantiateTOSMsg(MessageFactory.java:118)
>         at 
net.tinyos.message.MessageFactory.createTOSMsg(MessageFactory.java:44)
>         at net.tinyos.packet.AbstractSource.open(AbstractSource.java:81)
>         at net.tinyos.tools.Listen.main(Listen.java:54)
> Exception in thread "main" java.lang.NullPointerException
>         at net.tinyos.packet.AbstractSource.open(AbstractSource.java:82)
>         at net.tinyos.tools.Listen.main(Listen.java:54)
> 
> but since everyone else seems to have this problem as well, I figure I've
> at least made progress.
> 
> Best of luck,
> 
> Kim Nico
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help at Millennium.Berkeley.EDU
> http://mail.Millennium.Berkeley.EDU/mailman/listinfo/tinyos-help
> 
> 



More information about the Tinyos-help mailing list