怎么helloworld程序无法运行?
我己经在记事本中写好程序,程序如下:
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




