Results 1 to 4 of 4
- 12-05-2012, 01:36 AM #1
Member
- Join Date
- Nov 2012
- Posts
- 5
- Rep Power
- 0
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:
I know this means I have no main class but it's there since I'm editing it. Samething with the actual JFrame class.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
Here's the JFrame class:
All in NetBeans by the way, I figured I missed something in the NetBeans instruction manual:PJava 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 }Last edited by beastman3226; 12-05-2012 at 01:39 AM.
- 12-05-2012, 03:13 AM #2
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
Re: Made new JFrame Class, not running though
It said that it cannot fine the NewMain (me.GUI.NewMain) class. Do you have it?
Website: Learn Java by Examples
- 12-05-2012, 04:57 AM #3
- 12-05-2012, 01:25 PM #4
Member
- Join Date
- Nov 2012
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
Generic List I've made holding Objects I've made must be cast?
By Lowest0ne in forum New To JavaReplies: 7Last Post: 10-14-2012, 06:05 AM -
custom made up date class with calendar
By infernocy in forum Advanced JavaReplies: 1Last Post: 04-12-2012, 06:42 PM -
Collections sorting a list made of generic class objects
By andreiutz10 in forum New To JavaReplies: 5Last Post: 02-07-2012, 05:56 PM -
Unable to access getter method in an object class I made
By EnSlavingBlair in forum New To JavaReplies: 6Last Post: 10-01-2011, 10:52 AM -
No class made
By ChuckLS in forum New To JavaReplies: 1Last Post: 04-28-2009, 04:54 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks