简体   繁体   English

Javac找不到.class文件,具有正确的类路径

[英]Javac can't find .class files, have right classpath

Although I'm not new to programming in general, I am new to java, and it seems to work a little bit differently. 虽然我并不陌生,在一般的编程,我新来的Java,它似乎工作有点不同。 When trying to compile a .java with javac it gives me this error: cannot find symbol . 尝试使用javac编译.java时,出现此错误: cannot find symbol I looked the cause of this up, and the error occurs when the .class file that you are referencing could not be found. 我查找了造成这种情况的原因,并且在找不到您所引用的.class文件时发生了错误。 I ensured that all of my references were spelled correctly, I ensured I had the right classpath, I tried compiling a .java file I know is valid, even on an XP computer just in case my Vista installation was the cause, but to no avail. 我确保所有引用均正确拼写,确保具有正确的类路径,并尝试编译知道有效的.java文件,即使在XP计算机上,以防万一我的Vista安装是造成该错误的原因,但无济于事。 Here are the contents of the .bat I am using to run javac, it could be the cause of my problems. 这是我用来运行javac的.bat的内容,这可能是造成我问题的原因。

@echo off
"C:\Program Files (x86)\Java\jdk1.6.0_21\bin\javac" -encoding UTF8 -cp .  hl.java
pause

Thank you for the help, this has been troubling me for quite some time now. 谢谢您的帮助,这已经困扰了我一段时间了。

Can you show us this? 你能告诉我们这个吗?

I tried compiling a .java file I know is valid

Could it be that you are using classes not compiled on . 可能是您使用的不是在上编译的类。 ? Unless your code is as simple as hello world , I'd say chances are high. 除非您的代码像hello world一样简单,否则我说机会很高。

This is a long shot, but looking at your script and the error message you described, you're probably not running javac at all. 这是一个长镜头,但是查看您的脚本和所描述的错误消息,您可能根本没有运行Javac。 Try this on the command line and see what it says: 在命令行上尝试此操作,看看它显示了什么:

C:\Program Files (x86)\Java\jdk1.6.0_21\bin\javac -version

If that doesn't work, then you're not pointing to a valid javac. 如果这不起作用,则说明您没有指向有效的javac。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM