怎么helloworld程序无法运行?

liu_y_f 2005-01-02 06:17:23
我己经在记事本中写好程序,程序如下:
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
请帮忙分析是什么问题?
...全文
209 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
hu_an_xiong 2005-01-13
  • 打赏
  • 举报
回复
肯定保存有问题
hscartoon 2005-01-11
  • 打赏
  • 举报
回复
肯定保存为.txt文件了。建议使用IDE(推荐Eclipse)!!!
123xxx 2005-01-02
  • 打赏
  • 举报
回复
有可能是文件类型的问题,你在c盘下用dir看看那个文件究竟是*.java还是*.java.txt。然后classpath的最前面加上".;"---把当前路径设置到classpath中,要不然你编译通过之后用java命令执行时也可能会出问题
liuguangliang 2005-01-02
  • 打赏
  • 举报
回复
这个不可能是环境变量的问题,肯定是文件名不对
可能是保存为.txt文件了
liu_y_f 2005-01-02
  • 打赏
  • 举报
回复


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

????
limitmx 2005-01-02
  • 打赏
  • 举报
回复
你那个文件是HelloWorldApp.java吗?
不会是HelloWorldApp.java.txt吧?
angelface 2005-01-02
  • 打赏
  • 举报
回复
args[ ]
多了一个空格?
liu_y_f 2005-01-02
  • 打赏
  • 举报
回复
晕倒死就是晕倒死
liu_y_f 2005-01-02
  • 打赏
  • 举报
回复


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以后是这样
liu_y_f 2005-01-02
  • 打赏
  • 举报
回复
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
哪个有问题??
梦想家起飞 2005-01-02
  • 打赏
  • 举报
回复
估计是在CLASSPATH里面没有把 “.”(代表当前路径)加上。
limitmx 2005-01-02
  • 打赏
  • 举报
回复
设置问题
楼主可以在提示符下面运行java试试看有什么反应
classjava 2005-01-02
  • 打赏
  • 举报
回复
环境变量有问题

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