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

您没有登录

» Java开发网 » Java SE 综合讨论区 » 安装/配置/编译/环境  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 为什么我的程序不能被编译? (error:cannot read:Welcome.java)
chuxueaihaozhe





发贴: 26
积分: 0
于 2005-06-22 15:58 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
网友们好!
我用的是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
请问这是什么原因?谢谢!


why edited on 2005-06-26 20:29


作者 Re:为什么我的程序不能被编译? [Re:chuxueaihaozhe]
vicious





发贴: 185
积分: 30
于 2005-06-22 17:47 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 Welcome.java


作者 Re:为什么我的程序不能被编译? [Re:chuxueaihaozhe]
why

問題兒童

总版主


发贴: 4629
积分: 388
于 2005-06-22 23:38 user profilesend a private message to usersend email to whysearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
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


why edited on 2005-06-22 23:41

作者 Re:为什么我的程序不能被编译? [Re:chuxueaihaozhe]
一枝梅





发贴: 42
积分: 0
于 2005-06-23 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
是不是保存的文件类型出错


作者 Re:为什么我的程序不能被编译? [Re:chuxueaihaozhe]
chuxueaihaozhe





发贴: 26
积分: 0
于 2005-06-23 20: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
谢谢关注,我回家按照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的大门!");
}
}
请各位网友帮帮忙,看究竟是什么原因.




作者 Re:为什么我的程序不能被编译? [Re:chuxueaihaozhe]
why

問題兒童

总版主


发贴: 4629
积分: 388
于 2005-06-23 21:16 user profilesend a private message to usersend email to whysearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
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


why edited on 2005-06-24 00:38

作者 Re:为什么我的程序不能被编译? [Re:chuxueaihaozhe]
chuxueaihaozhe





发贴: 26
积分: 0
于 2005-06-24 22:39 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
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




作者 Re:为什么我的程序不能被编译? [Re:chuxueaihaozhe]
why

問題兒童

总版主


发贴: 4629
积分: 388
于 2005-06-24 23:01 user profilesend a private message to usersend email to whysearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
chuxueaihaozhe wrote:
但是我遇到另一个问题,当我把*.java.txt改为*.java后myclass中的文件就打不开了,

myclass中并没有生成Welcom.class的文件,而只是Welcom,没有.class,打开也只看到 Macromedia Flash Player 6.0(之下是空白),这样一来以前写的程序既看不到又改不了.请问是什么原因,怎么办?谢谢!

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.)



作者 Re:为什么我的程序不能被编译? [Re:why]
snowbird2005

米兰大脑



发贴: 72
积分: 10
于 2005-06-24 23: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
我觉得问这些执行环境的设定如path、classpath、文件后缀等等的问题,只要看看张孝祥的JAVA基础视频教程的第一课就一清二楚了,很生动的。
不知道这里有没有,
如果没有的话,我可以上传一个,就是太大了,足有300M。不知道能不能传。



作者 Re:为什么我的程序不能被编译? [Re:snowbird2005]
why

問題兒童

总版主


发贴: 4629
积分: 388
于 2005-06-25 00:37 user profilesend a private message to usersend email to whysearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
snowbird2005 wrote:
我觉得问这些执行环境的设定如path、classpath、文件后缀等等的问题,只要看看张孝祥的JAVA基础视频教程的第一课就一清二楚了,很生动的。
不知道这里有没有,
如果没有的话,我可以上传一个,就是太大了,足有300M。不知道能不能传。

Very well.
From now on, please stop asking 这些执行环境的设定如path、classpath、文件后缀等等的问题, try to find 张孝祥的JAVA基础视频教程的第一课 Smile -- 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 视频教程.


why edited on 2005-06-26 20:36

作者 Re:为什么我的程序不能被编译? [Re:chuxueaihaozhe]
chuxueaihaozhe





发贴: 26
积分: 0
于 2005-06-25 18:55 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
Thank you very much !
You open the door for me to Java .





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