Topic: 为什么我的程序不能被编译? (error:cannot read:Welcome.java) |
Print this page |
1.为什么我的程序不能被编译? (error:cannot read:Welcome.java) | Copy to clipboard |
Posted by: chuxueaihaozhe Posted on: 2005-06-22 15:58 网友们好! 我用的是Windows2000中的记事本,J2sdk1.4.2. public class Welcome { public static void main(string[] args) { Systerm.out.println("这是我的第一个程序,欢迎走入Java的大门"); } } 以Welcome.java为名保存,但编译不了: error:cannot read:Welcome.java 1 error 请问这是什么原因?谢谢! |
2.Re:为什么我的程序不能被编译? [Re: chuxueaihaozhe] | Copy to clipboard |
Posted by: vicious Posted on: 2005-06-22 17:47 javac Welcome.java |
3.Re:为什么我的程序不能被编译? [Re: chuxueaihaozhe] | Copy to clipboard |
Posted by: why Posted on: 2005-06-22 23:38 Where is your Welcome.java? Is it in the folder where you issued the command javac Welcome.java ? Run the following commands and copy-n-paste the contents in the Command Prompt window to here: > echo JAVA_HOME > echo PATH > echo CLASSPATH > dir > javac Welcome.java |
4.Re:为什么我的程序不能被编译? [Re: chuxueaihaozhe] | Copy to clipboard |
Posted by: 一枝梅 Posted on: 2005-06-23 08:53 是不是保存的文件类型出错 |
5.Re:为什么我的程序不能被编译? [Re: chuxueaihaozhe] | Copy to clipboard |
Posted by: chuxueaihaozhe Posted on: 2005-06-23 20:48 谢谢关注,我回家按照WHY的建议输入如下代码: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ c:\>cd myclass c:\myclass>echo java-home java-home c:\myclass>echo path path c:\myclass>echo classpath classpath c:\myclass>dir 驱动器c中的卷是DISK1-VOL1 卷的序列号是0672-82C6 C:\myclass的目录 05/01/2005 09:31p <DIR> . 05/01/2005 09:31P <DIR> .. 06/05/2005 09:51a 176 FloatTest.java.txt 06/23/2005 04:27p 135 Welcome.java.txt 06/15/2005 04:56p 253 LogicSign.java.txt 3个文件 564字节 2个目录 2,902,650,880可用字节 c:\myclass>javac Welcome.java error:cannot read:Welcome.java 1 error c:\myclass>javac FloatTest.java error:cannot read:FloatTest.java 1 error c:\myclass>javac LogicSign .java error:cannot read: LogicSign.java 1 error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 其中Welcome.java的代码如下: public class Welcome { public static void main(String[] args) { System.out.println("这是我的第一个程序,欢迎走入Java的大门!"); } } 请各位网友帮帮忙,看究竟是什么原因. |
6.Re:为什么我的程序不能被编译? [Re: chuxueaihaozhe] | Copy to clipboard |
Posted by: why Posted on: 2005-06-23 21:16 06/05/2005 09:51a 176 FloatTest.java.txt 06/23/2005 04:27p 135 Welcome.java.txt 06/15/2005 04:56p 253 LogicSign.java.txt rename *.java.txt as *.java Sorry, should be > echo %JAVA_HOME% > echo %PATH% > echo %CLASSPATH% Note that it's JAVA_HOME, not JAVA-HOME |
7.Re:为什么我的程序不能被编译? [Re: chuxueaihaozhe] | Copy to clipboard |
Posted by: chuxueaihaozhe Posted on: 2005-06-24 22:39 Thank you very much!非常感谢! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\myclass>rename Welcom.java.txt Welcom.java C:\myclass>javac Welcom.java C:\myclass>java Welcom 这是我的第一个程序,欢迎走入Java的大门! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public class Welcom { public static void main(String[] args) { System.out.println("这是我的第一个程序,欢迎走入Java的大门!"); } } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 但是我遇到另一个问题,当我把*.java.txt改为*.java后myclass中的文件就打不开了,myclass中并没有生成Welcom.class的文件,而只是Welcom,没有.class,打开也只看到 Macromedia Flash Player 6.0(之下是空白),这样一来以前写的程序既看不到又改不了.请问是什么原因,怎么办?谢谢! chuxueaihaozhe edited on 24/06/2005 22:43 |
8.Re:为什么我的程序不能被编译? [Re: chuxueaihaozhe] | Copy to clipboard |
Posted by: why Posted on: 2005-06-24 23:01 chuxueaihaozhe wrote: Windows Explorer menuitem "Tools-->Folder Options" tab "View" uncheck "Hide file extensions for known file types" You'll see filename.ext then. .class file is a binary file that contains bytecode (for JVM). You may drag the .java file into your editor or set up proper file association -- don't ask me how. It is very boring to repeat (not to speak writing them down) this kind of stuff again and again, while anyone can read on such Windows operation basics himself/herself (if one don't know how to use Windows, learn so before doing program development.) |
9.Re:为什么我的程序不能被编译? [Re: why] | Copy to clipboard |
Posted by: snowbird2005 Posted on: 2005-06-24 23:53 我觉得问这些执行环境的设定如path、classpath、文件后缀等等的问题,只要看看张孝祥的JAVA基础视频教程的第一课就一清二楚了,很生动的。 不知道这里有没有, 如果没有的话,我可以上传一个,就是太大了,足有300M。不知道能不能传。 |
10.Re:为什么我的程序不能被编译? [Re: snowbird2005] | Copy to clipboard |
Posted by: why Posted on: 2005-06-25 00:37 snowbird2005 wrote: Very well. From now on, please stop asking 这些执行环境的设定如path、classpath、文件后缀等等的问题, try to find 张孝祥的JAVA基础视频教程的第一课 -- don't ask me how and where -- I don't have it and for sure I don't need it. FYI, CJSDN does not have this 视频教程. |
11.Re:为什么我的程序不能被编译? [Re: chuxueaihaozhe] | Copy to clipboard |
Posted by: chuxueaihaozhe Posted on: 2005-06-25 18:55 Thank you very much ! You open the door for me to Java . |
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 |