Test Foro de elhacker.net SMF 2.1

Programación => Programación General => Java => Mensaje iniciado por: Meta en 6 Marzo 2015, 06:25 AM

Título: Encontrar motivos de fallos sobre código Java.
Publicado por: Meta en 6 Marzo 2015, 06:25 AM
Hola:

Tengo un código medio hecho en el cual no se el motivo de los fallos. Se trata de encender y apagar un Led con Netbeans 8 en mi caso y Arduino.

Código (java) [Seleccionar]

import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import java.io.OutputStream;
import java.util.Enumeration;
import javax.swing.JOptionPane;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author Meta
*/
public class JAVADUINO_JFrame extends javax.swing.JFrame {

   /**
    * Creates new form JAVADUINO_JFrame
    */
   
   private static final String L8ON = "Led_8_ON";
   private static final String L8OFF = "Led_8_OFF";
   
   // Variables de conexión.
   private final OutputStream output = null;
   SerialPort serialPort;
   private final String PUERTO = "COM4";
   
   private static final int TIMEOUT = 2000;
   
   private static final int DATA_RATE = 115200;
   
   public JAVADUINO_JFrame() {
       initComponents();
       inicializarConexion();
   }

   public final void inicializarConexion(){
       CommPortIdentifier puertoID = null;
       Enumeration puertoEnum = CommPortIdentifier.getPortIdentifiers();
       
       while(puertoEnum.hasMoreElements()){
           CommPortIdentifier actualPuertoID = (CommPortIdentifier) puertoEnum.nextElement();
           if (PUERTO.equals(actualPuertoID.getName())){
               puertoID = actualPuertoID;
               break;
           }
       }
   }
   
   if (puertoID == null){
   mostrarError("No se puede conectar al puerto.");
   System.exit(ERROR);
}
   
   try{
       serialPort = (SerialPort) puertoID.open(this.getClass().getName(), TIMEOUT);
       // Parámetros puerto serie.
       serialPort.setSerialPortParams(DATA_RATE, SerialPort.DATABITS_8, SerialPort.STOPBITS_2, SerialPort.PARITY_NONE);
       output = serialPort.getOutputStream();
}
   catch (Exception e){
   mostrarError(e.getMessage());
   System.exit(ERROR);
}

   private void enviarDatos(String datos){
       try{
           output.write(datos.getBytes());
       }
       catch(Exception e){
           mostrarError("ERROR");
           System.exit(ERROR);
       }
   }
   
