CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Java >  框架、开源

怎么helloworld程序无法运行?

楼主liu_y_f()2005-01-02 18:17:23 在 Java / 框架、开源 提问

我己经在记事本中写好程序,程序如下:  
  public   class   HelloWorldApp   {//an   application  
  public   static   void   main   (String   args[   ]){  
  System.out.println("Hello   World!");  
  }  
  }  
  并把它保存到了c盘下HelloWorldApp.java,也装好了jdk,  
  可是我输入c:>javac   HelloWorldApp.java回车以后就提   示  
   
   
  C:\>javac   HelloWorldApp.java  
  error:   cannot   read:   HelloWorldApp.java  
  1   error  
  请帮忙分析是什么问题? 问题点数:0、回复次数:13Top

1 楼classjava(原始野人)回复于 2005-01-02 18:23:48 得分 0

环境变量有问题Top

2 楼limitmx(limit....)回复于 2005-01-02 18:26:38 得分 0

设置问题  
  楼主可以在提示符下面运行java试试看有什么反应Top

3 楼wingtrace(虽然生活很艰苦,但是我们也不能做禽兽)回复于 2005-01-02 18:28:08 得分 0

估计是在CLASSPATH里面没有把   “.”(代表当前路径)加上。Top

4 楼liu_y_f()回复于 2005-01-02 18:29:44 得分 0

classpath  
  C:\j2sdk1.4.1_07\lib\tools.jar;C:\j2sdk1.4.1_07\jre\lib\rt.jar;  
  java_home  
  C:\j2sdk1.4.1_07  
  path  
  C:\j2sdk1.4.1_07\bin  
  哪个有问题??Top

5 楼liu_y_f()回复于 2005-01-02 18:34:01 得分 0

 
   
  C:\>java  
  Usage:   java   [-options]   class   [args...]  
                        (to   execute   a   class)  
        or     java   -jar   [-options]   jarfile   [args...]  
                        (to   execute   a   jar   file)  
   
  where   options   include:  
          -client               to   select   the   "client"   VM  
          -server               to   select   the   "server"   VM  
          -hotspot             is   a   synonym   for   the   "client"   VM     [deprecated]  
                                      The   default   VM   is   client.  
   
          -cp   -classpath   <directories   and   zip/jar   files   separated   by   ;>  
                                      set   search   path   for   application   classes   and   resources  
          -D<name>=<value>  
                                      set   a   system   property  
          -verbose[:class|gc|jni]  
                                      enable   verbose   output  
          -version             print   product   version   and   exit  
          -showversion     print   product   version   and   continue  
          -?   -help             print   this   help   message  
          -X                         print   help   on   non-standard   options  
          -ea[:<packagename>...|:<classname>]  
          -enableassertions[:<packagename>...|:<classname>]  
                                      enable   assertions  
          -da[:<packagename>...|:<classname>]  
          -disableassertions[:<packagename>...|:<classname>]  
                                      disable   assertions  
          -esa   |   -enablesystemassertions  
                                      enable   system   assertions  
          -dsa   |   -disablesystemassertions  
                                      disable   system   assertions  
  运行java以后是这样Top

6 楼liu_y_f()回复于 2005-01-02 18:40:58 得分 0

晕倒死就是晕倒死Top

7 楼angelface(§<@#$&^%$>§)回复于 2005-01-02 18:46:19 得分 0

args[   ]  
  多了一个空格?Top

8 楼limitmx(limit....)回复于 2005-01-02 18:46:42 得分 0

你那个文件是HelloWorldApp.java吗?  
  不会是HelloWorldApp.java.txt吧?Top

9 楼liu_y_f()回复于 2005-01-02 19:00:01 得分 0

 
   
  C:\>javac   HelloWorldApp.java  
  error:   cannot   read:   HelloWorldApp.java  
  1   error  
   
  C:\>javac   HelloWorldApp.java.txt  
  javac:   invalid   flag:   HelloWorldApp.java.txt  
  Usage:   javac   <options>   <source   files>  
  where   possible   options   include:  
      -g                                                 Generate   all   debugging   info  
      -g:none                                       Generate   no   debugging   info  
      -g:{lines,vars,source}         Generate   only   some   debugging   info  
      -nowarn                                       Generate   no   warnings  
      -verbose                                     Output   messages   about   what   the   compiler   is   doing  
      -deprecation                             Output   source   locations   where   deprecated   APIs   are   us  
  ed  
      -classpath   <path>                   Specify   where   to   find   user   class   files  
      -sourcepath   <path>                 Specify   where   to   find   input   source   files  
      -bootclasspath   <path>           Override   location   of   bootstrap   class   files  
      -extdirs   <dirs>                       Override   location   of   installed   extensions  
      -d   <directory>                         Specify   where   to   place   generated   class   files  
      -encoding   <encoding>             Specify   character   encoding   used   by   source   files  
      -source   <release>                   Provide   source   compatibility   with   specified   release  
      -target   <release>                   Generate   class   files   for   specific   VM   version  
      -help                                           Print   a   synopsis   of   standard   options  
   
   
  C:\>java   HelloWorldApp  
  Exception   in   thread   "main"   java.lang.NoClassDefFoundError:   HelloWorldApp  
   
  ????Top

10 楼liuguangliang(小刀刘)回复于 2005-01-02 20:06:17 得分 0

这个不可能是环境变量的问题,肯定是文件名不对  
  可能是保存为.txt文件了Top

11 楼123xxx(香克斯)回复于 2005-01-02 21:22:09 得分 0

有可能是文件类型的问题,你在c盘下用dir看看那个文件究竟是*.java还是*.java.txt。然后classpath的最前面加上".;"---把当前路径设置到classpath中,要不然你编译通过之后用java命令执行时也可能会出问题Top

12 楼hscartoon(卡通)回复于 2005-01-11 22:02:38 得分 0

肯定保存为.txt文件了。建议使用IDE(推荐Eclipse)!!!Top

13 楼hu_an_xiong()回复于 2005-01-13 17:06:33 得分 0

肯定保存有问题Top

相关问题

  • asp.net程序无法运行
  • ?无法运行regsrv程序,怎么办?
  • Vs.net程序无法在win98运行。
  • 无法运行asp.net web应用程序。
  • 无法运行asp.net web 应用程序
  • 关于程序无法运行(ntdll.dll)
  • 无法运行ASP.NET Web应用程序
  • 菜鸟级问题:HelloWorld程序运行出错???
  • 为什么这个“helloworld”程序不能运行?
  • 运行 ejb 的 HelloWorld 客户程序出现的问题

关键词

  • 文件
  • vm
  • classpath
  • sdk
  • source
  • client
  • helloworldapp
  • 程序
  • javac
  • j2sdk1.4.1

得分解答快速导航

  • 帖主:liu_y_f

相关链接

  • CSDN Java频道
  • Java类图书
  • Java类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo