add javax.comm API on a mac - java

I would like make an java app that communicates with a serial device(handheld scanner) so that the app is platform independent.
I have found a few code examples, and when I copy them into Eclipse it says that javax.comm.* is missing.
How do I install this on my Mac?
And how do I add this library to my app so that the users does not have to install anything?
I want to able to give the users a jar file and the device, and they should be able to run it on windows/Mac/Linux without little or none configuration.
I found a download where I could download a javax.comm.jar file but the download included a win32comm.dll it dependented on some how - at least that was the fault I got when I added the jar file to my project.
Error loading win32com: java.lang.UnsatisfiedLinkError: no win32com in java.library.path

This is the Java Communications API. You can get it here but it won't help you. The supported platforms are Solaris SPARC, Solaris x86, and Linux x86.
For Mac and Linux, if the serial port is already configured, you can open /dev/ttyS0, /dev/ttyS1, /dev/ttyS2, etc. as a file and read/write to it. On Windows, if the serial port is already configured you can open "COM1", "COM2", etc. and read and write to it.
Unfortunately, javax.comm (as provided in the reference implementation) isn't cross-platform, so you'll have to either resort to bundling additional native libraries and supporting classes or use a platform-dependent way to configure the serial port. On Windows, this could be the "mode" command, and on Mac/Linux, this could be the stty command.

I would recommend RXTX. It doesn't use the javax.comm package, but it follows the same API (with some helpful additions).
E1: As it turns out, RXTX 2.0 does use the javax.comm package. You can find it on the same download page.

Related

Getting UnsatisfiedLinkError: no rxtxSerial in java.library.path for Mac

I am trying to use rxtx as a way for arduino to communicate via serial port to my java program. However, despite trying many versions of rxtx downloads as well as the many answers to questions like this on stack overflow, I cannot seem to get rid of this error.
I have added to VM options the path to my librxtxSerial.jnilib file as well as RXTXcomm.jar. I have tried all of the downloads : http://rxtx.qbang.org/wiki/index.php/Download
I'd advise you to move to nrjavaserial as it is really the next (maintained) version of RXTX. The code hasn't changed significantly but they include the native libraries (which you're missing) in the Jar file so you don't have to have the Java side and the native side. I've used it for Bluetooth projects on Mac and Linux and it works well.

Native library bluecove not available on Mac

I downloaded bluecove-2.1.0.jar and added it as an external JAR on my Eclipse project. I am following this tutorial for using Bluetooth with Android: http://luugiathuy.com/2011/02/android-java-bluetooth/
When I run the program intended for my laptop to act as a server, I get an error stating 'Native library bluecove not available'. I made sure bluetooth was enabled by typing 'bluetooth' in Spotlight (which took me to Bluetooth File Exchange and allowed me to select a file to send).
I saw another Stackoverflow post stating that BlueCove requires 32-bit JVM to run so I added the -d32 argument under VM arguments in the run configuration. When I ran it, I got another error stating
"Error: This Java instance does not support a 32-bit JVM.
Please install the desired version."
Does anyone have any ideas on how to fix this?
Try using OpenJDK rather than the Oracle JDK. This supports the -d32 arguments so it ought to work for you.
OpenJDK may work as Mike suggested but its installation process was rather involved. I found a workaround by installing an earlier version of Eclipse that supported 32-bit OS X versions and setting -d32 in the VM arguments there worked without issues. Be sure to keep the earlier version of Eclipse in a separate folder so it doesn't overwrite your recent version.
I installed the 32-bit version of Eclipse Kepler from here: https://eclipse.org/downloads/packages/release/Kepler/SR2
Of course, Bluecove had some other issues with IOBluetooth device not found (since Apple removed that since OS X 10.8 I believe), for which you can check here for a possible solution.

Installing Java on a Flash Drive

I'm really tired of computers not having the necessary Java version I need, or I don't have admin privileges to install it. I've seen tons of windows tutorials, but I'm on a Mac. So can someone tell me how to put Java 7/8 on a flash drive, and how to create a script to run a jar file with the version on my drive I have selected? Thanks! I'm on Mac OS X 10.10
Based on your comment to another answer
I have a computer I can do it on with admin privileges
It sounds like you just want to have the JVM/JDK on some portable media that you can run from after you plug it into another computer. This should be simple assuming you only plan on using it on comparable systems. For example, you won't reliably (or at all) be able to install Mac x64 java binaries on a flash drive and try to run it on a Windows machine.
So assuming you only intend to run it on comparable machines, it's as simple as copying the directory structure from the root of the Java install directory. On my Mac OsX 10.9.5 it's /Library/Java/Home. Once you have it on the drive, you just plug it into another Mac. It should automount and you open up a terminal to the root of that mount. cd into the $JAVACOPY/bin (where $JAVACOPY is the directory structure you copied) and you can run ./java -version to verify you are running it.
If all is well after doing that, you can launch any JAR file from that flash drive mount directory with
cd /Volumes/flashMount/Java/Home/;
./bin/java -jar /Users/myuserid/myJar.jar
Keep in mind that Java doesn't strictly require any of the formal install process that systems like Mac and Windows surround it with. All of the fluff involved with "installing" java is about setting up the system to use whichever Java version is installed without the user having to know or care. But you can have as many versions of java as you want in the file system without "installing" them and they should all function just fine (ignoring classpath collisions for certain libraries.)

RXTX gnu.io.PortInUseException: & WARNING: RXTX Version mismatch

I am trying to get GPS data from a NMEA 0183 GPS via the Java Marine API, using the RXTX API.
Running the Java Marine supplied SerialPortExample.java, I return the two errors. Perhaps they are related and so I am bundling them together into this question.
gnu.io.PortInUseException: Unknown Application
I believe this is caused by the RXTX API. A search reveals that OSX often is missing the required var/lock folder, which one would rectify by with sudo mkdir /var/lock (full details: https://groups.google.com/forum/#!topic/openhab/YUJC8DTLokc) however this does not solve my problem.
WARNING: RXTX Version mismatch
I have Jar RXTX-2.1-7 but native lib Version = RXTX-2.2pre2. I am trying to download the latest version of RXTX, but keep running into dead links (http://rxtx.qbang.org)
I am running Mavericks on MB Air.
Can anyone help?
Problem 1
gnu.io.PortInUseException: Unknown Application
I solved this by looking up the ports in use on my machine with ls /dev/tty.*
This flagged up a lot of old bluetooth devices, I cleared most of them off (Apple > System Preferences > Bluetooth) and it solved the problem
Problem 2
WARNING: RXTX Version mismatch
I took some time to delete everything associated with the RXTX install, and ensured that I was only using one version. Seems to have done the trick.
unknown port exception
This error happens while some of other programs are using the serial port .Make sure your no other applications are using serial port when your application works .check your application is also running only single copy.
RXTX version mismatch
download rxtx jar matched with your java version
I had the same bug. Make sure you terminate any other processes that could be using that connection. I was trying to run my program from the command line but the port was connected to energia's serial monitor.
RXTX: if you manually added any RXTX files delete them and run sudo apt-get install librxtx-java, this should clear up the mismatch.

cannot find symbol in net beans

i am having code which is using javax.comm lib file,i am getting error saying cannot find symbol.i want to know where exactly my jar file should be?i using windows xp and net beans ide
Import jar into netbeans
Do get it to run maybe also check
The Java Communications API: A Working Example
According to the Java Communications API web page, there is no implementation for Windows XP:
[...]
Implementations of the API are currently available for Solaris SPARC, Solaris x86, and Linux x86.
[...]

Categories

Resources