问题描述
我已经为我的64位Windows 7下载了一个java开发工具包,在记事本中记下我的代码,虽然代码是从命令提示符编译并创建一个.class文件,但是它拒绝运行显示错误代码:
java.lang.NoClassDefFoundError:first引发者:java.lang.ClassNotFoundException:first
at java.net。 URLClassLoader $ 1.run(未知源)
at java.security.AccessController.doPrivileged(Native方法)
在java.net.URLClassLoader.findClass(未知源)
at java.lang.ClassLoader .loadClass(未知源)
at sun.misc.Launcher $ AppClassLoader.loadClass(未知源)
at java.lang.ClassLoader.loadClass(未知源)
找不到主类:第一。程序将退出。线程main中的异常
我已经多次确认文件名和类名是完全相同的(我保持他们小写'a'只是为了确保)。但是仍然没有效果,你能建议一些解决方案请..我是新的java我基本上是一个C / C ++程序员。
一个java程序具有以下基本结构:
ClassName.java
public class ClassName
{
public static void main(String [] args)
{
}
}
尝试使用此大纲来生成您的代码。
编译并运行:
javac ClassName.java
java ClassName
I have downloaded a java developers kit for my 64bit windows 7, wrote down my code in the notepad, though the code is compiling from the command prompt and creating a .class file, but its refusing to run showing the error code:
java.lang.NoClassDefFoundError: first Caused by: java.lang.ClassNotFoundException: first
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)
Could not find the main class: first. Program will exit. Exception in thread "main"
I have made sure more than once that the file name and the class name are exactly same(i have kept them smallcase 'a' just to be sure). But still no avail, could you please suggest a few solutions please.. I'm new to java i'm basically a C/C++ programmer.
解决方案 A java program has this basic structure:
ClassName.java
public class ClassName
{
public static void main(String[] args)
{
}
}
try using this outline to generate your code.
compile and run with:
javac ClassName.java
java ClassName
这篇关于无法运行一个简单的java代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!