   public void mostrarError(String mensaje){
       JOptionPane.showMessageDialog(this, mensaje, "ERROR", JOptionPane.ERROR_MESSAGE);
       
   }
   /**
    * 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() {

       jButton1 = new javax.swing.JButton();
       jButton2 = new javax.swing.JButton();

       setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

       jButton1.setText("ON");

       jButton2.setText("OFF");

       javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
       getContentPane().setLayout(layout);
       layout.setHorizontalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(layout.createSequentialGroup()
               .addGap(21, 21, 21)
               .addComponent(jButton1)
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 101, Short.MAX_VALUE)
               .addComponent(jButton2)
               .addGap(45, 45, 45))
       );
       layout.setVerticalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
               .addContainerGap(250, Short.MAX_VALUE)
               .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                   .addComponent(jButton1)
                   .addComponent(jButton2))
               .addGap(27, 27, 27))
       );

       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(JAVADUINO_JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
       } catch (InstantiationException ex) {
           java.util.logging.Logger.getLogger(JAVADUINO_JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
       } catch (IllegalAccessException ex) {
           java.util.logging.Logger.getLogger(JAVADUINO_JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
       } catch (javax.swing.UnsupportedLookAndFeelException ex) {
           java.util.logging.Logger.getLogger(JAVADUINO_JFrame.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 JAVADUINO_JFrame().setVisible(true);
           }
       });
   }

   // Variables declaration - do not modify                    
   private javax.swing.JButton jButton1;
   private javax.swing.JButton jButton2;
   // End of variables declaration                  

   private void mostrarError(String no_se_puede_conectar_al_puerto) {
       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
   }
}


Todavía no he programado los botones, hay que acabar con los fallos primero. Los mensajes que me dan son estos.
Citarrun:
java.lang.ClassFormatError: Duplicate field name&signature in class file JAVADUINO_JFrame
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
   at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
   at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
   at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
   at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

He segudio los tutoriales hasta el minuto 37':30" de este vídeo.
https://www.youtube.com/watch?v=4Hr_LZ62SdY

¿Alguna idea?

Saludos.
Título: Re: Encontrar motivos de fallos sobre código Java.
Publicado por: Usuario Invitado en 6 Marzo 2015, 13:00 PM
ClassFormatException se lanza cuando el compilador no ha podido identificar dicho código como una clase. Pueden ser múltiples los problemas, desde interfaces mal implementadas, o clases mal anotadas, etc.

Me causa asombro, que NetBeans no te corrija esto:

Código (java) [Seleccionar]
public final void inicializarConexion(){
CommPortIdentifier puertoID = null;
Enumeration puertoEnum = CommPortIdentifier.getPortIdentifiers();

while(puertoEnum.hasMoreElements()){
CommPortIdentifier actualPuertoID = (CommPortIdentifier) puertoEnum.nextElement();
if (PUERTO.equals(actualPuertoID.getName())){
puertoID = actualPuertoID;
break;

}

}

} // aquí has cerrado el método inicilizarConexion(), por lo no podría
// si quiera compilar el if debajo ni el try-catch.
if (puertoID == null){
mostrarError("No se puede conectar al puerto.");
System.exit(ERROR);
}


En la línea 15 como puedes ver has cerrado el método inicializarConexión. Toda instrucción a no ser que sea una declaración o un bloque estático, debe hacerse dentro de un método o constructor. No se pueden escribir instrucciones sin algún método que los englobe. Por eso, me parece raro en sobremanera que NetBeans no te marque en rojo lo que hay debajo del método.
Título: Re: Encontrar motivos de fallos sobre código Java.
Publicado por: Meta en 6 Marzo 2015, 14:23 PM
Hola:

Código (java) [Seleccionar]
/*
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import java.io.OutputStream;
import java.util.Enumeration;
import javax.swing.JOptionPane;
*/

import java.io.OutputStream;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import java.util.Enumeration;
import javax.swing.JOptionPane;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author Meta
*/
public class JAVADUINO_JFrame extends javax.swing.JFrame {

    /**
     * Creates new form JAVADUINO_JFrame
     */
   
    private static final String L8ON = "Led_8_ON";
    private static final String L8OFF = "Led_8_OFF";
   
    // Variables de conexión.
    private final OutputStream output = null;
    SerialPort serialPort;
    private final String PUERTO = "COM4";
   
    private static final int TIMEOUT = 2000;
   
    private static final int DATA_RATE = 115200;
   
    public JAVADUINO_JFrame() {
        initComponents();
        inicializarConexion();
    }

    public final void inicializarConexion(){
        CommPortIdentifier puertoID = null;
        Enumeration puertoEnum = CommPortIdentifier.getPortIdentifiers();
       
        while(puertoEnum.hasMoreElements()){
            CommPortIdentifier actualPuertoID = (CommPortIdentifier) puertoEnum.nextElement();
            if (PUERTO.equals(actualPuertoID.getName())){
                puertoID = actualPuertoID;
                break;
            }
        }
       
            if (puertoID == null){
    mostrarError("No se puede conectar al puerto.");
    System.exit(ERROR);
}
   
    try{
        serialPort = (SerialPort) puertoID.open(this.getClass().getName(), TIMEOUT);
        // Parámetros puerto serie.
        serialPort.setSerialPortParams(DATA_RATE, SerialPort.DATABITS_8, SerialPort.STOPBITS_2, SerialPort.PARITY_NONE);
        output = serialPort.getOutputStream();
}
    catch (Exception e){
    mostrarError(e.getMessage());
    System.exit(ERROR);
}
    }
   

    private void enviarDatos(String datos){
        try{
            output.write(datos.getBytes());
        }
        catch(Exception e){
            mostrarError("ERROR");
            System.exit(ERROR);
        }
    }
   
