Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.lang.NoClassDefFoundError:_Java_Eclipse - Fatal编程技术网

java.lang.NoClassDefFoundError:

java.lang.NoClassDefFoundError:,java,eclipse,Java,Eclipse,我有一个新的错误,代码如下。最初我有一些被命名为不同的类。我改变了它们,但出现了新的错误。下面的代码将无法正确运行,因为我必须删除其中的一些代码。它有太多的字符。希望我没有扔掉需要修理的部件 import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.*; import java.io.*; import java.text.SimpleDateFormat; import java.tex

我有一个新的错误,代码如下。最初我有一些被命名为不同的类。我改变了它们,但出现了新的错误。下面的代码将无法正确运行,因为我必须删除其中的一些代码。它有太多的字符。希望我没有扔掉需要修理的部件

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import java.text.SimpleDateFormat;
import java.text.DecimalFormat;
import javax.swing.ButtonGroup;
import java.awt.FlowLayout;

public class VolCalc extends JFrame implements ActionListener{ 
    private JTabbedPane jtabbedPane; 
    private JPanel general; 
    private JPanel pools; 

    private JPanel tempCalc; 
    private JPanel options; 
    private JPanel hotTub; 
    private JComponent date; 
    JTextField lengthText, widthText, depthText, volumeText; 

    public void CalcVolume(){

        JPanel customers = new JPanel();

        setTitle("Pools"); 
        setSize(300, 200); 

        JPanel topPanel = new JPanel(); 
        topPanel.setLayout( new BorderLayout() ); 
        getContentPane().add( topPanel ); 

        createGeneral(); 
        createPools(); 
        createOptions(); 

        jtabbedPane = new JTabbedPane(); 
        jtabbedPane.addTab("General", general); 
        jtabbedPane.addTab("Pools", pools); 

        jtabbedPane.addTab("Temp Calculator", tempCalc); 
        jtabbedPane.addTab("Options", options); 
        jtabbedPane.addTab("Hot Tubs", hotTub);

        topPanel.add(jtabbedPane, BorderLayout.CENTER); 
    }

    /*      CREATE GENERAL    */

    public void createGeneral(){ 
        general = new JPanel(); 
        general.setLayout(null); 

        JLabel dateLabel = new JLabel("Todays Date"); 
        dateLabel.setBounds(10, 15, 150, 20); 
        general.add(dateLabel); 

        JFormattedTextField date = new JFormattedTextField( 
        java.util.Calendar.getInstance().getTime()); 
        date.setEditable(false); 
        date.setBounds(150,15,150,20); 
        general.add(date); 

        JButton Exit = new JButton("Exit"); 
        Exit.setBounds(10,80,150,30); 
        Exit.addActionListener(this); 
        Exit.setBackground(Color.red); 
        general.add(Exit); 
    }

    /*      CREATE POOLS    */

    public void createPools(){ 
        pools = new JPanel(); 
        pools.setLayout(null); 

        JLabel lengthLabel = new JLabel( "Enter the length of swimming pool(ft):"); 
        lengthLabel.setBounds(10, 15, 260, 20); 
        pools.add(lengthLabel); 

        lengthText = new JTextField(); 
        lengthText.setBounds( 260, 15, 150, 20 ); 
        pools.add( lengthText ); 

        JLabel widthLabel = new JLabel("Enter the width of the swimming pool(ft):"); 
        widthLabel.setBounds(10, 60, 260, 20); 
        pools.add(widthLabel); 

        widthText = new JTextField(); 
        widthText.setBounds(260, 60, 150, 20); 
        pools.add(widthText); 

        JLabel depthLabel = new JLabel("Enter the average depth the swimming pool(ft):"); 
        depthLabel.setBounds(10, 100, 260, 20); 
        pools.add( depthLabel); 

        depthText = new JTextField(); 
        depthText.setBounds(260, 100, 150, 20); 
        pools.add(depthText); 

        JLabel volumeLabel = new JLabel("The pool volume is:(ft ^3"); 
        volumeLabel.setBounds(10, 200, 260, 20); 
        pools.add(volumeLabel); 

        volumeText = new JTextField(); 
        volumeText.setBounds(260, 200, 150, 20); 
        volumeText.setEditable(false); 
        pools.add(volumeText); 

        JButton calcVolume = new JButton("Calculate Volume"); 
        calcVolume.setBounds(150,250,150,30); 
        calcVolume.addActionListener(this); 

        pools.add(calcVolume); 

        JButton Exit = new JButton("Exit"); 
        Exit.setBounds(350,250,80,30); 
        Exit.addActionListener(this); 
        Exit.setBackground(Color.white); 
        pools.add(Exit); 
    }

    public void createOptions() 
    { 
        options = new JPanel(); 
        options.setLayout( null ); 
        JLabel labelOptions = new JLabel("Change Company Name:"); 
        labelOptions.setBounds( 150, 50, 150, 20 ); 
        options.add( labelOptions ); 

        JTextField newTitle = new JTextField(); 
        newTitle.setBounds( 150, 70, 150, 20 ); 
        options.add( newTitle ); 

        JButton newName = new JButton("Set New Name");
        newName.setBounds(100,115,150,30);
        newName.addActionListener(this);
        newName.setBackground(Color.yellow);
        options.add(newName);

        JButton Exit = new JButton("Exit");
        Exit.setBounds(250,115,80,30);
        Exit.addActionListener(this);
        Exit.setBackground(Color.red);
        options.add(Exit);
    }

    public void actionPerformed(ActionEvent event){ 
        JButton button = (JButton)event.getSource(); 
        String buttonLabel = button.getText(); 

        if ("Exit".equalsIgnoreCase(buttonLabel)){ 
            Exit_pressed(); return; 
        } 

        if ("Set New Name".equalsIgnoreCase(buttonLabel)){ 
            New_Name(); 
            return; 
        } 

        if ("Calculate Volume".equalsIgnoreCase(buttonLabel)){ 
            Calculate_Volume(); return; 
        } 

        if ("Customers".equalsIgnoreCase(buttonLabel)){ 
            Customers(); return; 
        } 

        if ("Calculate Volume".equalsIgnoreCase(buttonLabel)){ 
            Calculate_Volume(); 
            return;                                                                                            
        } 

        if ("Options".equalsIgnoreCase(buttonLabel)){ 
            Options(); 
            return; 
        }
    } 

    private void Exit_pressed(){ 
        System.exit(0); 
    } 
    private void New_Name(){ 
        System.exit(0); 
    } 
    private void Calculate_Volume(){ 
        String lengthString, widthString, depthString; 
        int length=0; 
        int width=0; 
        int depth=0; 

        lengthString = lengthText.getText(); 
        widthString = widthText.getText(); 
        depthString = depthText.getText(); 
        if (lengthString.length() < 1 || widthString.length() < 1 || depthString.length() < 1){ 
            volumeText.setText("Error! Must enter in all three numbers!!");  
            return;                                                                                                    
        } 
        length = Integer.parseInt(lengthString ); 
        width = Integer.parseInt(widthString ); 
        depth = Integer.parseInt(depthString); 

        if (length != 0 || width != 0 || depth != 0){ 
            volumeText.setText((length * width * depth) + "" ); 
        }   
        else{ 
               volumeText.setText("Error! Must Enter in all three numbers!!"); 
               return; 
            } 
    } 

    private void Customers(){ 
    } 

    private void Options(){
    } 

    public static void main(String[] args){ 
        JFrame frame = new VolCalc(); 
        frame.setSize(525, 350); 
        frame.setVisible(true); 
    }
}
错误:

java.lang.NoClassDefFoundError:VolCac由以下原因引起:java.lang.ClassNotFoundException:VolCac位于java.net.URLClassLoader$1.runUnknown Source位于java.security.AccessController.DoPrivilegeNative方法位于java.net.URLClassLoader.findClassUnknown Source位于java.lang.ClassLoader.loadClassUnknown Source位于主线程中java.lang.ClassLoader.loadClassUnknown源异常处的sun.misc.Launcher$AppClassLoader.loadClassUnknown源异常


不知道如何实例化,但stacktrace表明找不到VolCac类。在您粘贴到这里的代码中,您的类名为VolCalc…

我猜您试图使用以前的启动配置,该配置使用的是旧名称。从上下文菜单启动该类或使用适当的键盘快捷键,我现在记不起来了,比如Ctrl-Alt-X,J将使用新名称,可能会解决问题


或者,您可以使用“运行”按钮旁边的下拉菜单编辑启动配置,告诉它要启动的正确类名。

@Bartzilla,对不起,stacktrace是什么?因此,您出现了一些错误,您没有向我们提供详细信息,您更改了某些类的名称,但我们不知道是哪个,现在你有了新的错误,你还没有告诉我们细节。部分问题可能存在于您尚未发布的代码中。总而言之,这使得我们很难回答这个问题。请读一读-我们不是通灵者。@Mike:那你是怎么办到的?它真的没有错误吗?@Mike你需要提供更多的细节。首先,你指的这些新错误是什么?代码是否生成编译错误?它会在行刑时爆炸吗?或者它根本就没有达到你运行它时所期望的效果?@Mike你能举一个简单的例子来重现你的错误吗?您是否可以编辑上面的文章,将其全部包括在内,并详细描述我们将如何在Eclipse中重现您的错误。如果我们有很多不必要的代码,并且可能没有一些重要的代码,我们就无法找出哪里出了问题。