aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes problem with serial communication in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "problem with serial communication in java" Watch "problem with serial communication in java" New topic
Author

problem with serial communication in java

Preeti Malik
Greenhorn

Joined: Dec 14, 2006
Posts: 6
I am using javax.comm package to achieve serial communication in java. I did the following:

1. put comm.jar in jdk/lib and jre/lib
2. put javax.comm.properties in jdk/lib and jre/lib
3. put win32com.dll in jdk/bin and jre/bin

I put my java program in jdk/bin directory and compiled it, its compiling and running properly. Its able to read from and write to a serial port and communicate with a device attached to that port.
But when i put the same program in another directory (my directory of java programs), it compiles fine but shows the following exception when run:

Exception in thread "main" java.lang.NullPointerException
at WriteReadPort.main(WriteReadPort.java:27)

I am working on Windows 2000, I have added the path of my java programs directory in CLASSPATH env variable, i really dont know why this exception is occuring, the same program is running perfectly in the jdk/bin directory.

Can anyone please help me out, this is very important.

thanks
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Hi,

Welcome to JavaRanch.

Please don't post the same question to more than one forum. See here for an explanation of why I just deleted three other copies of this thread.


[Jess in Action][AskingGoodQuestions]
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8964
    
    9

That behavior seems to point to your jdk/bin not being in the PATH (CLASSPATH has nothing to do with DLL's)
You should be aware that the Windows version of the java.comm api has long since been discontinued. Our Java IO FAQ has some alternatives.


[How To Ask Questions On JavaRanch]
Preeti Malik
Greenhorn

Joined: Dec 14, 2006
Posts: 6
i have put jdk/bin path in PATH variable also, the problem still persists, so are you suggesting i use rxtx instead of javax.comm?? i need my program to read & write to a serial port and not USB
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8964
    
    9

so are you suggesting i use rxtx instead of javax.comm??

I have done little work with java.comm and none with rxtx. However, java.comm is not supported on Windows and rxtx appears to have a stable community, so your chances may be better with rxtx.

i need my program to read & write to a serial port and not USB

I don't know where you would get that impression:

RXTX is a native lib providing serial and parallel communication for the Java Development Toolkit (JDK).

RXTX: Intro
Mike Ngo
Ranch Hand

Joined: Oct 16, 2006
Posts: 89
put win32com.dll in the windows dll dir (I think it is Windows\system32)
Preeti Malik
Greenhorn

Joined: Dec 14, 2006
Posts: 6
javax.comm is working properly now, problem solved!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with serial communication in java