Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

New to Java, what does this mean!


  • Please log in to reply

#1
BSNCAPBYY

BSNCAPBYY

    Member

  • Member
  • PipPipPip
  • 216 posts
I want to run a JAVA Program and this pops up?

--------------------Configuration: Chapter03_Example01 - JDK version 1.6.0_10 <Default> - <Default>--------------------
java.lang.NoClassDefFoundError: Mortgage
Caused by: java.lang.ClassNotFoundException: Mortgage
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: Mortgage. Program will exit.
Exception in thread "main"
Process completed.

Please help me so I can move on, thanks
  • 0

Advertisements


#2
jpshortstuff

jpshortstuff

    Member

  • Member
  • PipPipPip
  • 119 posts
Usually it means that you haven't defined the entry point for the program - i.e. it doesn't know where to start.

Can you post the code for the program so we can see if we can help? Also, what compiler/IDE are you using?
  • 0

#3
BSNCAPBYY

BSNCAPBYY

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 216 posts
Can you post the code for the program so we can see if we can help?


import java.io.*;
import java.text.NumberFormat;

public class Mortgage {

public static void main(String args[]) throws IOException {

BufferedReader keyboard =
new BufferedReader(new InputStreamReader(System.in));
double principal, rate, ratePercent;
int years, n;
final int paymentsPerYear = 12;
final int timesPerYearCalculated = 12;
double effectiveAnnualRate;
double payment;
NumberFormat currency = NumberFormat.getCurrencyInstance();

System.out.print("How much are you borrowing? ");
principal = Double.parseDouble(keyboard.readLine());
System.out.print("What's the interest rate? ");
ratePercent = Double.parseDouble(keyboard.readLine());
rate = ratePercent / 100.00;
System.out.print("How many years are you taking to pay? ");
years = Integer.parseInt(keyboard.readLine());
System.out.println("------------------------------");

n = paymentsPerYear * years;
effectiveAnnualRate = rate / paymentsPerYear;
payment =
principal
* (effectiveAnnualRate
/ (1 - Math.pow(1 + effectiveAnnualRate, -n)));
System.out.print("Your monthly payment is ");
System.out.println(currency.format(payment));
System.out.println();
}
}

Also, what compiler/IDE are you using?
I am using JCreator LE

I am new to this, this code is from book I am reading, and its telling me to run this workspace so I can see how it runs, but I cant even do this, please help!!!

Thanks!!!
  • 0

#4
jpshortstuff

jpshortstuff

    Member

  • Member
  • PipPipPip
  • 119 posts
Sound like a problem with the Compiler to me.

Had a little look around, looks like this is a similar problem to yours:
http://www.jcreator....?showtopic=2595

By the sounds of it, the source file is being created in the wrong place and the compiler can't find them. I am not familiar with your IDE I'm afraid, so I can't offer any direct advice on how to solve/workaround the problem.

Have ago at the advice offered in that link above, and see if that helps with the problem.

Hope that helps.
  • 0

#5
coyne20

coyne20

    Member

  • Member
  • PipPip
  • 35 posts
Try running the same program in Eclipse IDE. I tried it within Eclipse and JVM 1.4.2._XX. It works like a charm. Consider the output example below:

How much are you borrowing? 5000
What's the interest rate? 0.05
How many years are you taking to pay? 10
------------------------------
Your monthly payment is £41.77
  • 0

#6
PoRco

PoRco

    Member

  • Member
  • PipPip
  • 14 posts
Yeap, just ran the code you pasted using DR.JaVa.

Definitely seems to be a problem with your compiler. Its really not worth looking into the problem, just use Dr.Java or Eclipse as suggested by a previous poster.

I recommend Dr.Java cause it doesnt auto-complete any of the code for you, you learn faster that way.
  • 0

#7
stew4

stew4

    New Member

  • Member
  • Pip
  • 1 posts
Hi,

I had the same problem, and i presume you were usuing the same beginning programming with java for dummies as i was. The problem was much simpler than any answers i found whilst browsing the web. Basically, for me this was, when I downloaded the Jcreator program from the books website i downloaded the pro version, DO NOT DO THIS. This is because the program still searchs for the file in a "jcreatorLE" directory.
If you download jcreator LE from the books site instead this should solve the issue, it did for me.

Hope that helps

Stewart
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP