Results 1 to 4 of 4
  1. #1
    beastman3226 is offline Member
    Join Date
    Nov 2012
    Posts
    5
    Rep Power
    0

    Default Made new JFrame Class, not running though

    I made a new JFrame class and I have added all functionality to it but when I run it says "No main class found". When ever I run the class individually I get a stack trace like this:
    Java Code:
    java.lang.NoClassDefFoundError: me/GUI/NewMain
    Caused by: java.lang.ClassNotFoundException: me.GUI.NewMain
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    Could not find the main class: me.GUI.NewMain.  Program will exit.
    Exception in thread "main" Java Result: 1
    I know this means I have no main class but it's there since I'm editing it. Samething with the actual JFrame class.

    Here's the JFrame class:
    Java Code:
    package me.GUI;
    
    /**
     *
     * @author beastman3226
     */
    public class AreaJFrame extends javax.swing.JFrame {
        
        /**
         * Creates new form AreaJFrame
         */
        public AreaJFrame() {
            initComponents();
        }
    
        /**
         * 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() {
    
            Length = new javax.swing.JTextField();
            Width = new javax.swing.JTextField();
            Multiply = new javax.swing.JButton();
            Area = new javax.swing.JLabel();
    
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("Area Finder\n");
    
            Length.setText("Length");
    
            Width.setText("Width");
    
            Multiply.setText("Find");
            Multiply.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    MultiplyActionPerformed(evt);
                }
            });
    
            Area.setText("Area");
    
            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(Length, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(Multiply, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(Width, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap())
                .addGroup(layout.createSequentialGroup()
                    .addGap(136, 136, 136)
                    .addComponent(Area, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(Length, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(Width, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(Multiply))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(Area))
            );
    
            pack();
        }// </editor-fold>
    
        private void MultiplyActionPerformed(java.awt.event.ActionEvent evt) {
            int length = (int) (Double.parseDouble(Length.getText()));
            int width = (int) (Double.parseDouble(Width.getText()));
            int area = length * width;
            Area.setText(area + "< -- Area");
        }
        
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new AreaJFrame().setVisible(true);
                }
            });
        }
        
        // Variables declaration - do not modify
        private javax.swing.JLabel Area;
        private javax.swing.JTextField Length;
        private javax.swing.JButton Multiply;
        private javax.swing.JTextField Width;
        // End of variables declaration
    }
    All in NetBeans by the way, I figured I missed something in the NetBeans instruction manual:P
    Last edited by beastman3226; 12-05-2012 at 01:39 AM.

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    758
    Rep Power
    8

    Default Re: Made new JFrame Class, not running though

    It said that it cannot fine the NewMain (me.GUI.NewMain) class. Do you have it?

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: Made new JFrame Class, not running though

    Quote Originally Posted by beastman3226 View Post
    I made a new JFrame class and I have added all functionality to it but when I run it says "No main class found". ,,, I figured I missed something in the NetBeans instruction manual:P
    Search the NetBeans help to find how to set the main class (hint: Project -> Properties -> Run

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    beastman3226 is offline Member
    Join Date
    Nov 2012
    Posts
    5
    Rep Power
    0

    Default Re: Made new JFrame Class, not running though

    Quote Originally Posted by wsaryada View Post
    It said that it cannot fine the NewMain (me.GUI.NewMain) class. Do you have it?
    I deleted it and restarted Netbeans, now at my class declaration line it says "Duplicate class: me.GUI.AreaJFrame". Whenever I quick fix It makes me create a new class.

Similar Threads

  1. Replies: 7
    Last Post: 10-14-2012, 06:05 AM
  2. custom made up date class with calendar
    By infernocy in forum Advanced Java
    Replies: 1
    Last Post: 04-12-2012, 06:42 PM
  3. Collections sorting a list made of generic class objects
    By andreiutz10 in forum New To Java
    Replies: 5
    Last Post: 02-07-2012, 05:56 PM
  4. Unable to access getter method in an object class I made
    By EnSlavingBlair in forum New To Java
    Replies: 6
    Last Post: 10-01-2011, 10:52 AM
  5. No class made
    By ChuckLS in forum New To Java
    Replies: 1
    Last Post: 04-28-2009, 04:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •