Newsgroup: it.comp.java
Titolo: Problemi con Netbeans

Ho acquistato un libro su Java. In questo libro ci sono vari esempi
che se apro con un editor come Ginipad e li elaborano funzionano bene.
Se li apro con Netbeans mi da in fase di run questo msg :
java.lang.NoClassDefFoundError: v2ch6/TreeEditTest/TreeEditTest (wrong
name: TreeEditTest)
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
        at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
        at
java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
        at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
        at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
Exception in thread "main"
Ecco un esempio di codice che ho lanciato, in fase di compilazione non
mi da errore:
/**
   @version 1.01 2001-07-17
   @author Cay Horstmann
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;
/**
   This program demonstrates tree editing.
*/
public class TreeEditTest
{  
   public static void main(String[] args)
   {  
      JFrame frame = new TreeEditFrame();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.show();
   }
}
/**
   A frame with a tree and buttons to edit the tree.
*/
class TreeEditFrame extends JFrame
{  
   public TreeEditFrame()
   {  
      setTitle("TreeEditTest");
      setSize(WIDTH, HEIGHT);
      // construct tree
      TreeNode root = makeSampleTree();
      model = new DefaultTreeModel(root);
      tree = new JTree(model);
      tree.setEditable(true);
      // add scroll pane with tree to content pane
      JScrollPane scrollPane = new JScrollPane(tree);
      getContentPane().add(scrollPane, BorderLayout.CENTER);
      makeButtons();
      // make button panel
   }
   public TreeNode makeSampleTree()
   {  
      DefaultMutableTreeNode root
         = new DefaultMutableTreeNode("World");
      DefaultMutableTreeNode country
         = new DefaultMutableTreeNode("USA");
      root.add(country);
      DefaultMutableTreeNode state
         = new DefaultMutableTreeNode("California");
      country.add(state);
      DefaultMutableTreeNode city
         = new DefaultMutableTreeNode("San Jose");
      state.add(city);
      city = new DefaultMutableTreeNode("Cupertino");
      state.add(city);
      state = new DefaultMutableTreeNode("Michigan");
      country.add(state);
      city = new DefaultMutableTreeNode("Ann Arbor");
      state.add(city);
      country = new DefaultMutableTreeNode("Germany");
      root.add(country);
      state = new DefaultMutableTreeNode("Schleswig-Holstein");
      country.add(state);
      city = new DefaultMutableTreeNode("Kiel");
      state.add(city);
      return root;
   }
   /**
      Makes the buttons to add a sibling, add a child, and
      delete a node.
   */
   public void makeButtons()
   {
      JPanel panel = new JPanel();
      JButton addSiblingButton = new JButton("Add Sibling");
      addSiblingButton.addActionListener(new
         ActionListener()
         {
            public void actionPerformed(ActionEvent event)
            {
               DefaultMutableTreeNode selectedNode
                  = (DefaultMutableTreeNode)
                  tree.getLastSelectedPathComponent();
               if (selectedNode == null) return;
               DefaultMutableTreeNode parent
                  = (DefaultMutableTreeNode)
                  selectedNode.getParent();
               if (parent == null) return;
               DefaultMutableTreeNode newNode
                  = new DefaultMutableTreeNode("New");
               int selectedIndex = parent.getIndex(selectedNode);
               model.insertNodeInto(newNode, parent,
                  selectedIndex + 1);
 
               // now display new node
 
               TreeNode[] nodes = model.getPathToRoot(newNode);
               TreePath path = new TreePath(nodes);
               tree.scrollPathToVisible(path);
            }
         });
      panel.add(addSiblingButton);
      JButton addChildButton = new JButton("Add Child");
      addChildButton.addActionListener(new
         ActionListener()
         {
            public void actionPerformed(ActionEvent event)
            {
               DefaultMutableTreeNode selectedNode
                  = (DefaultMutableTreeNode)
                  tree.getLastSelectedPathComponent();
               if (selectedNode == null) return;
               DefaultMutableTreeNode newNode
                  = new DefaultMutableTreeNode("New");
               model.insertNodeInto(newNode, selectedNode,
                  selectedNode.getChildCount());               
               // now display new node
 
               TreeNode[] nodes = model.getPathToRoot(newNode);
               TreePath path = new TreePath(nodes);
               tree.scrollPathToVisible(path);
            }
         });
      panel.add(addChildButton);
      JButton deleteButton = new JButton("Delete");
      deleteButton.addActionListener(new
         ActionListener()
         {
            public void actionPerformed(ActionEvent event)
            {
               DefaultMutableTreeNode selectedNode
                  = (DefaultMutableTreeNode)
                  tree.getLastSelectedPathComponent();
               if (selectedNode != null && 
                  selectedNode.getParent() != null)
                  model.removeNodeFromParent(selectedNode);
            }
         });
      panel.add(deleteButton);
      getContentPane().add(panel, BorderLayout.SOUTH);
   }
   private DefaultTreeModel model;
   private JTree tree;
   private static final int WIDTH = 400;
   private static final int HEIGHT = 200;
}
cosa devo fare?
Grazie

Vero che non hai montato la directory v2ch6, ma una sua sub directory?
Le directory in nb sono come i packages.
Ps. se non l'hai ancora fatto prova la versione 3.4 rc2, la trovo 
formidabile!
Ciao,
    kiuma