简体   繁体   English

可以识别Java但不能识别Javac

[英]Java is recognized but Javac is not recognized

I recently installed Java but when I open the command line and I enter: 我最近安装了Java,但是当我打开命令行并输入时:

java -version

I get back: 我回来了:

C:\Users\Tim>java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

But when I enter: 但是当我输入:

javac -version

I get back: 我回来了:

C:\Users\Tim>javac -version
'javac' is not recognized as an internal or external command,
operable program or batch file.

I added the following line to the end of my path in environment variables: 我在环境变量的路径末尾添加了以下行:

;C:\Program Files\Java\jdk1.8.0_60\bin;

I installed this version: 我安装了此版本:

jdk-8u60-windows-x64.exe

I use Windows 10. I have sought out multiple sources for help but none of them seem to be working. 我使用Windows10。我已经寻求了多种资源来寻求帮助,但是似乎都没有用。 I think I've installed the right package as the name is JDK, it is for Windows on a 64 machine and java is found, but the compiler is not. 我想我已经安装了正确的软件包,因为它的名称是JDK,适用于64台计算机上的Windows,并且找到了Java,但编译器却没有。 I'm trying to train on Java now, but I'm stuck here and can't go much further until I iron this out. 我现在正在尝试使用Java进行培训,但是我一直坚持在这里,除非我解决了这个问题,否则别无所求。 I appreciate any help. 感谢您的帮助。 Thank you. 谢谢。

You missed some steps. 您错过了一些步骤。 Go to variable environment and do the following: 转到可变环境并执行以下操作:

System Variables: 系统变量:

  • Edit path variable adding the following: 编辑路径变量,添加以下内容:

    ;C:\\ProgramFiles\\Java\\Java_version\\bin ; C:\\ ProgramFiles \\ Java \\ Java_version \\ bin

  • Create a new variable. 创建一个新变量。 Its name will be classpath and its value will be: ;C\\ProgramFiles\\Java\\Java_Version\\src.zip 其名称将为classpath ,其值将为:; C \\ ProgramFiles \\ Java \\ Java_Version \\ src.zip

User Variables : 用户变量:

  • Create a variable called path , its value will be: C:\\ProgramFiles\\Java\\Java_verson\\bin 创建一个名为path的变量,其值将为:C:\\ ProgramFiles \\ Java \\ Java_verson \\ bin

  • Create a variable called classpath , its value will be: C\\ProgramFiles\\Java\\Java_Version\\src.zip 创建一个名为classpath的变量,其值将为:C \\ ProgramFiles \\ Java \\ Java_Version \\ src.zip

I had that problem.. the solution is to remove all spaces from the java path. 我遇到了问题..解决方案是从java路径中删除所有空格。 So instead of having it located at: 因此,与其将其放置在:

JAVA_HOME = C:\\Program Files\\Java\\jdk1.8.0_60 JAVA_HOME = C:\\ Program Files \\ Java \\ jdk1.8.0_60

move the jdk folder to, 将jdk文件夹移至

for example: JAVA_HOME = C:\\Java\\jdk1.8.0_60 例如: JAVA_HOME = C:\\ Java \\ jdk1.8.0_60

Then add the following line to the end of path in environment variables: 然后将以下行添加到环境变量的路径末尾:

C:\\Java\\jdk1.8.0_60\\bin; C:\\ Java \\ jdk1.8.0_60 \\ bin;

it worked for me :) 它对我有用:)

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

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