Click here to Skip to main content
15,123,367 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
A o a!
I'm creating a software that have simple and scientific calculators and many converter. I create this software using swing components. I create separate class for every program like every converter and calculator. I complete this software. During creation of software every thing is fine and run but now when I try to run there is approximately 3 to 5 files thats have this error. When I call them from main class below an error occurs. I try to find solution for this error through many sites but I can't find. Kindly if anyone can be know the solution of this error so please please share with me. I'm past the error below.

What I have tried:

Java
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem5);

        jMenu5.setText("Converter");
        jMenu5.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N

        jMenuItem6.setText("Volume");
        jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem6ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem6);

        jMenuItem7.setText("Length");
        jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem7ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem7);

        jMenuItem10.setText("Weight and Mass");
        jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem10ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem10);

        jMenuItem8.setText("Temperature");
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem8ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem8);

        jMenuItem11.setText("Energy");
        jMenuItem11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem11ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem11);

        jMenuItem9.setText("Area");
        jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem9ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem9);

        jMenuItem12.setText("Speed");
        jMenuItem12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem12ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem12);

        jMenuItem14.setText("Time");
        jMenuItem14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem14ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem14);

        jMenuItem15.setText("Power");
        jMenuItem15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem15ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem15);

        jMenuItem16.setText("Data");
        jMenuItem16.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem16ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem16);

        jMenuItem13.setText("Pressure");
        jMenuItem13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem13ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem13);

        jMenuItem17.setText("Angle");
        jMenuItem17.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem17ActionPerformed(evt);
            }
        });


This is error that occur.....

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: Reader
at pdf_reader.jMenuItem1ActionPerformed(pdf_reader.java:350)
at pdf_reader.access$1600(pdf_reader.java:22)
at pdf_reader$17.actionPerformed(pdf_reader.java:224)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:842)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:886)
at java.awt.Component.processMouseEvent(Component.java:6539)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6304)
at java.awt.Container.processEvent(Container.java:2239)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4535)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
at java.awt.Container.dispatchEventImpl(Container.java:2283)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:733)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.ClassNotFoundException: Reader
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 41 more
BUILD SUCCESSFUL (total time: 6 seconds)
Posted
Updated 29-Mar-21 22:13pm
v2
Comments
CHill60 27-Mar-21 17:50pm
   
You have to share your code. We can't see your screen from over here!
Mehboob Shaukat 27-Mar-21 17:53pm
   
Hello Sir I have many classes. I'll need to main class code share with or any other class?
CHill60 27-Mar-21 17:59pm
   
How about just the first one that causes this error?
Richard MacCutchan 28-Mar-21 4:05am
   
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: Reader
Where is the Reader class defined?
Mehboob Shaukat 28-Mar-21 5:30am
   
/* * To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/


import java.awt.Desktop;
import java.io.File;
import javax.swing.JOptionPane;
import java.awt.Toolkit;

/**
*
* @author Mehboob Shauakt
*/
public class Reader extends javax.swing.JFrame {

String filepath;

/**
* Creates new form Reader1
*/
public Reader() {
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() {

jFileChooser1 = new javax.swing.JFileChooser();
jLabel1 = new javax.swing.JLabel();
txtfilepath = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu3 = new javax.swing.JMenu();
jMenuItem3 = new javax.swing.JMenuItem();
jMenu4 = new javax.swing.JMenu();
jMenuItem4 = new javax.swing.JMenuItem();
jMenuItem5 = new javax.swing.JMenuItem();
jMenu5 = new javax.swing.JMenu();
jMenuItem6 = new javax.swing.JMenuItem();
jMenuItem7 = new javax.swing.JMenuItem();
jMenuItem10 = new javax.swing.JMenuItem();
jMenuItem8 = new javax.swing.JMenuItem();
jMenuItem11 = new javax.swing.JMenuItem();
jMenuItem9 = new javax.swing.JMenuItem();
jMenuItem12 = new javax.swing.JMenuItem();
jMenuItem14 = new javax.swing.JMenuItem();
jMenuItem15 = new javax.swing.JMenuItem();
jMenuItem16 = new javax.swing.JMenuItem();
jMenuItem13 = new javax.swing.JMenuItem();
jMenuItem17 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jMenuItem22 = new javax.swing.JMenuItem();
jMenuItem1 = new javax.swing.JMenuItem();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Reader");
setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("M1.png")));
setResizable(false);

jLabel1.setText(" File path");

jButton1.setText("Select Path");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jButton2.setText("Open");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jMenu3.setText(": :");
jMenu3.setFont(new java.awt.Font("Segoe UI", 1, 12)); // NOI18N

jMenuItem3.setText("Restart");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem3);

