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

  • SEARCH
  • Home
  • 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 8271029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:44:32+00:00 2026-06-08T06:44:32+00:00

I just started my java tutorials and as part of my first exercise, i

  • 0

I just started my java tutorials and as part of my first exercise, i was asked to:

a) Create a new class for a real-world object (i chose mobile phone): mobile
b) For this class, create an interface that defines its behavior, then require your class to implement it.

I used Netbeans for this exercise and this is the code i wrote/extended:

    package mobile;

    /**
     * @param args the command line arguments
     */

    public static void main(String[] args) {

public class Mobile {
    int volume = 0;
    int ringtone = 0;

void volumeUp (int increment){
    volume = volume + increment;
}
void changeringtone (int newValue){
    ringtone = newValue;
}
void volumeDown (int decrement){
    volume = volume - decrement;
}
void printStates(){
    System.out.println("ringtone:" + ringtone + "volume:" + volume);
}

}

However when i run it, i get this error message:

java.lang.NoClassDefFoundError: mobile/Mobile (wrong name: mobile/mobile)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

Could not find the main class: mobile.Mobile. Program will exit.

I am kindly requesting if anyone can please, first of all, point out to me the mistakes in my code and secondly, how i can fix these problems inside of Netbeans.

Thank you in advance!

karramelle

  • 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-06-08T06:44:35+00:00Added an answer on June 8, 2026 at 6:44 am

    In this case, you may not even need the main() method unless you are writing code to test your class. As thinksteep suggested, you can move the main() method inside your Mobile class. Alternatively, you can remove it all together in order to compile your code. However, note that you must have a main() method somewhere in order to run your program.

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

Sidebar

Related Questions

Ok so I've just started learning java (I usually program in Objective-C). My first
I've just started writing GAE web applications in Java so I'm kind of new
I am pretty new to image capturing using java. Just started working in java.
We just started a new project in Java EE in our office and i
I've just started Java and we have been asked to produce pong (or a
I just started with Java and downloaded Netbeans, i kind of like it, but
I've just started learning Java (about a week ago) and the last few days
I have just started MongoDB + Java, and I am getting into queries, collections
I've just started learning LWJGL (Java OpenGL), and i'm encountering an enormous amount of
How would you explain to someone who has just started programming in Java, what

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.