Thursday, June 28, 2012

Install javax.comm(or RXTX) in Eclipse

Hello Everyone...,
This post is about Configuring Eclipse IDE to work with javax.comm Api , so that we can read or write from Serial Port [RS232].

We can do this by using any one api :
  • Java Communication Api (javax.comm) or
  • RXTX (
both are same RXTX is a 3rd party API the only difference is we need to use
import*;  instead of
javax.comm.*;  Rest everything is same.

Here I'm gonna use RXTX API.
You can Download it from here :

Configuring both the api's require same steps., we just add the jar files to our Eclipse Project Build path.

And the trick part is adding Native Libraries like DLL(on Windows ) or SO(on Linux).
So Lets get Started.

  1. First Download the RXTX api from above mentioned Link.
  2. Extract to any Location.
  3. Right Click on you Eclipse Project (in Package Explorer on Left Panel).
  4. Select "Build Path".
  5. Click "Configure Build Path" .( A new Window will Open)
  6. Select "Add External Jars" under "Libraries" tab.(It will open a File Chooser)
  7. Select "RXTXcomm.jar".[Now our Jar File is Added and we need to attach the Native Library File to our Jar File(RXTXcomm.jar).]
  8. Under "Libraries" Expand the JAR file "RXTXcomm.jar" (using '+' icon at start of RXTXcomm.jar name)
  9. Select the "Native Library Location"
  10. Click "Edit" (It will open new Window)
  11. Click "External Folder" button ( A File Chooser will open )
  12. Now browse to the downloaded RXTX api folder open the appropriate OS folder and select the folder where native library files are located. [ Example on Windows OS ..\rxtx-2.1-7-bins-r2\Windows\i368-mingw32\ is the location of DLL files. ]
  13. Click OK and everything is done.
Remember to change or use import*; instead of javax.comm.*; If you are using RXTX API.

You can see the following video, Demonstrated the all of the above steps.

Hope this post was helpful to you.
If yes, Leave a comment.
If any queries.., leave a comment or contact to my email., I'll be sure to help as per my Knowledge.

... " You have no idea how happy you'll feel, standing in its Shade when it grows up "....

Tuesday, June 26, 2012

Adding JAR Files to your Project in Eclipse

Hello fellow Java Developers..,
In this post I'll show you how to add JAR files to your project in ECLIPSE IDE.


Eclipse ide provide 2 ways to add JAR files to our project:

  1. Adding External JARs
  2. Adding JARs
(yes there is a difference in those 2 options)

Adding External Jars:

In this option Eclipse add JAR files to Project by Absolute path..,
i.e., If you add a jar file which is located on desktop your system,to your Eclipse Project
then the path would be : c:/documents and settings/admin/desktop/xxxxxxx.jar.
The main Disadvantages of adding jar files like this are:
  • If you move or delete the jar file located in absolute path then project won't work.
  • If you move your project to other PC then you need to place the jar file in same location as in the previous system OR you need to add the jar file to project again.

Here is how you can add JAR file using "Add External JAR s" method.
  1. Rigth Click on your Eclipse Project.
  2. Go to Build Path
  3. Select "Add External Jar Archives" , if this option is not listed go to STEP 4 or go to  STEP 6
  4. Select "Configure Build Path"
  5. Select "Add External JARs" under "Libraries"
  6. You'll get a File dialog : Select the JAR file you want to add and OK.

See the following Video:

Adding JARs

 In this option  Eclipse will add the JARs from Relative path in Project Directory.
All you have to do is copy the jars to your Project folder.
Now even if you move your project to another PC you don't need to worry about the JARs

Lets see how we can add Jars to our Eclipse Projects Permanently using this method:

  1. Copy all the JAR files you need to include in your project.
  2. Now Create a new Folder in your Eclipse Project as Follows
    1. Right Click and select New
    2. Select "Folder" option
    3. Provide name for folder ( say: APIs)
  3. Now paste all the jars inside that folder.
  4. Now Right click on project select "Build Path"
  5. Select "Configure Build Path"
    Select "Add JARs" [ NOT Add External JARs ] option under "Libraries" Tab
  6. A file Explorer will open up. Notice that it shows only files on you Eclipse workspace.
  7. Now select the JAR files that you psated in your project folder.
Observer that the path for Referenced jar is Relative [ Example /<Project Name>/APIs(folderName)/ ]

See the Following Video

If you have any further queries contact me or post a reply.
Hope you find, what you're looking for.