Want to communicate with serial port using Java? You may want to try RxTx library. It's easy to use.
To install follow the instruction below:
The official RxTx binary pack is available here. The provided link will download the distro with some standard binaries (for linux 32bit, 64 bit, etc). If binaries for your specific operating system are not included, you may consider recompiling RxTx yourselves.
For a custom Win64 RxTx distro, have a look at the CloudHopper's web site.
To install it, unzip the distribution file in a temporary place and do the following copies:
File RXTXcomm.jar should go under JDKDIR/jre/lib/ext/
The necessary library( .so for linux, .dll for windows) should go under JDKDIR/jre/bin/
Unzip the distribution archive, i.e. apache-maven-3.0.4-bin.zip to the directory you wish to install Maven 3.0.4. These instructions assume you chose C:\Program Files\Apache Software Foundation. The subdirectory apache-maven-3.0.4 will be created from the archive.
Add the M2_HOME environment variable. [almost similar as this]: adding the M2_HOME variable in the system variables with the value C:\Program Files\Apache Software Foundation\apache-maven-3.0.4. Be sure to omit any quotation marks around the path even if it contains spaces.
In the same dialog, add the M2 environment variable in the system variables with the value %M2_HOME%\bin.
In the same dialog, update/create the Path environment variable in the system variables and prepend the value %M2% to add Maven available in the command line.
In the same dialog, make sure that JAVA_HOME exists in your system variables and it is set to the location of your JDK, e.g.C:\Program Files\Java\jdk1.5.0_02 and that %JAVA_HOME%\bin is in your Path environment variable.
Open a new command prompt and run mvn --version to verify that it is correctly installed.
Linux based/Ubuntu Operating Systems:
Extract the distribution archive, to the directory you wish to install Maven 3.0.4. These instructions assume you chose /home/username/java/tools/maven.
Open terminal and type: gedit ~/.bashrc
Set environment variable by adding the following lines at the bottom of .bashrc :
export M2_HOME=/home/username/java/tools/maven
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
export JAVA_HOME=/usr/lib/jvm/jdk-default #if JAVA_HOME not exist.
Run mvn --version to verify that it is correctly installed.
a. Checking if java is set as path environment variables:
1. Go to Start-> Run-> cmd
2. write: java -version and hit Return/Enter. If the path variable set properly it will show your java version.
b. Setting path variable in windows 7:
1. Go to start menu -> control panel -> system and security -> System.
or simply paste this in your windows explorer address bar-->
Control Panel\System and Security\System
2. Now select "Advanced system settings" from the left panel.
3. A new window appears. Click on "Environment variables..." 4. under System Variables, find PATH, and click on it. 5. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.
6. the location looks like: "C:\Program Files (x86)\Java\jdk1.6.0_23\bin;" end it with a semicolon.
7. Click ok.
8. Close all these windows.
C. Check if path variable is set properly:
1. Go to command prompt/cmd.
2. write: "java -version" end hit Return/Enter. if the path variable set properly it will show your java version.
3. If it still not working reboot your computer and try step c1 & c2.
Hope, now your path variable for java is set. Else read steps of "b" carefully.