JOptionPane broken on Netbeans 8.2

114 Views Asked by At

I am a programming student in Spain, lately we've been learning about file input and output with objects, recently we've been developing a small program that asks for some data, writes it into a file and shows everything the file contains using JOptionPane.

My problem is that my JOptionPane seems to literally not work, program just stops there, doesn't throw any exception, doesn't follow up...

I've tried it in the computer of a friend and it works there, also asked my teacher but he is clueless, any ideas on what's going on?

Main class:

public class Main {

    
    public static void main(String[] args) {
        System.out.println("Introduce la matricula del vehículo");
        String matricula = pideInput();
        System.out.println("Introduce la marca del vehículo");
        String marca = pideInput();
        System.out.println("Introduce el tamaño del deposito del vehículo");
        Double tamDeposito = pideNum();
        System.out.println("Introduce el modelo del vehículo");
        String modelo = pideInput();
        try {
            MiObjectOutputStream escritor = new MiObjectOutputStream(new FileOutputStream("D:\\vehiculos.dat",true));
            escritor.writeObject(new Vehiculo(matricula,marca,tamDeposito,modelo));
            escritor.close();
            escritor.flush();
            MiObjectInputStream lector = new MiObjectInputStream(new FileInputStream("D:\\vehiculos.dat"));
            try{
            
                while(true){
                    Vehiculo v;
                    v = (Vehiculo) lector.readObject();
                    String desc = v.toString();
                    JOptionPane.showMessageDialog(null, desc);
                    System.out.println(desc);
                }   
            }
            catch (ClassNotFoundException ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            }catch (EOFException ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            }
            lector.close();
        } catch (IOException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SecurityException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
        
    }
    
    
    private static double pideNum(){
        Scanner lector = new Scanner(System.in);
        double input = -1;
        try{
            input = lector.nextDouble();
        }catch(java.util.InputMismatchException e){
            System.out.println("Error, se debe introducir un número adecuado");
            return pideNum();
        }
        return input;
    }
    
    private static String pideInput(){
        Scanner lector = new Scanner(System.in);
        return lector.nextLine();
    }
}

Vehicle class:

public class Vehiculo implements Serializable{
    String matricula;
    String marca;
    String modelo;
    double tamDeposito;
    public Vehiculo(String matricula, String marca, double tamDeposito, String modelo) {
        this.matricula = matricula;
        this.marca = marca;
        this.tamDeposito = tamDeposito;
        this.modelo = modelo;
    }
    @Override
    public String toString() {
        return "Vehiculo{" + "matricula=" + matricula + ", marca=" + marca + ", modelo=" + modelo + ", tamDeposito=" + tamDeposito + '}';
    }
}

Custom stream:

public class MiObjectOutputStream extends ObjectOutputStream {
    public MiObjectOutputStream(OutputStream out) throws IOException {
        super(out);
    }
    public MiObjectOutputStream() throws IOException, SecurityException {
        super();
    }
    @Override
    protected void writeStreamHeader(){
        //Fumate un petardo
    } 
}

The custom ObjectInputStream is mostly the same as the output one, only differences are that it extends ObjectInputStream, uses InputStream as a param in the constructor and Overrides readStreamHeader() instead of writeStreamHeader().

Edit: tried uninstalling, error popped up and cant uninstall, it seems some netbeans process is still open, nothing on task manager tho.

running uninstallation logic NameResolver - to parse C:\Program Files\NetBeans 8.2 [2System.getProperty(netbeans.default_userdir_root): C:\Users\Alumno\AppData\Roaming\NetBeans System.getProperty(netbeans.default_userdir_root): C:\Users\Alumno\AppData\Roaming\NetBeans It appears that the following instance of the NetBeans IDE is still running: C:\Program Files\NetBeans 8.2 A lock file exists at C:\Users\Alumno\AppData\Roaming\NetBeans\8.2\lock Please close this NetBeans IDE prior to continuing with uninstallation. show message dialog title: Critical Error message: It appears that the following instance of the NetBeans IDE is still running: C:\Program Files\NetBeans 8.2 A lock file exists at C:\Users\Alumno\AppData\Roaming\NetBeans\8.2\lock Please close this NetBeans IDE prior to continuing with uninstallation.

0

There are 0 best solutions below