Java Question error to create a librarie

charro98120165

Member
Licensed User
Longtime User
im try to cread a librarie but i get an error

javadoc: error - No packages or classes specified.
usage: javadoc [options] [packagenames] [sourcefiles] [@files]
-overview <file> Read overview documentation from HTML file
-public Show only public classes and members
-protected Show protected/public classes and members (default)
-package Show package/protected/public classes and members
-private Show all classes and members
-help Display command line options and exit
-doclet <class> Generate output via alternate doclet
-docletpath <path> Specify where to find doclet class files
-sourcepath <pathlist> Specify where to find source files
-classpath <pathlist> Specify where to find user class files
-exclude <pkglist> Specify a list of packages to exclude
-subpackages <subpkglist> Specify subpackages to recursively load
-breakiterator Compute 1st sentence with BreakIterator
-bootclasspath <pathlist> Override location of class files loaded
by the bootstrap class loader
-source <release> Provide source compatibility with specified release
-extdirs <dirlist> Override location of installed extensions
-verbose Output messages about what Javadoc is doing
-locale <name> Locale to be used, e.g. en_US or en_US_WIN
-encoding <name> Source file encoding name
-quiet Do not display status messages
-J<flag> Pass <flag> directly to the runtime system
-X Print a synopsis of nonstandard options

1 error

help plis
 

charro98120165

Member
Licensed User
Longtime User
1.- I try to creat a librarie with this code
i want to put a string in a men variable and return the variable s1
how I do this?

2.-im try to cread a librarie but i get the same error.
javadoc: error - No packages or classes specified.

help me plis

B4X:
package anywheresoftware.b4a.sample;


import java.io.*;
import java.net.*;
import java.security.*;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
import javax.crypto.*;
import javax.crypto.spec.DESKeySpec;
import javax.swing.JOptionPane;
import sun.net.util.IPAddressUtil;



public class libconexion extends javax.swing.JFrame {
    

    //Variables de la EncryptaciOn
    private static final String UNICODE_FORMAT = "UTF8";
    public static final String DES_ENCRYPTION_SCHEME = "DES";
    private KeySpec myKeySpec;
    private SecretKeyFactory mySecretKeyFactory;
    private Cipher cipher;
    byte[] keyAsBytes;
    private String myEncryptionKey;
    private String myEncryptionScheme;
    SecretKey key;
    public String men;
    //Titulo Mensajes
    private String sTitulo = "CONEXION";
    