jMenu4.setText("Calculator");
jMenu4.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N

jMenuItem4.setText("Basic");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem4);

jMenuItem5.setText("Scientific");
jMenuItem5.addActionListener(new
Richard MacCutchan 28-Mar-21 5:38am
   
And where does the error occur? You must provide proper clear details of the problem and where and when it occurs. We have never seen this code before, so we have no idea how it is supposed to fit together with whatever else you have written.
Mehboob Shaukat 28-Mar-21 5:41am
   
Sir how can I sent u whole files in .txt I hope you will find better solution by watching them!!!!
Richard MacCutchan 28-Mar-21 5:54am
   
You cannot send everything, and even if you did no one would look at it. You need to provide just the information that is relevant to the problem.
Mehboob Shaukat 29-Mar-21 0:00am
   
Hello Sir Thanks for encourage me. I don't know, how? But when I create a jar file and create setup and then install setup every thing is same as I want. But in NetBeans some classes not run and some classes run. I'm again Thanks to you.
Mehboob Shaukat 29-Mar-21 0:09am
   
Hello Sir Thanks for encourage me. I don't know, how ? But when I create a jar file and create setup and then install setup every thing is same as I want. But in NetBeans some classes not run and some classes run. I thank you again...
Mehboob Shaukat 30-Mar-21 2:19am
   
Hello Sir can I ask one more question to you?
Richard MacCutchan 30-Mar-21 3:11am
   
Er, yes, what is the question?
Mehboob Shaukat 30-Mar-21 3:38am
   
Sir I create a jar file and then create setup. This setup is run on my pc but can't run on other pc when I check installation place there is same jar file on the place of application file. So I think to create application file so I try to create this file, I use launch4j for and create this success fully. But this setup also run on my pc but can't run on other pc. It shows a message "This application requires a java Runtime Environment 1.4.0"
So I add jre link in jre tab in launch4j. But it seems same. How can I solve it?
Richard MacCutchan 30-Mar-21 3:48am
   
Sorry, i have not used launch4j so cannot offer any suggestions. Try Launch4j - Cross-platform Java executable wrapper[^], where they have a support forum.
Mehboob Shaukat 30-Mar-21 3:51am
   
Ok sir thank you!
Mehboob Shaukat 28-Mar-21 5:42am
   
I'm using NetBeans IDE.
Mehboob Shaukat 28-Mar-21 5:38am
   
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem5);

jMenu5.setText("Converter");
jMenu5.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N

jMenuItem6.setText("Volume");
jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem6ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem6);

jMenuItem7.setText("Length");
jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem7ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem7);

jMenuItem10.setText("Weight and Mass");
jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem10ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem10);

jMenuItem8.setText("Temperature");
jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem8ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem8);

jMenuItem11.setText("Energy");
jMenuItem11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem11ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem11);

jMenuItem9.setText("Area");
jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem9ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem9);

jMenuItem12.setText("Speed");
jMenuItem12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem12ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem12);

jMenuItem14.setText("Time");
jMenuItem14.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem14ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem14);

jMenuItem15.setText("Power");
jMenuItem15.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem15ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem15);

jMenuItem16.setText("Data");
jMenuItem16.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem16ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem16);

jMenuItem13.setText("Pressure");
jMenuItem13.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem13ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem13);

jMenuItem17.setText("Angle");
jMenuItem17.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem17ActionPerformed(evt);
}
});

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900