繁体   English   中英

当我启动Web Start应用程序时,出现以下错误。 请帮我

[英]When I launch an web start application i am geteng the following error. Please help me

启动应用程序时遇到以下错误。 线程“ javaWSApplicationMain”中的异常java.lang.NoClassDefFoundError:SimpleSerail。

我正在使用的Java代码如下:

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

导入java.io。 ; //导入java.lang。 ; //导入java.lang.ClassNotFoundException; / * SimpleSerial的接口类。

如果您不知道接口是什么,请不要担心。 接口定义可由此类的实现者调用的函数。 当前有两个实现程序,SimpleSerialNative和SimpleSerialJava。 将来可能还会有更多。

SimpleSerialNative要求文件“ SimpleSerialNative.dll”与Java项目文件位于同一文件夹中。 就这么简单。

SimpleSerialJava需要正确安装Sun的Javacomm通信软件包。 它功能强大得多,但是对于新手来说,配置和使用它可能会很棘手。

如果您有一个问题,为什么不尝试另一个。

一个非常简单的实现:

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

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);

}

需要注意的一些重要事项:

  1. 当您将数据写入串行端口时,无论PIC芯片是否准备好接收数据,它都只会写入数据。 没有握手或信号。 如果发送数据而PIC芯片尚未准备好,它将被忽略。 某些PIC芯片具有硬件UART,它将缓冲一些字节的数据以供以后检索。 但这不是万能的。 如果缓冲区已满,它将创建一个错误条件,阻止进一步的数据读取。 您需要包括自定义PIC代码以重置错误标志。

2与PIC芯片相比,计算机具有相当大的硬件缓冲区。 如果PIC芯片在您不需要读取串行数据时将其发送到您的计算机,则该数据将被存储。

  1. 如果调用readByte(),并且没有要读取的数据,则readByte()会等到有数据为止。 如果您想知道有多少数据(如果有),请调用available()。

  2. 相反,如果调用readBytes()或readString()且没有要读取的数据,则readBytes()返回长度为零的字节数组,而readString()返回且为空字符串。

  3. 如果要使用Sun的JavaComm软件包而不是此代码,请替换对新SimpleSerialNative(2)的调用;
    带有新的SImpleSerialJava(2);

* /

公共接口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
  • 找到哪个jar文件具有类SimpleSerial。
  • 运行程序时,确保它在类路径中

听起来您指定了错误的主类,应该是Aeon_PManager

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM