tags:

views:

147

answers:

3

am geeting the following error while launching the application. Exception in thread "javaWSApplicationMain" java.lang.NoClassDefFoundError:SimpleSerail.

The java code that i am using is as follows:

Aeon_PManager.java

/**************************************************************************
***************************************************************************
    Version    : Aeon_PManager 1.00
    Done By  : N.S. Vijayashree
    Started on             :  25.08.2007
****************************************************************************
****************************************************************************/

//import javax.comm.*;
import java.io.*;
import java.util.TooManyListenersException;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.Timer.*;
import javax.swing.border.*;
import java.util.*;
//import java.lang.*;
//import java.lang.ClassNotFoundException;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.table.*;
import java.text.DateFormat;
import java.util.Date;
import java.net.*;
//import java.File;


public class Aeon_PManager extends JPanel
    {
    String projectfor="";
    String flag="";
    String waybill_data="";
    int result=0;
    String hex_checksum = "";
    String file_data_buffer = "";
    Date now = new Date();
    String sys_date="",Sys_time="";
    static JDialog dialog;
    JFrame frame;
    static  ProgressMonitor progressmonitor;
    static  int counter = 0;
    JLabel slabel1;
    String filename ="";

    final JLabel label = new JLabel ();
    EmptyBorder empty = new EmptyBorder(5,5,5,5);
    JTextField ebtno_wtext1 = new JTextField (10);
    JTextField flag_wtext2 = new JTextField (10);
    JTextField ver_wtext3 = new JTextField (10);
    JTextField tkt_wtext4 = new JTextField (10);
    JTextField amt_wtext5 = new JTextField (10);
    SimpleSerial ss;


    public Aeon_PManager ()
     {
            frame = new JFrame("Aeon HHBM Manager");
     JFrame.setDefaultLookAndFeelDecorated(true);

     ss = new SimpleSerialNative(1); 

     JFrame.setDefaultLookAndFeelDecorated(true);         
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     frame.getContentPane().setLayout (new BorderLayout ());
     frame.getContentPane().add (trsm_northpanel(),BorderLayout.NORTH);
     frame.getContentPane().add (trsm_centerpanel(),BorderLayout.CENTER);
     frame.getContentPane().add (trsm_southpanel(),BorderLayout.SOUTH);
     frame.getContentPane().add (trsm_westpanel(),BorderLayout.WEST);
     frame.getContentPane().add (west_displaypanel (),BorderLayout.EAST);
     frame.pack ();frame.setResizable (false);
            frame.setVisible(true);  
     } 
     //..........................End of constructor trnsm1 ().........................................

    protected JComponent trsm_northpanel ()
     {
     JPanel northpanel = new JPanel (new GridLayout(2,0,0,0));  
     JLabel nlabel = new JLabel ("AEON HHBM Manager",JLabel.CENTER);  
     JLabel nlabel1 = new JLabel ("      Device Interface and Data Communication",JLabel.CENTER);
     JLabel nlabel2 = new JLabel ("VER : 01.01",JLabel.RIGHT);
     nlabel1.setVerticalAlignment (JLabel.CENTER);
     JPanel p1 = new JPanel (new GridLayout(2,0,0,0));
     p1.add (nlabel1);
     p1.add (nlabel2);  
     northpanel.add (nlabel);
     northpanel.add (p1);
     return northpanel;
     }

    protected JComponent trsm_southpanel ()
     {
     JPanel southpanel = new JPanel ();
     southpanel.setLayout (new BoxLayout(southpanel,BoxLayout.Y_AXIS));
     southpanel.setBorder (BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(""),BorderFactory.createEmptyBorder(5,5,5,5)));      
     slabel1 = new JLabel ("               ");   
     southpanel.add (slabel1);
     return southpanel;
     }

    protected JComponent trsm_westpanel ()
     {
     JPanel westpanel = new JPanel (new BorderLayout()); 
     westpanel.add (west_buttonpanel (),BorderLayout.NORTH);
     return westpanel;
     }

    protected JComponent west_buttonpanel ()
     {
     JPanel wsubpanel1 = new JPanel (new GridLayout (9,1,0,3));
     final JButton bstatus = new JButton ("EBTM Status");
     //final JButton bupmisc = new JButton ("Upload Miscellenous Data");
     //final JButton buptarf = new JButton ("Upload Tariff Data");
     /*final JButton buproute = new JButton ("Upload Data");  
     final JButton beraset = new JButton ("Erase Transaction");
     final JButton bdndata = new JButton ("Download Data");
     final JButton bupfirmware = new JButton ("Upload New Firmware");
     //final JButton bsync = new JButton ("Synchronize Time_Date");*/
     final JButton bclose = new JButton ("Close");

     bstatus.setMnemonic ('S');
     //bupmisc.setMnemonic ('M');
     //buptarf.setMnemonic ('T');
     /*buproute.setMnemonic ('R');  
     beraset.setMnemonic ('T');
     bdndata.setMnemonic ('D');
     bupfirmware.setMnemonic ('F');*/
     //bsync.setMnemonic ('Y');
     bclose.setMnemonic ('C');

     bstatus.setToolTipText ("Gets EBTM Status");
     //bupmisc.setToolTipText ("Upload Miscellenous Data from PC to EBTM");
     //buptarf.setToolTipText ("Upload Tariff Data from Pc to EBTM" );
     /*buproute.setToolTipText ("Upload Data from PC to EBTM ");  
     beraset.setToolTipText ("Erase the data in Memory");
     bdndata.setToolTipText ("Download data from EBTM to PC");
     bupfirmware.setToolTipText ("Upload new Firmware form PC to EBTM");*/
     //bsync.setToolTipText ("Synchronize PC and EBTM Time and Date");
     bclose.setToolTipText ("Close this window");

     wsubpanel1.add (bstatus);
     //wsubpanel1.add (bupmisc);
     //wsubpanel1.add (buptarf); 
     /*wsubpanel1.add (buproute);  
     wsubpanel1.add (beraset); 
     wsubpanel1.add (bdndata); 
     wsubpanel1.add (bupfirmware);*/
     //wsubpanel1.add (bsync);  
     wsubpanel1.add (bclose);

     //bupmisc.setEnabled (false);
     //buptarf.setEnabled (false);
     /*buproute.setEnabled (false);  
     beraset.setEnabled (false);
     bdndata.setEnabled (false);
     bupfirmware.setEnabled (false);
     //bsync.setEnabled (false);*/


     JPanel westpanel1 = new JPanel ();
     westpanel1.setLayout (new BoxLayout(westpanel1,BoxLayout.Y_AXIS));
     westpanel1.setBorder (BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Task"),BorderFactory.createEmptyBorder(5,5,5,5)));      
     westpanel1.add (wsubpanel1);

     bstatus.addActionListener (new ActionListener ()
       {
       public void actionPerformed (ActionEvent ae)
        {     
        slabel1.setText ("                                                             ");
        get_status ();    
        slabel1.setText ("Get Status ................");

        /*if (flag.equals("T")) { bdndata.setEnabled (true);bupfirmware.setEnabled (false);} //bupfirmware.setEnabled (true) added by shiva      
        if (flag.equals("D")) { beraset.setEnabled (true);bdndata.setEnabled (true);}
        if (flag.equals("E")) {beraset.setEnabled (true);}
        if (flag.equals("R")) 
         {      
         buproute.setEnabled (true); bupfirmware.setEnabled (true);
         }*/

        //bupmisc.setEnabled (true);
        //buptarf.setEnabled (true);
        /*buproute.setEnabled (true);  
        beraset.setEnabled (true);
        bdndata.setEnabled (true);
        bupfirmware.setEnabled (true);
        //bsync.setEnabled (true);*/

        slabel1.setText ("                                                             ");    
        }
       });

     /*bdndata.addActionListener (new ActionListener ()
       {
       public void actionPerformed (ActionEvent ae)
        {     
        //download_data ();
        download_data_new ();
        beraset.setEnabled (true);
        bdndata.setEnabled (true);        
        }

       }); 

     beraset.addActionListener (new ActionListener ()
       {
       public void actionPerformed (ActionEvent ae)
        {     
        erase_data_transaction ();
        bdndata.setEnabled (false);// buproute.setEnabled (true);
        beraset.setEnabled (false);     
        }
       });

     bupmisc.addActionListener (new ActionListener ()
       {
       public void actionPerformed (ActionEvent ae)
        {     
        upload_misc_data();
        bupmisc.setEnabled(false);

        }

       });

     buptarf.addActionListener (new ActionListener ()
       {
       public void actionPerformed (ActionEvent ae)
        {     
        upload_tariff_data();
        buptarf.setEnabled(false);       
        }

       });*/ 



     /*buproute.addActionListener (new ActionListener ()
       {
       public void actionPerformed (ActionEvent ae)
        {      
        upload_route_data ();     
        buproute.setEnabled (false);       
        }
       });

     bupfirmware.addActionListener (new ActionListener ()
       {
       public void actionPerformed (ActionEvent ae)
        {
        int j = upload_new_firmware ();     
        if (j == 1) bupfirmware.setEnabled (true);
        else
         bupfirmware.setEnabled (false);      
        }
       });/*

     /*bsync.addActionListener (new ActionListener ()
       {
       public void actionPerformed (ActionEvent ae)
        {     
        sync_time_date();
        bsync.setEnabled(true);

        }

       });*/ 


     bclose.addActionListener (new ActionListener ()
       {
       public void actionPerformed (ActionEvent ae)
        {
        ss.close();     
        frame.dispose ();
        }
       });    

     return westpanel1;
     }

    protected JComponent west_displaypanel ()
     {
     JPanel wsubpanel2 = new JPanel (new GridLayout (7,1,2,3));
     JLabel wlb1 = new  JLabel (" ");
     JLabel wlb2 = new  JLabel (" ");
     JLabel wlb3 = new  JLabel (" ");
     JLabel wlb4 = new  JLabel (" ");
     JLabel wlabel1 = new JLabel ("EBTM NO",JLabel.RIGHT);
     JLabel wlabel2 = new JLabel ("FLAG",JLabel.RIGHT);  
     JLabel wlabel3 = new JLabel ("VERSION",JLabel.RIGHT);
     JLabel wlabel4 = new JLabel ("TICKET",JLabel.RIGHT);
     JLabel wlabel5 = new JLabel ("CUM AMT",JLabel.RIGHT);


     wlabel1.setLabelFor (ebtno_wtext1);
     wlabel2.setLabelFor (flag_wtext2);
     wlabel3.setLabelFor (ver_wtext3);
     wlabel4.setLabelFor (tkt_wtext4);
     wlabel5.setLabelFor (amt_wtext5);

     wsubpanel2.add (wlb1); 
     wsubpanel2.add (wlb2);
     wsubpanel2.add (wlabel1); 
     wsubpanel2.add (ebtno_wtext1);
     wsubpanel2.add (wlabel2);
     wsubpanel2.add (flag_wtext2);
     wsubpanel2.add (wlabel3);
     wsubpanel2.add (ver_wtext3);
     wsubpanel2.add (wlabel4);
     wsubpanel2.add (tkt_wtext4);
     wsubpanel2.add (wlabel5);
     wsubpanel2.add (amt_wtext5);
     wsubpanel2.add (wlb3); 
     wsubpanel2.add (wlb4);

     JPanel westpanel2 = new JPanel ();
     westpanel2.setLayout (new BoxLayout(westpanel2,BoxLayout.Y_AXIS));
     westpanel2.setBorder (BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(""),BorderFactory.createEmptyBorder(5,5,5,5)));      
     westpanel2.add (wsubpanel2);
     return westpanel2;
     }

    protected JComponent trsm_eastpanel ()
     {
     JPanel eastpanel = new JPanel ();
     eastpanel.setLayout (new BoxLayout(eastpanel,BoxLayout.Y_AXIS));
     eastpanel.setBorder (BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Up/Down Loading"),BorderFactory.createEmptyBorder(5,5,5,5)));        

     JTextField elabel1 = new JTextField (25);   
     JTextField elabel2 = new JTextField (25);   
     elabel1.setBorder (new BevelBorder(BevelBorder.RAISED));  
     elabel2.setBorder (new BevelBorder(BevelBorder.RAISED));
     JProgressBar eprogressbar = new JProgressBar ();   
     eprogressbar.setMinimum (0);
     eprogressbar.setMaximum (100);
     JTextArea etarea = new JTextArea ();
     etarea.setLineWrap (true);
     etarea.setWrapStyleWord (true);
     etarea.append ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
     JScrollPane  ejsp = new JScrollPane (etarea);

     eastpanel.add (elabel1);
     eastpanel.add (new JLabel (" "));
     eastpanel.add (elabel2);
     eastpanel.add (new JLabel (" "));
     eastpanel.add (eprogressbar);
     eastpanel.add (new JLabel (" ")); 
     eastpanel.add (ejsp);
     return eastpanel;
     }

    protected JComponent trsm_centerpanel ()
     {
     JPanel centerpanel = new JPanel ();
     centerpanel.add (new JLabel());
     centerpanel.add (new JLabel());
     centerpanel.add (new JLabel());
     centerpanel.add (new JLabel());
     centerpanel.add (new JLabel());
     centerpanel.add (new JLabel());  
     return centerpanel;
     }

    public int get_status ()
     {
                  int i = 1;
     String status_string ="SSS2";

     ss.writeString (status_string);
                      try { Thread.sleep(800); } catch (InterruptedException e) {}

     String inputString = ss.readString ();

     display_status (inputString);
     return 1;
     }

    public void display_status (String inputString)
     {
     String str = "",in_str ="";
     in_str = inputString;
     str = in_str.substring (12,20);
     ebtno_wtext1.setText(str);
     str = in_str.substring (20,21);
     //str = "" + in_str.charAt(20);
     //str = in_str.charAt(10);  //shiva
     flag_wtext2.setText(str);
     flag = str;
     str = in_str.substring (22,33);
     ver_wtext3.setText(str); 
     }

    /*public void erase_data_transaction()
     {
     String erase_string ="SSS1";
     int i = 1;
     ss.writeString (erase_string);
     try 
      { 
      slabel1.setText ("Erasing data......");
      Thread.sleep(8000); 
      Thread.sleep(8000); 
      Thread.sleep(8000);
      Thread.sleep(4000);  
      }
     catch (InterruptedException e) {}
     slabel1.setText ("Data erased Sucessfully");
     }

    public void download_data_new ()
     {
             int i=0, status = 0,i_cnt = 0,count=0,timer = 0;

     int data_available = 0; 
     String count_bytes="";
     String recvd_checksum="";

     result =0; hex_checksum ="";file_data_buffer="";  

     String dwnld_string ="SSS5";
     String ok = "ROK";
     ss.writeString (dwnld_string);
     try
     {
     //FileOutputStream out = new FileOutputStream ("data.txt");
     //PrintStream p = new PrintStream (out);  

     for (i=0; i<4;i++)
      {
      i_cnt = ss.readByte();
      }
     count_bytes="";
     for (i=0; i<6;i++)
      {
      i_cnt = ss.readByte();count_bytes+=(char)i_cnt;
      }

     i_cnt = ss.readByte();

     count = conv_hex_to_dec (count_bytes);

     System.out.println(count);
     //for (i=0;i<count;i++)

      while(i<count)

      {
      i_cnt = ss.readByte();
      //System.out.println(i_cnt);
      file_data_buffer += (char)i_cnt;
      //checksum (i_cnt);
      i++;
      }
     i_cnt = ss.readByte();
     i_cnt = ss.readByte();recvd_checksum += (char)i_cnt;
     i_cnt = ss.readByte();recvd_checksum += (char)i_cnt;
     conv_checksum_tohex (result);  
     reverse_string ();

     if (hex_checksum.equals (recvd_checksum)) status = 1;
     else status = 0;  
     //p.close ();
     }
     catch (Exception e) {slabel1.setText ("Error :"+ e.toString());}  

     if (status == 1)
      {
      ss.writeString (ok);
      try { Thread.sleep(200); } catch (InterruptedException e) {}
      //System.out.println ("----"+file_data_buffer+"----");   
      Calendar  cal = Calendar.getInstance();
      int dt = cal.get(Calendar.DATE);
      int mn = cal.get(Calendar.MONTH) + 1;
      int yy = cal.get(Calendar.YEAR);
      String s="Datafiles\\";
      s+=yy;
      if (mn < 10) {s += "0"; }
       s+=mn;
      if (dt < 10)  {s += "0";}
       s+=dt;

      Date cur_date = new Date ();
      int hr = cur_date.getHours();
      int min = cur_date.getMinutes();
      int sec = cur_date.getSeconds();

      if (hr < 10) {s+="0";}
       s += hr;
      if (min < 10) {s+="0";}
       s += min;
      s+="_HHBM_TO_PC.txt";
      filename += s ; 
      try
       {
       FileOutputStream out = new FileOutputStream (filename);
       PrintStream p = new PrintStream (out);
       p.print (file_data_buffer);
       p.close();
       }
      catch (Exception e) {}   
      slabel1.setText ("Downloaded Sucessfully");   
      }
     else
      {
      file_data_buffer = "";
      slabel1.setText ("Error while downloading data");    
      }

     } 

    /*public void upload_misc_data()
     {

     }

    public void upload_tariff_data()
     {

     }*/ 

    /*public void upload_route_data ()
     {
     String upload_string = "SSS6";
     int i = 1,k=0,ret_val;
     long no_of_bytes;
     String s="";
     result =0; hex_checksum="";
     filename="";
     filename = get_filename ();
     System.out.println("filename : "+filename);
     //String str1="C:\\Aeon_PManager\\Datafiles\\"+filename;

     String str1="E:\\project\\Datafiles\\"+filename;
     System.out.println("Path : "+str1);
     //E:\projeect\Datafiles
     //System.out.println (str1);
     //File f1 = new File (filename);
     File f1 = new File (str1); //shiva
     no_of_bytes = f1.length(); 
     System.out.println(no_of_bytes); 
     conv_dec_to_hex (no_of_bytes);
     reverse_data_string ();

     s = "::: B ";
     s += hex_checksum+" ";

     ss.writeString (upload_string);

     while (true)
      {
      int data_available = ss.available ();
      if (data_available > 0)
       {
       String g = ss.readString();
       break;
       }
      }

               try { Thread.sleep(5000); } catch (InterruptedException e) {}

     ss.writeString (s);
     System.out.println (str1);

     try 
      {
      System.out.println (str1);

      FileReader fr = new FileReader(str1);
      //System.out.println (str1);
      while(k<no_of_bytes)

      //BufferedReader br = new BufferedReader(fr);
       {
       i = fr.read(); //Read a character 
       //System.out.println (i);

       ss.writeByte ((byte)i);
       checksum (i);
       k++;
       }

      fr.close();
      ss.writeByte ((byte)' ');
      hex_checksum = "";
      conv_checksum_tohex (result);
      reverse_string ();
      ss.writeString (hex_checksum);
                  try { Thread.sleep(500); } catch (InterruptedException e) {}   
      }
     catch (Exception e){System.out.println ("System File input error");}

     }

    public int upload_new_firmware ()
     {
     String upload_string = "SSS9";
     String s="";
     int k=0,no_of_bytes=0,i=0;
     result =0; hex_checksum="";
     String f_path = "Firmware\\"; 
     File f1 = new File (f_path);
     if (f1.exists())
      {
      String sf[] = f1.list ();
      k = sf.length;
      s = sf[k-1];
      k= 0;
      filename = "Firmware\\" + s ;   
      }
     else
      {
      slabel1.setText ("Error##: File Not Found");
      return 1;
      }
     f1 = new File (filename);
     if (f1.exists())
      {
      no_of_bytes =(int) f1.length();  
      conv_dec_to_hex (no_of_bytes);
      reverse_data_string ();

      s = "::: B ";
      s += hex_checksum+" ";
      //System.out.println (s);
      ss.writeString (upload_string);
      while (true)
      {
      int data_available = ss.available ();
      if (data_available > 0)
       {
       String g = ss.readString();
       break;
       }
      }

                  try { Thread.sleep(5000); } catch (InterruptedException e) {}
                          ss.writeString (s); 
      try 
      {
      FileReader fr = new FileReader(filename); 
      while (k < no_of_bytes)
       {
       i = fr.read();
       ss.writeByte ((byte)i);
       checksum (i);
       k++;
       }
      fr.close();
      ss.writeByte ((byte)' ');
      hex_checksum = "";
      conv_checksum_tohex (result);
      reverse_string ();
      ss.writeString (hex_checksum);
                        try { Thread.sleep(500); } catch (InterruptedException e) {}   
      }
      catch (Exception e){}
      return 0;
      }
     else
      return 1;
     }

    /*public void sync_time_date()
     {

     }*/

    public int conv_hex_to_dec (String count_bytes)
     {
     int count = 0;
     String s="";
     for (int i=0;i<count_bytes.length();i++)
      {
      s =count_bytes.substring (i,i+1);
      if (s.equals("A")) s="10";
      if (s.equals("B")) s="11";
      if (s.equals("C")) s="12";
      if (s.equals("D")) s="13";
      if (s.equals("E")) s="14";
      if (s.equals("F")) s="15";
      int k = Integer.parseInt (s);
      count +=k*(int) Math.pow (16.0,(double)5-i);   
      }
     return count;
     }

    public void checksum (int ascii)
     {
     result = result + ascii;
     result = result % 256;
     }

    public void conv_checksum_tohex (int result)
     {
     int cpy_result = 0,i,value=0;
     cpy_result = result;
     for (i=0;i<=1;i++)
      {
      value = result % 16;
      result = result / 16;
      hexaformat (value);
      }
     result = cpy_result;
     }

    public void hexaformat (int result)
     {
     switch (result)
      {
      case 0:  hex_checksum += '0'; break;
      case 1:  hex_checksum += '1'; break;
      case 2:  hex_checksum += '2'; break;
      case 3:  hex_checksum += '3'; break;
      case 4:  hex_checksum += '4'; break;
      case 5:  hex_checksum += '5'; break;
      case 6:  hex_checksum += '6'; break;
      case 7:  hex_checksum += '7'; break;
      case 8:  hex_checksum += '8'; break;
      case 9:  hex_checksum += '9'; break;
      case 10: hex_checksum += 'A'; break;
      case 11: hex_checksum += 'B'; break;
      case 12: hex_checksum += 'C'; break;
      case 13: hex_checksum += 'D'; break;
      case 14: hex_checksum += 'E'; break;
      case 15: hex_checksum += 'F'; break;
      default: break;
      }
     }

    public void reverse_data_string ()
     {
     String s="";
     s += hex_checksum.substring (5,6);
     s += hex_checksum.substring (4,5);
     s += hex_checksum.substring (3,4);
     s += hex_checksum.substring (2,3);
     s += hex_checksum.substring (1,2);
     s += hex_checksum.substring (0,1);  
     hex_checksum = s;
     }

    public void reverse_string ()
     {
     String s="",s1="";
     s += hex_checksum.substring (1,2); 
     s += hex_checksum.substring (0,1);  
     hex_checksum = s;  
     }

    public void conv_dec_to_hex (long no_of_bytes)
     {
     long copy_bytes;
     int value;
     copy_bytes = no_of_bytes;
     hex_checksum="";
     for (int i=0;i<=5;i++)
      {
      value = (int)no_of_bytes % 16;
      no_of_bytes = no_of_bytes / 16;
      hexaformat (value);
      } 
     no_of_bytes = copy_bytes;
     } 

    public String get_filename ()
     {
     final JFileChooser fc = new JFileChooser ("Datafiles");
     String fname="";
     int returnval = fc.showOpenDialog (Aeon_PManager.this);
     if (returnval == JFileChooser.APPROVE_OPTION)
      {
             File file = fc.getSelectedFile();
      String s = file.getName ();
      fname = s;
                   }
     return fname;
     }  

    public static void main (String args[])
     {
     Aeon_PManager mpot = new Aeon_PManager ();
     }
    }

SimpleSerial.java

import java.io.; //import java.lang.; //import java.lang.ClassNotFoundException; /* Interface class for SimpleSerial.

If you don't know what an interface is, don't worry. An interface defines the functions that can be called by implementors of this class. Currently there are two implementors, SimpleSerialNative, and SimpleSerialJava. There might be more in the future.

SimpleSerialNative requires the file "SimpleSerialNative.dll" to be in the same folder as your Java project file. It's that simple.

SimpleSerialJava requires the correct installation of Sun's Javacomm communication package. It's much more powerful, but it can be tricky for the newcomer to configure, and use.

If you have problems with one, why don't you try the other.

A VERY SIMPLE IMPLEMENTATION:

public static void main(String args[]) { SimpleSerial ss; // delcare the SimpleSerial object

ss = new SimpleSerialNative(2);         // The argument is the commport number.  There is no Comm0.

ss.writeByte((byte)'a');                // write a byte to the serial port

// Give the PIC chip time to digest the byte to make sure it's ready for the next byte.
try { Thread.sleep(1); } catch (InterruptedException e) {}

ss.writeByte((byte)'!');                // write another byte to the serial port

String      inputString = ss.readString();      // read any string from the serial port
System.out.println("I read the string:  " + inputString);

}

A few important things to note:

  1. When you write data to the serial port, it just writes the data, whether or not the PIC chip is ready to receive data. There's no handshaking or signaling. If you send data and the PIC chip isn't ready for it, it will be ignored. Some PIC chips have a hardware UART which will buffer a few bytes of data for later retrieval. But this isn't a cure-all. If the buffer fills up, it creates an error condition which prevents further data from being read. You need to include custom PIC code to reset the error flag.

2 In contrast to the PIC chip, the computer has a rather large hardware buffer. If the PIC chip sends serial data to your computer when you're not around to read it, it gets stored.

  1. If you make a call to readByte(), and there's no data to be read, readByte() waits until there is data. If you want to know how much data (if any) is available, make a call to available().

  2. Conversely, if you make a call to readBytes() or readString() and there's no data to be read, readBytes() returns a byte array of zero length, and readString() returns and empty string.

  3. If you want to use Sun's JavaComm package instead of this code, subsitute your calls to new SimpleSerialNative(2);
    with new SImpleSerialJava(2);

*/

public interface SimpleSerial {

// These are copied right out of WINBASE.H
// Most applications should be fine with the defaults.

public static final int NOPARITY            = 0;
public static final int ODDPARITY           = 1;
public static final int EVENPARITY          = 2;
public static final int MARKPARITY          = 3;
public static final int SPACEPARITY         = 4;

public static final int ONESTOPBIT          = 0;
public static final int ONE5STOPBITS        = 1;
public static final int TWOSTOPBITS         = 2;

/*
Returns the number of bytes available at the time of this call.
It's possible there are more bytes by the time readByte() or
readBytes() is executed.  But there will never be fewer.
*/
public int available();

public void waitForData(int n);
public boolean writeString(String string);
/*
returns TRUE if port is fully operationsal
returns FALSE if there is a problem with the port
*/
public boolean isValid();

/*
Be sure to close your serial port when done.  Note that port is
automatically closed on exit if you don't close it yourself
*/
public void close();

/*
Reads a single byte from the input stream.
Return value will be from -128 to 127 (inclusive)
If no data at serial port, waits in routine for data to arrive.
Use available() to check how much data is available.
If error, returns 256.
*/
public int readByte();

/*
Reads all the bytes in the serial port.
If no bytes availble, returns array with zero elements. 
Never waits for data to arrive
*/
public byte[] readBytes();

/*
Reads bytes from serial port and converts to a text string.
DO NOT use this routine to read data.  Ch
+2  A: 
  • Locate which jar file has the class SimpleSerial.
  • Ensure that it's in your classpath when your run your program
talonx
A: 

Sounds like you have specified the wrong main class, should be Aeon_PManager

objects
A: 

Vedavathi,

I am getting similar error Exception in thread "javawsApplicationMain" java.lang.NoClassDefFoundError: org/apache/log4j/Appender ? did you figure is the solution?

thanks Dipen