Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 问题啊 问题(NoClassDefFoundError)
iceriver2000





发贴: 29
积分: 0
于 2006-11-06 10:56 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
今天编写了个很简单的程序 text.java保存在c:\myjava目录下
可是执行 c:\myjava>javac text.java命令是出现如下错误

Exception in thread "main" java.lang.NoClassDefFoundError:text/java
而且以前运行成功的程序也出现了上述问题
请问是怎么会事 是我的jdk配置问题吗?


why edited on 2006-11-07 18:28

作者 Re:问题啊 问题 [Re:iceriver2000]
shom0058





发贴: 10
积分: 0
于 2006-11-06 12:31 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
是你调试的程序没有main函数吧


JAVA第二军团群:16014973
作者 Re:问题啊 问题 [Re:shom0058]
zcjl

涅槃



发贴: 537
积分: 65
于 2006-11-06 13:37 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
1、请给出text.java的代码,注意文件名和Class名要一致,尤其是大小写
2、如果text.java没有问题,请使用javac -classpath . text.java



作者 Re:问题啊 问题 [Re:iceriver2000]
iceriver2000





发贴: 29
积分: 0
于 2006-11-07 08:53 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我的text文件是非常简单 代码为:
import java.io.*;
public class text{
public static void main(String[] args){
System.out.println("why main programe has something wrong");
}
}
保存为 text.java
在执行 c:\myjava>javac text.java时还是有问题:
Exception in thread "main" java.lang.NoClassDefFoundError:text/java
这是什么问题呢 ?请大家指教.



作者 Re:问题啊 问题 [Re:iceriver2000]
zcjl

涅槃



发贴: 537
积分: 65
于 2006-11-07 10:48 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
程序本身没有问题
看来应该是环境设置的问题了
请给出JAVA_HOME、CLASSPATH等环境变量的设置

ps:我这里只设置了JAVA_HOME,没有设置CLASSPATH,编译和运行你这个代码就一切正常



作者 Re:问题啊 问题 [Re:iceriver2000]
iceriver2000





发贴: 29
积分: 0
于 2006-11-07 10:49 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
在运行 javac xx.java编辑好后
执行java xx文件.
那么xx文件一定要包含main方法吗??
我在用netbeans执行没有main方法的xx.class文件时可以显示结果,
但是在控制台执行xx.class文件就有错误:
Exception in thread "main" java.lang.NoClassDefFoundError:text/java



作者 Re:问题啊 问题(NoClassDefFoundError) [Re:iceriver2000]
snow_lxj





发贴: 7
积分: 0
于 2006-11-12 17:17 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
mai方法是程序执行的入口



flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923