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 6808029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:54:18+00:00 2026-05-26T19:54:18+00:00

I am learning Java from scratch. I installed the JDK, and I got the

  • 0

I am learning Java from scratch. I installed the JDK, and I got the Hello World Program running. I am trying to run a simple accountdemo program. In Account.java, I have :

public class Account 
{
    protected double balance;

    // Constructor to initialize balance
    public Account( double amount )
{
    balance = amount;
}

    // Overloaded constructor for empty balance
    public Account()
{
    balance = 0.0;
}

    public void deposit( double amount )
{
    balance += amount;
}

    public double withdraw( double amount )
{
            // See if amount can be withdrawn
    if (balance >= amount)
    {
        balance -= amount;
                    return amount;
    }
    else
            // Withdrawal not allowed
                    return 0.0;
}

    public double getbalance()
{
            return balance;
}
}  

On compiling this, I got the Account.class. In accountdemo.java, I have this

class AccountDemo
{

 public static void main(String args[])
 {
 Account my_account = new Account();
 my_account.deposit(250.00);
 System.out.println("Current balance " + my_account.getbalance());
 my_account.withdraw(80.00);
 System.out.println("Remaining balance" + my_account.getbalance());
}


 }

On compiling this, I got AccountDemo.class. But, when I try to run this as an application, I get the error java.lang.NoClassDefFoundError:
C:\Users\roymustang/NT\Documents\javaprogram\accountdemo/java

I have set the classpath to : C:\Users\roymustang.NT\Documents\javaprogram

Am I missing anything obvious? Like mismatched uppercase or something?

EDIT : Not homework, just trying to learn.

I am using Textpad, http://www.textpad.com/ . It has an option run commands. So, I have configured it to run javac.exe (C:\Program Files\SDK\jdk\bin\javac.exe $File $FileDir)

and run as application by java.exe ( C:\Program Files\SDK\jdk\bin\java.exe $File $FileDir)

  • 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-26T19:54:18+00:00Added an answer on May 26, 2026 at 7:54 pm

    Hi there I’ll assume that you are trying to run this using no java IDE e.g. Eclipse or Netbeans. I tested your code and they worked just fine.

    C:>java AccountDemo
    Current balance 250.0
    Remaining balance170.0

    Your error Message is:

    java.lang.NoClassDefFoundError:
    C:\Users\roymustang/NT\Documents\javaprogram\accountdemo/java

    meaning you used:

    java accountdemo

    to run your program. Remember that Java is case sensitive this can be corrected by using this.

    java AccountDemo

    Happy Coding ^_^

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

Sidebar

Related Questions

I'm learning java and I have made simple program that simply reads value from
I'm currently learning ObjC and Cocoa programming, coming from the Java world. To test
I'm learning java and I'm trying to make a very simple application that does
As someone learning Java from scratch, who knows a little Python, I have been
When I was learning Java coming from a background of some 20 years of
I just started learning C++ (coming from Java ) and am having some serious
Coming from PHP with some Java Struts 2.0 experience any tips/tricks on learning GWT?
I am learning Java (slowly) from the ground up, but every now and again
I am fairly new to learning C# (from Java & C++ background) and I
I am learning java, and studying the following example from sun.com. import java.io.*; import

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.