java线程“main”中出现异常。lang.noclassdeffounderror
它说exeption it线程是“主”java。noclassdeffounderror:后跟13行“at java”
我尝试了最常用的方法来解决这个错误,我对java完全陌生,这让我发疯!这很令人沮丧(我将“classpath”环境变量更改为“.”并将正确的路径(C:\Program Files\Java\jdk1.7.0_17\bin)复制到“path”变量。我不这么认为。我甚至在另一台计算机上进行了尝试,结果完全相同(在我更改了环境变量之后)。我从“fordummies”网站下载了代码,所以我不认为这是个坏代码。。。 我花了4个小时研究这个问题,我想是时候向专家寻求建议了:):)
// This program prompts for information about a loan and
// computes the monthly loan payment.
import java.util.*; // for Scanner
public class Mortgage {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
// obtain values
System.out.println("This program computes monthly " +
"loan payments.");
System.out.print("loan amount : ");
double loan = console.nextDouble();
System.out.print("number of years : ");
int years = console.nextInt();
System.out.print("interest rate : ");
double rate = console.nextDouble();
System.out.println();
// compute result and report
int n = 12 * years;
double c = rate / 12.0 / 100.0;
double payment = loan * c * Math.pow(1 + c, n) /
(Math.pow(1 + c, n) - 1);
System.out.println("payment = $" + (int) payment);
}
}
错误是:
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(unknown Source)
at java.security.AccessController.DoPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
# 1 楼答案
我不知道这是否是问题所在,但值得一试
首先(这是我不确定的),我认为不是:
我认为你应该:
另一件事是确保你有你的清单。txt文件,如果您将程序设置为Jar文件Some information on Jar manifest files.
# 2 楼答案
请注意,Java区分大小写,包括命令行中使用的参数。我的猜测是,您的程序运行不正确
由于类名为
Mortgage
,因此必须使用相同的大小写:注意
java
程序需要包含main()
方法的类的名称。因此,大小写必须与代码中声明的内容匹配