Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3331526
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:35:35+00:00 2026-05-17T23:35:35+00:00

I am new to java and I have two classes (class calc and button)

  • 0

I am new to java and I have two classes (class calc and button) that I need to split into separate files and class calc uses class button. they both compile however when I run class A it fails. How can I do this?

This is the code for class calc

package start; 
import javax.swing.*;  
import java.awt.event.*;  
import java.awt.Container;  
import java.awt.Insets;  
import java.awt.Dimension;  
import button.*;

public class calc {
 private button calc_buttons;

 private static void creategui(){
  JFrame window = new JFrame("hello dynamic window");

  buttons.createbuttons();
  buttons.setOpaque(false);
  window.setContentPane(buttons);
  window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  window.pack();
  window.setVisible(true);

 }

 static public void main(String[] args){
  creategui();
 }

}

this is the code for class button

package button;

import javax.swing.*;
import java.awt.event.*;
import java.awt.Container;
import java.awt.Insets;
import java.awt.Dimension;

public class button /*extends JPanel implements ActionListener*/{

 protected static JButton button1, button2, button3, button4, button5, button6, button7;
 protected static JButton button8, button9, button_fact, button_exp, button_sqrt, button_abs;
 protected static JButton button_sin, button_cos, button_tan, button_percent, button_rcl;
 protected static JButton button_MC, button_e, button_pi, button_Mplus, button_Mminus;
 protected static JButton button_C, button_AC, button_MS, button_sign;
 protected static JButton button_plus, button_minus, button_div, button_mult, button_equal;

 static public void calc_button(){


 }

}

when I compile I get no error messages but when I run the calc class I get this

Exception in thread “main” java.lang.NoClassDefFoundError: calc (wrong name: start/calc)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:35:35+00:00Added an answer on May 17, 2026 at 11:35 pm

    Go one directory higher (into the directory that contains “start” and “button”) and do this:

    java start.calc
    

    By the way, it’s a convention to let class names start with a capital letter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple Java generics question: I have two classes - one of which uses generics
I have two Java class files: primegen and primecheck sitting in the same directory.
I'm pretty new to Java and this has me really confused. I have two
I have two classes as Splash.java and Activity2.java !! I have tried simple code
I have two classes as Splash.java and Activity2.java!! I have tried simple code for
Thanks !!i have two .java classes as trial.java and CommonActivity.java as: public void onClick(View
Hi I work with netbeans. I have written a code which has two classes
I am very new to Android (and Java) originally a C# developer.. and am
Please help me figure this out. I've tried so many combinations but nothing seems

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.