Newsgroup: it.comp.java
Titolo: Programma compilato senza errori, ma non parte

Ringrazio tutti per la pazienza dimostrata. Grazie ai vostri aiuti sono
finalmente riuscito a compilare un programma d'esempio che era scritto su un
libero però quando provo ad eseguirlo mi da tanti errori che qua sotto vi
allego, e vi allego anche il programma.
Grazie.
java.lang.NoClassDefFoundError: flussi/CreateSequentialFile (wrong name:
CreateSequentialFile)
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
        at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
Exception in thread "main"
import flussi.pluto.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class CreateSequentialFile extends JFrame {
    private ObjectOutputStream output;
    private BankUI userInterface;
    private JButton enter, open;
    /** Creates a new instance of CreateSequentialFile */
    public CreateSequentialFile() {
        super ("Creating a Sequential File of Objects");
        getContentPane().setLayout(new BorderLayout());
        userInterface = new BankUI();
        enter=userInterface.getTask();
        enter.setText("Enter");
        enter.setEnabled(false);
        enter.addActionListener(new ActionListener(){
            public void actionPerformed (ActionEvent e){
                addRecord();
            }
        }
        );
        addWindowListener( new WindowAdapter(){
            public void windowClosing(WindowEvent e)
            {
                if(output!=null){
                    addRecord();
                    closeFile();
                }else
                    System.exit(0);
            }
        }
        );
        open=userInterface.getDoTask2();
        open.setText("Save As");
        open.addActionListener(
        new ActionListener(){
            public void actionPerformed(ActionEvent e){
                openFile();
            }
        }
        );
        getContentPane().add(userInterface, BorderLayout.CENTER);
        setSize(300, 200);
        show();
    }
    private void openFile(){
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        int result = fileChooser.showSaveDialog(this);
        if (result==JFileChooser.CANCEL_OPTION)
            return;
        File fileName = fileChooser.getSelectedFile();
        if(fileName==null || fileName.getName().equals(""))
            JOptionPane.showMessageDialog(this, "Invalid File Name",
"Invalid File Name", JOptionPane.ERROR_MESSAGE);
        else{
            try{
                output= new ObjectOutputStream( new
FileOutputStream(fileName));
                open.setEnabled(false);
                enter.setEnabled(true);
            }catch (IOException e){
                JOptionPane.showMessageDialog(this, "Error Opening File",
"Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    }
    private void closeFile(){
        try{
            output.close();
            System.exit(0);
        }catch (IOException ex){
            JOptionPane.showMessageDialog(this, "Error closing file",
"Error", JOptionPane.ERROR_MESSAGE);
            System.exit(1);
        }
    }
    public void addRecord(){
        int accountNumber=0;
        BankAccountRecord record;
        String fieldValues[]=userInterface.getFieldValues();
        if(!fieldValues[0].equals("")){
            try{
                accountNumber=Integer.parseInt(fieldValues[0]);
                if (accountNumber>0){
                    record = new BankAccountRecord(accountNumber,
fieldValues[1], fieldValues[2], Double.parseDouble(fieldValues[3]));
                    output.writeObject(record);
                    output.flush();
                }
            }catch (NumberFormatException nfe){
                JOptionPane.showMessageDialog(this, "Bad account number or
balance", "Invalid Number Format", JOptionPane.ERROR_MESSAGE);
            }catch (IOException io){
                closeFile();
            }
        }
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new CreateSequentialFile();
    }
}
Le classi conenute nel package flussi pluto sono:
package flussi.pluto;
import java.awt.*;
import javax.swing.*;
public class BankUI extends JPanel {
    protected final static String names[]={"Account number", "First name",
"Last name", "Balance"};
    protected JLabel labels[];
    protected JTextField fields[];
    protected JButton doTask, doTask2;
    protected JPanel innerPanelCenter, innerPanelSouth;
    protected int size=4;
    public static final int ACCOUNT=0, FIRST=1, LAST=2, BALANCE=3,
TRANSACTION=4;
    public BankUI() {
        this( 4 );
    }
    public BankUI(int mySize){
    size=mySize;
    labels =new JLabel[size];
    fields= new JTextField[size];
    for (int i=0; i<labels.length; i++)
        labels[i]=new JLabel(names[i]);
    for (int i=0; i<fields.length; i++)
        fields[i]=new JTextField();
    innerPanelCenter=new JPanel();
    innerPanelCenter.setLayout(new GridLayout(size, 2));
    for (int i=0; i<size; i++){
        innerPanelCenter.add(labels[i]);
        innerPanelCenter.add(fields[i]);
    }
    doTask=new JButton();
    doTask2=new JButton();
    innerPanelSouth= new JPanel();
    innerPanelSouth.add(doTask2);
    innerPanelSouth.add(doTask);
    setLayout(new BorderLayout());
    add(innerPanelCenter, BorderLayout.CENTER);
    add(innerPanelCenter, BorderLayout.SOUTH);
    validate();
    }
    public JButton getTask(){ return doTask; }
    public JButton getDoTask2(){ return doTask2; }
    public JTextField[] getFields(){ return fields; }
    public void clearFields(){
        for (int i=0; i<size; i++)
            fields[i].setText("");
    }
    public void setFieldValues(String s[]) throws IllegalArgumentException{
        if (s.length!=size)
            throw new IllegalArgumentException("There must be " + size + "
String in the array");
        for (int i=0; i<size; i++)
            fields[i].setText(s[i]);
    }
    public String[] getFieldValues(){
        String values[]=new String[size];
        for (int i=0; i<size; i++)
            values[i]=fields[i].getText();
        return values;
    }
}
/seconda classe
package flussi.pluto;
import java.io.Serializable;
public class BankAccountRecord implements Serializable {
    private int account;
    private String firstName;
    private String lastName;
    private double balance;
    /** Creates a new instance of BankAccountRecord */
    public BankAccountRecord() {
        this(0, "", "", 0.0);
    }
    public BankAccountRecord( int acct, String first, String last, double
bal){
        setAccount(acct);
        setFirstName(first);
        setLastName(last);
        setBalance(bal);
    }
    public void setAccount(int acct){
        account=acct;
    }
    public int getAccount(){
        return account;
    }
    public void setFirstName(String first){
        firstName=first;
    }
    public String getFirstName(){
        return firstName;
    }
    public void setLastName(String last){
        lastName=last;
    }
    public String getLastName(){
        return lastName;
    }
    public void setBalance(double bal){
        balance=bal;
    }
    public double getBalance(){
        return balance;
    }
}

 Grazie.
[CUT]
Bisognerebbe sapere da dove e come lo lanci.
Cmq a naso, prova a spostare CreateSequentialFile.class nella directory
superiore e lanciarlo da li con java CreateSequentialFile.
Inviato da 
www.mynewsgate.net

[CUT]
in sostanza dovresti avere una cosa così (sperando che venga):
C:\\prj
&#9474;   CreateSequentialFile$1.class
&#9474;   CreateSequentialFile$2.class
&#9474;   CreateSequentialFile$3.class
&#9474;   CreateSequentialFile.class
&#9474;   CreateSequentialFile.java
&#9474;
&#9492;&#9472;&#9472;&#9472;flussi
    &#9492;&#9472;&#9472;&#9472;pluto
            BankAccountRecord.class
            BankAccountRecord.java
            BankUI.class
            BankUI.java
Inviato da 
www.mynewsgate.net

(sperando che venga):
Per l'appunto. Riproviamo:
C:\\prj
|   CreateSequentialFile$1.class
|   CreateSequentialFile$2.class
|   CreateSequentialFile$3.class
|   CreateSequentialFile.class
|   CreateSequentialFile.java
|
\\---flussi
    \\---pluto


"gnazio" <8...@mynewsgate.ned.invalid> ha scritto nel messaggio
news:20031205...@mynewsgate.net...

Grazie tutto risolto, la vostra pazienza è stat infinita.