    /**
     * Creates new form JFrameConexion
     */
    public libconexion() {
        initComponents();

        DataOutputStream salida;
        Socket cliente;
        //Asigna Valores a la Variables de encry-desencry
        try {
            //LLave de encriptacion "(=Lo78&@"
            myEncryptionKey = "(=Lo78&@";
            myEncryptionScheme = DES_ENCRYPTION_SCHEME;
            keyAsBytes = myEncryptionKey.getBytes(UNICODE_FORMAT);
            myKeySpec = new DESKeySpec(keyAsBytes);
            mySecretKeyFactory = SecretKeyFactory.getInstance(myEncryptionScheme);
            cipher = Cipher.getInstance(myEncryptionScheme);
            key = mySecretKeyFactory.generateSecret(myKeySpec);
        } catch (InvalidKeySpecException ex) {
            muestraMensaje(ex.getMessage());
        } catch (NoSuchPaddingException ex) {
            muestraMensaje(ex.getMessage());
        } catch (NoSuchAlgorithmException ex) {
            muestraMensaje(ex.getMessage());
        } catch (InvalidKeyException ex) {
            muestraMensaje(ex.getMessage());
        } catch (UnsupportedEncodingException ex) {
            muestraMensaje(ex.getMessage());
        }


        try {
            try {
                //Declaro la cadena sin la longitud, tampoco lleva la bandera que indica si se encripta o no
                //eso se hace en los siguiente pasos
                
                byte mensaje[] = encrypt(men);  //'("1:1;2:1;3:APSERVER;4:00-14-5E-87-51-4B;5:ADMIN;6:VT;7:123;8:20130419;9:172357;10:3314954025;11:5000");
                //'Indica que el mensaje si va encriptado
                byte encriptar[] = "S".getBytes();
                //Se obtiene el socket
                cliente = new Socket(InetAddress.getByName("192.168.1.66"), 9003);
                //Longitud del arrbyte del mensaje despuEs de Encryptar
                Integer iLengMensaje = mensaje.length;
                byte SendBytesLongitud[] = IPAddressUtil.textToNumericFormatV4(iLengMensaje.toString());
                //Se crea el wraper que contiene la info a enviar    
                salida = new DataOutputStream(cliente.getOutputStream());
                //envIa primero la longitude la cadena    
                salida.write(SendBytesLongitud, 0, SendBytesLongitud.length);
                salida.flush();
                //enviar si hay que encriptar
                salida.write(encriptar, 0, encriptar.length);
                salida.flush();
                //una vez enviada la longitud, envIo la cadena
                salida.write(mensaje, 0, mensaje.length);
                salida.flush();
                //Se resive la respuesta del servidor
                InputStream in = cliente.getInputStream();
                DataInputStream dis = new DataInputStream(in);
                //Se obtiene en un arr de byte la respuesta del servidor
                int len = dis.readInt();
                byte[] data = new byte[len];
                if (len > 0) {
                    dis.readFully(data);
                }
                //Se desencrypta la respuesta que esta en el arr de byte
                String s1 = decrypt(data);
                //se muestra mensaje segUn respuesta
                if (s1.contains("91:0")) {
                    muestraMensaje("Recarga exitosa.");
                } else {
                    muestraMensaje("recarga NO exitosa");
                }
                //Se muestra la respuesta    
                jTextAreaMensage.setText(s1 + "\n");
                //Se cierran todosl los wrapper y el socket
                dis.close();
                in.close();
                salida.close();
                cliente.close();
            } catch (UnknownHostException ex) {
                muestraMensaje(ex.getMessage());
            } catch (IOException ex) {
                muestraMensaje(ex.getMessage());
            }
        } catch (Exception ex) {
            muestraMensaje(ex.getMessage());
        }


    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTextAreaMensage = new javax.swing.JTextArea();
        jForTextFieldIP = new javax.swing.JFormattedTextField();
        jForTextFieldPuerto = new javax.swing.JFormattedTextField();
        jLabelPuerto = new javax.swing.JLabel();
        jLabelHost = new javax.swing.JLabel();
        jButtonAcept = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("CONEXION");

        jTextAreaMensage.setColumns(20);
        jTextAreaMensage.setRows(5);
        jTextAreaMensage.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
        jScrollPane1.setViewportView(jTextAreaMensage);

        try {
            jForTextFieldPuerto.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        jLabelPuerto.setText("Puerto:");

        jLabelHost.setText("Host:");

        jButtonAcept.setText("Aceptar");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabelHost)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jForTextFieldIP, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 41, Short.MAX_VALUE)
                        .addComponent(jLabelPuerto)
                        .addGap(35, 35, 35)
                        .addComponent(jForTextFieldPuerto, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(65, 65, 65)
                        .addComponent(jButtonAcept)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelHost)
                    .addComponent(jForTextFieldIP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelPuerto)
                    .addComponent(jForTextFieldPuerto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonAcept))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                        

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(libconexion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(libconexion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(libconexion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(libconexion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new libconexion().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                     
    private javax.swing.JButton jButtonAcept;
    private javax.swing.JFormattedTextField jForTextFieldIP;
    private javax.swing.JFormattedTextField jForTextFieldPuerto;
    private javax.swing.JLabel jLabelHost;
    private javax.swing.JLabel jLabelPuerto;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextAreaMensage;
    // End of variables declaration                   

    /**
     * Método para encryptar un string, retornando un arreglo de byte
     */
    public byte[] encrypt(String sTextoToEncry) throws Exception {
        byte[] respuesta = null;
            cipher.init(Cipher.ENCRYPT_MODE, key);
            byte[] plainText = sTextoToEncry.getBytes(UNICODE_FORMAT);
            respuesta = cipher.doFinal(plainText,0,plainText.length);
        return respuesta;
    }  
    
     /**
     * Método encargado de recivir un arreglo de byte representando un string encriptado,
     * y devuelve el string desencryptado
     */
    public String decrypt(byte arrByte[])throws Exception  {
        String sRespuesta=null;
            cipher.init(Cipher.DECRYPT_MODE, key);
            byte[] textoEnArrByte = cipher.doFinal(arrByte);
            sRespuesta= bytesToString(textoEnArrByte);
        return sRespuesta;
    }
    
    /**
     * Convierte un arreglo de byte en un string
     */
    private static String bytesToString(byte[] bytes) {
        StringBuilder stringBuffer = new StringBuilder();
        for (int i = 0; i < bytes.length; i++) {
            stringBuffer.append((char) bytes[i]);
        }
        return stringBuffer.toString();
    }

    /**
     * Muestra un mensaje
     * @param sTextoMensaje: Texto del mensaje 
     */
    private void muestraMensaje(String sTextoMensaje) {
        JOptionPane.showMessageDialog(this, sTextoMensaje, sTitulo, JOptionPane.INFORMATION_MESSAGE);
    }
}
 
Top