    public void mostrarError(String mensaje){
        JOptionPane.showMessageDialog(this, mensaje, "ERROR", JOptionPane.ERROR_MESSAGE);
       
    }
    /**
     * 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() {

        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jButton1.setText("ON");

        jButton2.setText("OFF");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addComponent(jButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 101, Short.MAX_VALUE)
                .addComponent(jButton2)
                .addGap(45, 45, 45))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(250, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2))
                .addGap(27, 27, 27))
        );

        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(JAVADUINO_JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(JAVADUINO_JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(JAVADUINO_JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(JAVADUINO_JFrame.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 JAVADUINO_JFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    // End of variables declaration                   

    private void mostrarError(String no_se_puede_conectar_al_puerto) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}


Me sale este error.
Citarrun:
java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: Uncompilable source code - method mostrarError(java.lang.String) is already defined in class JAVADUINO_JFrame
   at JAVADUINO_JFrame.<clinit>(JAVADUINO_JFrame.java:174)
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

Saludos.
Título: Re: Encontrar motivos de fallos sobre código Java.
Publicado por: Usuario Invitado en 6 Marzo 2015, 15:48 PM
Aquí está tu error:

CitarCaused by: java.lang.RuntimeException: Uncompilable source code - method mostrarError(java.lang.String) is already defined in class JAVADUINO_JFrame

Traducido:

Método mostrarError(java.lang.String) está actualmente definido en la clase JAVADUINO_JFrame.

Cuando haces sobrecarga es necesario hacer cualquier de las siguientes cosas:

Título: Re: Encontrar motivos de fallos sobre código Java.
Publicado por: Meta en 6 Marzo 2015, 16:27 PM
Hola:

Uso netbeans 8.0.2 en español.

Mirando el código lo he hecho otra vez desde cero.
Código (java) [Seleccionar]

import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import java.io.OutputStream;
import java.util.Enumeration;
import javax.swing.JOptionPane;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author Meta
*/
public class JAVADUINO_Frame extends javax.swing.JFrame {

    /**
     * Creates new form JAVADUINO_Frame
     */
   
    private static final String L8on = "Led_8_ON";
    private static final String L8off = "Led_8_OFF";
   
    // Variables de conexión.
    private OutputStream output = null;
    SerialPort serialPort;
    private final String PUERTO = "COM4";
   
    private static final int TIMEOUT = 2000; // 2 segundos.
   
    private static final int DATA_RATE = 115200; // Baudios.
   
    public JAVADUINO_Frame() {
        initComponents();
        inicializarConexion();
    }
   
    public void inicializarConexion(){
        CommPortIdentifier puertoID = null;
        Enumeration puertoEnum = CommPortIdentifier.getPortIdentifiers();
       
        while (puertoEnum.hasMoreElements()){
            CommPortIdentifier actualPuertoID = (CommPortIdentifier) puertoEnum.nextElement();
            if (PUERTO.equals(actualPuertoID.getName())){
                puertoID = actualPuertoID;
                break;
            }
        }
       
        if (puertoID == null){
            mostrarError("No se puede conectar al puerto");
            System.exit(ERROR);
        }
       
        try{
            serialPort = (SerialPort) puertoID.open(this.getClass().getName(), TIMEOUT);
            // Parámatros puerto serie.
           
            serialPort.setSerialPortParams(DATA_RATE, SerialPort.DATABITS_8, SerialPort.STOPBITS_2, SerialPort.PARITY_NONE);
           
            output = serialPort.getOutputStream();
        } catch (Exception e){
            mostrarError(e.getMessage());
            System.exit(ERROR);
        }
    }
   
    private void enviarDatos(String datos){
        try{
            output.write(datos.getBytes());
        } catch (Exception e){
            mostrarError("ERROR");
            System.exit(ERROR);
        }
    }
   
    public void mostrarError(String mensaje){
        JOptionPane.showMessageDialog(this, mensaje, "ERROR", JOptionPane.ERROR_MESSAGE);   
    }
    /**
     * 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() {

        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jButton1.setText("ON");

        jButton2.setText("OFF");

        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()
                .addComponent(jButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 99, Short.MAX_VALUE)
                .addComponent(jButton2)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(92, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2))
                .addGap(26, 26, 26))
        );

        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(JAVADUINO_Frame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(JAVADUINO_Frame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(JAVADUINO_Frame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(JAVADUINO_Frame.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 JAVADUINO_Frame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    // End of variables declaration                   
}



Uso Windows 7 de 64 bits.

Me sle este error.
Citarrun:
java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path
   at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1865)
   at java.lang.Runtime.loadLibrary0(Runtime.java:870)
   at java.lang.System.loadLibrary(System.java:1119)
   at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:83)
   at JAVADUINO_Frame.inicializarConexion(JAVADUINO_Frame.java:43)
   at JAVADUINO_Frame.<init>(JAVADUINO_Frame.java:38)
   at JAVADUINO_Frame$1.run(JAVADUINO_Frame.java:155)
   at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
   at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:749)
   at java.awt.EventQueue.access$500(EventQueue.java:97)
   at java.awt.EventQueue$3.run(EventQueue.java:702)
   at java.awt.EventQueue$3.run(EventQueue.java:696)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:719)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
   at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

El que más me llama la ateción es este:
Citarjava.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path

Saludos.
Título: Re: Encontrar motivos de fallos sobre código Java.
Publicado por: Usuario Invitado en 6 Marzo 2015, 16:46 PM
Creo que no está encontrando las dll. Intenta lo siguiente:

Título: Re: Encontrar motivos de fallos sobre código Java.
Publicado por: Meta en 6 Marzo 2015, 17:28 PM
Lo puse así:

Citar-Djava.library.path="C:\Program Files (x86)\Java\jre1.8.0_40\bin"

Me aparece esto:
Citarrun:
java.lang.UnsatisfiedLinkError: C:\Program Files (x86)\Java\jre1.8.0_40\bin\rxtxSerial.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform thrown while loading gnu.io.RXTXCommDriver
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: C:\Program Files (x86)\Java\jre1.8.0_40\bin\rxtxSerial.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform

También puse esto:
Citar-Djava.library.path="C:\Program Files\Java\jre1.8.0_31\bin\rxtxSerial.dll"

Nombrando la dll y todo pero sigue con elmismo mensaje.
Título: Re: Encontrar motivos de fallos sobre código Java.
Publicado por: Usuario Invitado en 6 Marzo 2015, 17:45 PM
Si usas Java de 64 bits debes recompilar dicha biblioteca a 64 bits o puedes instalar la JVM de 32 bits.
Título: Re: Encontrar motivos de fallos sobre código Java.
Publicado por: Meta en 6 Marzo 2015, 17:57 PM
Por lo que veo, mejor usar todo a 32 bits.

Lo instalaré todo a 32 bits por si acaso, a lo mejor es más cómodo y rápido.

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

https://netbeans.org/downloads/8.0.1/

Desinstalé todo a 64 bits e instalé todo a 32 bits en Windows de 64 bits a ver que pasa. En este momento estoy descargando la última versión y a 32 bits, luego comento.

Saludos.
Título: Re: Encontrar motivos de fallos sobre código Java.
Publicado por: Meta en 6 Marzo 2015, 18:56 PM
Ya me ejecuta, lo instaré todo a 32 bits.

https://www.youtube.com/watch?v=JAwCa4Uk6tA

Estoy haciendo un buen tutorial sobre puerto serie con Visual Studio y Java.

(https://social.msdn.microsoft.com/Forums/getfile/616372)

Si quieres te envío en pdf hasta donde he llegado.

Muchísimas gracias por la ayuda.
Título: Re: Encontrar motivos de fallos sobre código Java.
Publicado por: Usuario Invitado en 6 Marzo 2015, 19:56 PM
Wow, se ve muy bueno ^^, claro envíame el PDF como que lo sigo con el tuto.

Saludos.
Título: Re: Encontrar motivos de fallos sobre código Java.
Publicado por: Meta en 6 Marzo 2015, 20:25 PM
Hola:

Claro que si, me envías tu correo y te lo paso a PDF, me falta muchos temas por acabar. Java recibir datos de texto que es lo que quiero hacer desde ya, VB 6. y todo referente a la electrónica que aúnno he acabado.

También lo mismo pero en modo consola, hay gente que lo quiere así y con todos los lenguajes. ;)

En otro manual, con Linux y Java y puede hasya con monodevelop C#, cosas así. Repito para que se entienda, me falta esquemas de electrónica que pondré poco a poco y bien explicado y algunos vídeos, por ahora solo tengo este.

[youtube=640,360]https://www.youtube.com/watch?v=g7XPhDL6auA[/youtube]


Mi correo es metacontaARROBAgmail com.

Saludos.
Título: Re: Encontrar motivos de fallos sobre código Java.
Publicado por: Usuario Invitado en 6 Marzo 2015, 20:33 PM
Vale, gracias. Creo que te he encontrado en Skype, no se tendrás esa cuenta activa. De todos modos, coordinamos por MP.

Un saludo!
Título: Re: Encontrar motivos de fallos sobre código Java.
Publicado por: Meta en 6 Marzo 2015, 20:41 PM
Te he enviado MP.