• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with serial communication in java

 
Preeti Malik
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Joe Ess
Bartender
Posts: 9318
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Preeti Malik
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9318
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
put win32com.dll in the windows dll dir (I think it is Windows\system32)
 
Preeti Malik
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
javax.comm is working properly now, problem solved!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic