简体   繁体   English

使用 javac 和 java 编译的问题

[英]problems compiling with javac and java

This problem is a bit embarrassing, and the solution is most likely on your web site somewhere, but I haven't been able to find it, so here goes: I've just installed Java to my C:\\ drive, and while the machine can find java it can't find javac, to wit:这个问题有点尴尬,解决方案很可能在你的网站上的某个地方,但我一直找不到它,所以这里是:我刚刚在我的 C:\\ 驱动器中安装了 Java,而机器可以找到java它找不到javac,也就是说:

C:\>java -version
java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)


C:\>javac -version
Error: Could not find or load main class com.sun.tools.javac.Main

and I get the above response even when I'm sitting IN the bin directory.即使我坐在 bin 目录中,我也会得到上述响应。 I'm stumped.我难住了。

I've tried updating both the PATH and JAVA_HOME environment variables, and I'm sorta stuck.我已经尝试更新 PATH 和 JAVA_HOME 环境变量,但我有点卡住了。 Can anyone help?任何人都可以帮忙吗? Note: I'm glad to go to the appropriate spot on your site, but I haven't been able to locate it, if you just point me to it I will consider myself helped, and thanks.注意:我很高兴转到您网站上的适当位置,但我无法找到它,如果您只是指向我,我会认为自己有帮助,谢谢。

The problem may be because you might have installed JRE, so you are able to use java command问题可能是因为你可能已经安装了 JRE,所以你可以使用 java 命令

javac command is used compiling java programs, hence its for development javac命令用于编译java程序,因此用于开发

And for development you need to install JDK对于开发,您需要安装 JDK

Have a look at this :看看这个:

What is the difference between JDK and JRE? JDK 和 JRE 有什么区别?

You need to specify the environment variable ie path.您需要指定环境变量即路径。 If you are using Windows 7, then Right click on my computer -> change settings -> advanced -> environment variable -> change path to bin folder of java ( C:\\Program Files\\Java\\jdk1.7.0_03\\bin ), no need to earse the prev path in path variable.如果您使用的是 Windows 7,则右键单击我的电脑 -> 更改设置 -> 高级 -> 环境变量 -> 将路径更改为 java 的 bin 文件夹( C:\\Program Files\\Java\\jdk1.7.0_03\\bin ),无需在路径变量中查看上一个路径。 Just give ";"只要给“;” at end, paste the link of the JDK's bin folder, and type ";".最后,粘贴 JDK 的 bin 文件夹的链接,然后键入“;”。

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

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