473,513 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem to listout the ports in javax.comm package

107 New Member
hi, currently i am doing the project to send the sms from PC to Mobile and vice versa using GSM modem. I successfully done this process in Hyperterminal.

First i connect the GSM modem in COM1 port

then set the baud rate to 9600

and execute the AT commands in hyperterminal and its works fine..

But my problem is that to do the similar process in java..

javax.comm package is used to interact with the ports..

I used the below code

Expand|Select|Wrap|Line Numbers
  1.         portList = CommPortIdentifier.getPortIdentifiers();
  2.  
  3.         while (portList.hasMoreElements()) {
  4.             portId = (CommPortIdentifier) portList.nextElement();
  5.             if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
  6.                 if (portId.getName().equals("COM1")) {
  7.                 //if (portId.getName().equals("/dev/term/a")) {
  8.                     try {
  9.                         serialPort = (SerialPort)
  10.                             portId.open("SimpleWriteApp", 2000);
  11.                     } catch (PortInUseException e) {}
  12.                     try {
  13.                         outputStream = serialPort.getOutputStream();
  14.                     } catch (IOException e) {}
  15.                     try {
  16.                         serialPort.setSerialPortParams(9600,
  17.                             SerialPort.DATABITS_8,
  18.                             SerialPort.STOPBITS_1,
  19.                             SerialPort.PARITY_NONE);
  20.                     } catch (UnsupportedCommOperationException e) {}
  21.                     try {
  22.                         outputStream.write(messageString.getBytes());
  23.                     } catch (IOException e) {}
  24.                 }
  25.             }
  26.  
  27.  
But the problem is that results the port count is 0(Null).
Please i need the solution.. Its Urgent..

Thanks in Advance..
Oct 3 '08 #1
9 6455
JosAH
11,448 Recognized Expert MVP
Note that saying "It's urgent" doesn't help you much: it may be urgent to you but
it isn't urgent to us and we won't hurry and treat you in a priviledged way because
you mentioned your urgency; you'd better had started your project a bit earlier.

w.r.t. your question: Sun's comm package only handles parallel and serial ports;
it doesn't understand, nor recognizes any usb ports.

kind regards,

Jos
Oct 3 '08 #2
rajujrk
107 New Member
Note that saying "It's urgent" doesn't help you much: it may be urgent to you but
it isn't urgent to us and we won't hurry and treat you in a priviledged way because
you mentioned your urgency; you'd better had started your project a bit earlier.

w.r.t. your question: Sun's comm package only handles parallel and serial ports;
it doesn't understand, nor recognizes any usb ports.

kind regards,

Jos
But Even it didn't list out the PARALLEL and SERIAL ports

Why?
Oct 10 '08 #3
JosAH
11,448 Recognized Expert MVP
What happens when you append a line (after line #4) like this:

Expand|Select|Wrap|Line Numbers
  1. System.out.println(portID.getName());
  2.  
Is anything printed at all?

kind regards,

Jos
Oct 10 '08 #4
rajujrk
107 New Member
What happens when you append a line (after line #4) like this:

Expand|Select|Wrap|Line Numbers
  1. System.out.println(portID.getName());
  2.  
Is anything printed at all?

kind regards,

Jos

AFter the Below Statement
Expand|Select|Wrap|Line Numbers
  1. portList = CommPortIdentifier.getPortIdentifiers(); 
  2.  
the getPortIdentifiers() method return no values . So the below while says always false
Expand|Select|Wrap|Line Numbers
  1.         while (portList.hasMoreElements()) { 
  2.  
  3.          }
  4.  
What happened in the getPortIdentifiers() Method?
Oct 10 '08 #5
JosAH
11,448 Recognized Expert MVP
What happened in the getPortIdentifiers() Method?
Did you properly install all three files? i.e. the jar in the lib/ext directory, the dll
in the bin directory and the .properties file in the lib directory.

kind regards,

Jos
Oct 10 '08 #6
rajujrk
107 New Member
Did you properly install all three files? i.e. the jar in the lib/ext directory, the dll
in the bin directory and the .properties file in the lib directory.

kind regards,

Jos
ya, i installed it in lib/ext

I include the following files

1. comm.jar
2. javax.comm.properties

What is the third file?

I have another file as win32.dll
Oct 11 '08 #7
JosAH
11,448 Recognized Expert MVP
Store that .properties file in /lib instead. So:

1) the .jar in /lib/ext
2) the .properties in /lib
3) the .dll in /bin

Also read their installation notes.

kind regards,

Jos
Oct 11 '08 #8
rajujrk
107 New Member
Store that .properties file in /lib instead. So:

1) the .jar in /lib/ext
2) the .properties in /lib
3) the .dll in /bin

Also read their installation notes.

kind regards,

Jos

Ya its working fine now..

I put .properties file in lib/ext

i change its loc to lib

Now its works fine

Thank you..
Oct 11 '08 #9
Bharti Goel
1 New Member
hi,

I am trying to do this same task. For me it is recognizing the ports but not sending the sms. It works fine via hyperterminal. Is it possible for you to send me your code?

Thanks a lot.

regards
Bharti
Dec 8 '11 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
6548
by: Hal Vaughan | last post by:
I'm using JDK 1.4.1 for Java 2. According to the API docs, I can use javax packages, but when I add: import javax.crypto; I get an error that it can't find the package. Is there some special...
4
5341
by: jesper | last post by:
Hi I am currently following the tutorial from IBM (http://www-106.ibm.com/developerworks/xml/edu/x-dw-xjaxb-i.html) I have three problems at the moment. 1. It says else where that when the...
13
10975
by: Bob Greschke | last post by:
We have some equipment that communicates at 57600 baud RS232. The path from the PC is USB to a Phillips USB hub, then off of that a TUSB3410 USB/Serial converter. The driver for the 3410 chip...
0
2090
by: Raquel | last post by:
I downloaded UDB PE8.1.3 on Win XP. JDK gets downloaded along with it (Java version 1.3.1). However, when I am trying to compile a java program which uses DataSource interface for Connections (by...
3
1523
by: Steve | last post by:
Hi All and seasons greetings. Is there an easy way of getting a list of current Comm ports on a machine? I suspect that most machines these days have 1 and 2, but there could be others and I...
12
11307
oll3i
by: oll3i | last post by:
when i launch the application from sun application server the console opens throws something i cannt even read what and closes before the application opened and threw nullpointerexception now it...
3
16516
by: psroga | last post by:
Can anyone look at this code and let me know why pthread_mutex_unlock and pthread_mutex_lock are giving me the "phtread_mutex_unlock" was not defined in this scope error. I am compiling the code...
1
14031
by: shrik | last post by:
hi everybody. I have following problem. There are two pages. index.jsp and main.jsp in my application Index.jsp contains logging interface in . It submits password and userid to loginform bean. ...
1
2293
by: Neverhood | last post by:
Hi folks, I'm trying to make a small game about being a drug dealer, with a 10x8 grid JPanel. On top of that i have another 10x8 grid JPanel as glassPane for the player icon. I have all the...
0
7166
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7386
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7543
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5094
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3236
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3226
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1601
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.