rhinonowbot

Javax.comm For Mac

UPDATE: This library works with Mac OS X 10.6 Snow Leopard. In order to access a serial port in Java, you need the compiled for your specific hardware. Java uses the (JNI) to bridge between your platform-independent application code and the hardware-specific serial port drivers. If you’ve tried this on an Intel Mac (perhaps to play with a ), you may be disappointed, since software keeps shipping from people that is either PowerPC only or isn’t compiled for 64-bit Intel. You’ve probably seen the UnsatisfiedLinkError message.

Javax.comm For Macbook Pro

Here you’ll find a file with support for both 32- and 64-bit PPC and Intel architectures, fitting the bill perfectly for both Java 5 and Java 6 on the Mac. $ file librxtxSerial.jnilib librxtxSerial.jnilib: Mach-O universal binary with 4 architectures librxtxSerial.jnilib (for architecture x8664): Mach-O 64-bit bundle x8664 librxtxSerial.jnilib (for architecture i386): Mach-O bundle i386 librxtxSerial.jnilib (for architecture ppc7400): Mach-O bundle ppc librxtxSerial.jnilib (for architecture ppc64): Mach-O 64-bit bundle ppc64 The Need for the RXTX Library Java’s “write once, run many” theory of operation works because the Java Virtual Machine (JVM), which must be made for each platform, abstracts away the underlying hardware.

As a programmer you can draw circles, label buttons, and even play multimedia without specific knowledge of the host operating system. A computer’s serial ports can be abstracted away in the same way, but the standard JVM does not provide a mechanism for this.

Sun decided (reasonably, though regrettably, I think) that the serial port would not be a required component for a JVM, and so there are no built-in classes for working with serial ports. Sun experimented, for a period of time, with a that would be a sort of plugin for working with things like serial ports (and parallel ports!), but the project and its javax.comm package died.

Thanks to the team at, we now have a gnu.io package modeled after Sun’s javax.comm package that is maintained and works. Why Doesn’t It Work for You? If you’re reading this, it might be because you can’t get it to work on your Mac. Probably you have an Intel Mac and are using Java 6 or later which requires a 64-bit Intel processor. Perhaps you’ve seen error messages that say thinks like UnsatisfiedLinkError and so forth.

Software talking to the serial port must communicate with the host operating system, and so the underlying native library must be compiled per-platform. Presumably your librxtxSerial.jnilib file is not compiled for your platform.

Here’s how to find out. Open the Terminal, navigate to the folder with a librxtxSerial.jnilib file, and use the file command. You’ll probably see this: $ cd /Users/rob/SunSPOT/sdk/lib $ file librxtxSerial.jnilib librxtxSerial.jnilib: Mach-O universal binary with 2 architectures librxtxSerial.jnilib (for architecture i386): Mach-O bundle i386 librxtxSerial.jnilib (for architecture ppc7400): Mach-O bundle ppc If you’re running Java 5 (which comes in 32- and 64-bit flavors on the Mac) you’re OK, but if you’re running Java 6, which is 64-bit Intel only, it won’t work. A Library with the Right Architectures No problem; all you have to do is re-compile RXTX from sources for your platform, right? I can’t even remember all the contortions I went through before I finally got it compiled.

You’re welcome to follow the various instructions online for compiling it yourself, but it gave me a lot of grief, so I’m placing a copy on this site (if you trust me not to insert nefarious code). I finally had to patch SerialImpl.c and SerialImpl.h (manually) based on the. At the end of the day, we have a file that has 32- and 64-bit PPC and Intel architectures. Find all instances of librxtxSerial.jnilib on your Mac and replace them with the one you downloaded from here (or compiled yourself).

Try the command locate librxtxSerial.jnilib in the Terminal to find extra copies hidden in various Java applications. Hi, I’m an user of rxtx library, I’m trying to compile the rxtx library for mac osx as you say in your web, but I can’t get the same result as you. I can’t compile for ppc64. If I put only -arch i386, -arch ppc, -arch x8664 it doesn’t not compile for ppc64, If I try to compile with -arch ppc64 the compilation makes error Furthermore, my compilation doesn’t work with x8664 with java6. Your file works fine, but I want this file without lock files, this is why I want to compile a new file I hope you can help me Regards. I have downloaded your modified librxtxSerial.jnilib on my 10.6.8 Snow Leopard machine.

But I still get the following problem. CommPortIdentifier:static initialization WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.1-7 Exception in thread “main” java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1758) at java.lang.Runtime.loadLibrary0(Runtime.java:823) at java.lang.System.loadLibrary(System.java:1045) at hts.HTSUI.(HTSUI.java:689) Experimental: JNIOnLoad called. Please bear in mind that my Java skills are quite primitive. Thanks a lot for your great work! It helped me a lot. I tested everything the last maybe even more then 7 days. This knowhow i would like to share, just in case somebody else has the same problems.

The Version from Robert Harder is 2.1-7. With this Version you have to build a var/lock directory with the right permissions.

The problem is that from Mac OS 10.5 this directory isn’t installed. The problem is also that the error message is portinuse-exception.

Even the port is not in use. Just the directory is missing. You can loose a lot of time to find the solution this way. RXTXcomm.jar Version 2.2 doesn’t need this var/lock-directory. I tested really almost all possibilities from Cloudhopper to jlog and so far.

There are always some disadvantages. Cloudhopper for example doesn’t support Mac. If you do it like I write her, you can save a lot of time. It works for all OS.

Download rxtx-2.2pre2-bins.zip. Take RXTXcomm.jar and put it to Java/lib/ext on Windows or Java/Extensions on Mac.

For Windows and Linux take the 32 or 64 Bit version of rxtxserial.dll or librxtxserial.so. For Mac OS 10.5 and lower take librxtxserial.jnilib. In Windows put rxtxserial.dll to Java/bin/. On Mac put it to Library/Java/Extensions. There is no librxtxserial,jnilib for 64-bit Mac. OS 10.6 and higher are always 64-bit. The right file you find here: Download librxtxSerial64.jnilib.

RXTXcomm.jar won’t find librxtxSerial64. You have to rename it to librxtxSerial.jnilib. Put it to Library/Java/Extensions.

Like this everything works without creating a var/lock-directory and troubleshooting around the wrong Error Message portinuse-Exception. Anyway it’s better to have Version 2.2 instead of 2.1-7 if there are not any other issues.

I didn’t find any so far. 2 hints at the end. On Mac with Version 2.1-7 and 2.2 the program crashed at serialPort.Close. It took me a hell of time until i found out that there must be a serialPort.removeEventListener; before serialPort.Close; even I didn’t open AddEventListener. This must be a bug. Just put serialPort.removeEventListener; and everything works fine. The second hint: I use usb to serial adapter to open a cashdrawer.

The first time when i was writing out the Esc-String it was working. But then nothing was writing out any more. But the program finished successfully. Without any error.

Javax.comm For Mac Pro

Very strange. I found out when i write out twice or more times outputStream.write(messageString.getBytes); then everything worked fine. It was doing the first write and also the second. But when i wrote just one time outputStream.write(messageString.getBytes); it was just working the first time. Then i could klick a 100 times it didnt’t work any more. I do it now like this: outputStream.write(messageString.getBytes); var justwriteanything = “rrrr”; outputStream.write( justwriteanything.getBytes); this way it works always.

Windows

Strange but true.