473,465 Members | 1,934 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

problem in javax.comm package . it is showing package does not exist.....

8 New Member
import java.io.*;
import java.util.*;
import javax.comm.*;
import javax.swing.*;
import java.awt.TrayIcon;

public class location implements Runnable, SerialPortEventListener {

static CommPortIdentifier portId;
static Enumeration portList;
static BufferedReader inputStream;
static SerialPort serialPort;
Thread readThread;
static String v="";
static String hj="";
static String b1="";
static String fq="";
static String ok="";


public void get() {
boolean portFound = false;
String defaultPort = "COM1";


portList = CommPortIdentifier.getPortIdentifiers();

while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
if (portId.getName().equals(defaultPort)) {
System.out.println("Found port: "+defaultPort);
portFound = true;
init();
}
}
}
if (!portFound) {
System.out.println("port " + defaultPort + " not found.");
}

}


public void init() {
try {
serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
} catch (PortInUseException e) {}

try {
inputStream = new BufferedReader(new InputStreamReader(serialPort.getInputStream()));
} catch (IOException e) {}

try {
serialPort.addEventListener(this);
} catch (TooManyListenersException e) {}

serialPort.notifyOnDataAvailable(true);

try {
serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
} catch (UnsupportedCommOperationException e) {}

readThread = new Thread(this);

readThread.start();
}


public void run() {
try {
Thread.sleep(20000);
} catch (InterruptedException e) {}
}


public void serialEvent(SerialPortEvent event) {
switch (event.getEventType()) {

case SerialPortEvent.BI:

case SerialPortEvent.OE:

case SerialPortEvent.FE:

case SerialPortEvent.PE:

case SerialPortEvent.CD:

case SerialPortEvent.CTS:

case SerialPortEvent.DSR:

case SerialPortEvent.RI:

case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;

case SerialPortEvent.DATA_AVAILABLE:

try
{
String to="";
v=inputStream.readLine();
System.out.println("GET="+v);
System.out.println("Next-"+inputStream.readLine());


System.out.println(v.length());
int len=v.length();
String val="";
for(int i=1;i<len;i++)
{
char c=v.charAt(i);
val=val+c;
}
System.out.println("Final-"+val);
System.out.println(v);
sub s=new sub();
message4 msg=new message4();

String a=s.twis(s.set(val));
System.out.println(a);
System.out.println(msg.mess(a));
String b1=msg.mess(a);
System.out.println("End3");
BareBonesBrowserLaunch b=new BareBonesBrowserLaunch();
b.openURL("http://localhost:8080/city_view_/personaldetails.jsp?id="+b1);



} catch (Exception e) {
System.out.println("End2-"+e);
}



break;
}


}
public void start()
{ /*location d=new location();
d.get();*/

}
}
Oct 26 '10 #1
0 1642

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

Similar topics

20
by: | last post by:
If I need to check if a certain value does exist in a field, and return either "yes" or "not" which query would be the most effestive?
1
by: Leo | last post by:
Hello all, I am having a problem which I cannot seem to find a solution for. In SQL Server 2000 I have created a DTS package which imports a Text file into a table. When I run the DTS package...
3
by: David W. Rogers | last post by:
I am trying to use the software from John Hind's article: "Use P/Invoke to Develop a .NET Base Class Library for Serial Device Communications". When I use my application, everything works fine. I...
0
by: neena | last post by:
When I start Microsoft Visual Studio .NET 2003 I am getting the following error message: --------------------------- Package Load Failure --------------------------- Package 'VsRptDesigner...
3
by: tshad | last post by:
I get the following error: PageInit.cs(43,71): error CS0246: The type or namespace name 'User' could not be found (are you missing a using directive or an assembly reference?) The error is...
9
by: mdshafi01 | last post by:
Hello All, I have problem in installing DBD::ORACLE package. Please can any one have experience in installing DBD::ORACLE package. please give me some hints to install this DBD::ORACLE...
9
by: rajujrk | last post by:
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...
4
Kosal
by: Kosal | last post by:
Dear Sir/Madam I would like you to help me to resolve the problem as below. I using window vista and I want to install VPN Client but error message : Eror 1721. there is a problem with the...
1
by: liming | last post by:
I have installed postgresql 8.3.1,import data from a dB to another one.I work in pgadmin 3 . When I choose a table ,select the characteristic?it shows the problem below? Error:relation...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.