Any Idea. Dealing with javax.comm ... UnsupportedCommOperationException ?
Hi... I would really appreciate if someone can help me out fugure this problem , cause this haulted the entire project i'm working on... I am creating a serial connection between my computer and a server located on a different machine... Both are connected via a serial cord... Now my program runs perfect when i use my compiler(code warrior 6.0) to run the application. Later i changed the java output type in the 'target setting panel' from a jar file to an executable file, this creates a Zip format file and an exe format file of the project. When i double click on the exe file to start my application this is what the console prints out
"Exception in thread "main" java.lang.NoClassDefFoundError: javax/comm/UnsupportesCommOperationException.
Now i don't have any error when i compile it using the compiler and the data transfer across the serial port is perfect. Now i'll include the parts of the code that have the serial port specification in them.... I would really appreciate if someone has any suggestions at all..
/CODE/
import javax.comm.*;
import javax.comm.UnsupportedCommOperationException;
import javax.comm.SerialPort;
//In the global definitions
private Enumeration portList;
private CommPortIdentifier portId;
private SerialPort serialPort;
//In the Event handler where the connection is chosen
while(portList.hasMoreElements())
{
portId = (CommPortIdentifier)portList.nextElement();
if(portId.getPortType() == CommPortIdentifier.PORT_SERIAL)
{
if(portId.getName().equals(portName))
{
try
{
serialPort = (SerialPort)portId.open("this",milliSecond);
}
catch(PortInUseException port_ex)
{
JOptionPane.showMessageDialog(null,"The port is in use","Error",JOptionPane.ERROR_MESSAGE);
}
try
{
serialPort.setSerialPortParams(38400,
serialPort.DATABITS_8,
serialPort.STOPBITS_1,
serialPort.PARITY_ODD);
}
catch(UnsupportedCommOperationException comm_ex)
{
JOptionPane.showMessageDialog(null,"Port parameters is unsupported by the driver","Error",JOptionPane.ERROR_MESSAGE);
}
}
}
}
//In the area where the send routine via serial is
public boolean sendSerialMsg(byte[] buffer, byte[] rcvMsg)
{
int count = 0, retryCount = 5;
int DataCounter = buffer[0] & 0x0f;
buffer[DataCounter+2] = checkSum(buffer);
try
{
while(count < retryCount)
{
int bytesRead;
inputSerialStream = serialPort.getInputStream();
outputSerialStream = serialPort.getOutputStream();
outputSerialStream.write(buffer, 0, MinMessageSize + DataCounter);
bytesRead = inputSerialStream.read(rcvMsg, 0, MaxMessageSize);
byte computedCS = checkSum(rcvMsg);
DataCounter = rcvMsg[0] & 0x0f;
if(rcvMsg[ (MinMessageSize + DataCounter) - 1] == computedCS )
{
// check the message, if ACK success, otherwise inc count retry
if(rcvMsg[1]==TallyNak)
{
System.out.println("Not Acknowledged");
}
else
{
return true;
}
}
count++;
}
}
catch(IOException io_ex)
{
JOptionPane.showMessageDialog(this,"No such connection","Error",JOptionPane.ERROR_MESSAGE);
}
return false;
}
/CODE/
Also if lets say the cord is connected to COM1 in the computer as well as the server and i choose COM2, the computer crashes. Is there a way to find out to what COM is the cord connected to ?

