'javac' 未被识别为内部或外部命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24553930/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 12:57:01  来源:igfitidea点击:

'javac' is not recognized as an internal or external command

javamatlab-deployment

提问by user3801619

I have to convert my Matlab algorithm in Java. For this I'm using matlab builder ja toolbox, after following all the necessary steps, the build fails and this error is displayed:

我必须在 Java 中转换我的 Matlab 算法。为此,我正在使用 matlab builder ja 工具箱,在完成所有必要的步骤后,构建失败并显示此错误:

'javac' is not recognized as an internal or external command, operable program or batch file. Error: An error occurred while shelling out to javac (error code = 1). Unable to build executable.

'javac' 不是内部或外部命令,也不是可运行的程序或批处理文件。错误:向 javac 发送时发生错误(错误代码 = 1)。无法构建可执行文件。

When typing java -versionin the matlab command line, this is what i get:

java -version在 matlab 命令行中输入时,这就是我得到的:

Java 1.6.0_12-b04 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode

Java 1.6.0_12-b04 与 Sun Microsystems Inc. Java HotSpot(TM) 客户端 VM 混合模式

It means I should have this compiler of java installed on my computer, only then the matlab builder ja works. I'm new to Java, I'm not sure what compiler I should be looking for.

这意味着我应该在我的计算机上安装这个 java 编译器,只有这样 matlab builder ja 才能工作。我是 Java 新手,我不确定我应该寻找什么编译器。

回答by Bruno

If you want javac(the compiler), you'll need to download the Java Development Kit (JDK), not just the Java Runtime Environment (JRE). Note that the JDK includes a JRE.

如果需要javac(编译器),则需要下载 Java 开发工具包 (JDK),而不仅仅是 Java 运行时环境 (JRE)。请注意,JDK 包含一个 JRE。

This tutorialgive instructions to install JDK to your computer.

教程提供了在您的计算机上安装 JDK 的说明。

回答by user1573932

You need to make sure that Java SDK is installed and also PATH is set properly so that windows would be able to know where the executable is. Detailed steps on how to debug this issue is explained here: http://www.windows-commandline.com/javac-not-recognized-internal-external-command/

您需要确保安装了 Java SDK 并正确设置了 PATH,以便 Windows 能够知道可执行文件的位置。此处解释了有关如何调试此问题的详细步骤:http: //www.windows-commandline.com/javac-not-recognized-internal-external-command/

回答by user3738165

If you receive this error, Windows cannot find the compiler (javac).

如果收到此错误,Windows 找不到编译器 (javac)。

Here's one way to tell Windows where to find javac. Suppose you installed the JDK in C:\jdk1.8.0. At the prompt you would type the following command and press Enter:

这是告诉 Windows 在哪里可以找到 javac 的一种方法。假设您在 C:\jdk1.8.0 中安装了 JDK。在提示符下,您将键入以下命令并按 Enter:

C:\jdk1.8.0\bin\javac HelloWorld.java If you choose this option, you'll have to precede your javac and java commands with C:\jdk1.8.0\bin\ each time you compile or run a program. To avoid this extra typing, consult the lecture "Creating a Hello World application" in this website

C:\jdk1.8.0\bin\javac HelloWorld.java 如果选择此选项,则每次编译或运行程序时都必须在 javac 和 java 命令之前加上 C:\jdk1.8.0\bin\。为避免这种额外的输入,请参阅本网站中的讲座“创建 Hello World 应用程序”

Class names, 'HelloWorld', are only accepted if annotation processing is explicitly requested

类名“HelloWorld”仅在明确请求注释处理时才被接受

If you receive this error, you forgot to include the .java suffix when compiling the program. Remember, the command is javac HelloWorld.java not javac HelloWorld.

如果您收到此错误,则您在编译程序时忘记包含 .java 后缀。请记住,命令是 javac HelloWorld.java 而不是 javac HelloWorld。

回答by Khalid Habib

Set Following Environment Variables It will works

设置以下环境变量它会起作用

JAVA_HOME=C:\Program Files\Java\jdk1.7.0_09
set PATH=%JAVA_HOME%\bin

回答by Jhossep Augusto Popayán Avila

  • First make sure you have installed jdk and jre, both are installed with the java software development kit. The installation folder is typically C:\Program Files\Java.

  • Now go to Computer > Properties > Advanced system settingsin the advanced tab click on Environment Variables

  • In System variables find the variable named Path, in the value of Pathyou will find a java path like C:\ProgramData\Oracle\Java\javapath, just change it to C:\Program Files\Java\jdk1.x.x_x\bin.

  • 首先确保你已经安装了jdk和jre,两者都是用java软件开发包安装的。安装文件夹通常是C:\Program Files\Java

  • 现在转到高级选项卡中的计算机 > 属性 > 高级系统设置,单击环境变量

  • 在系统变量找到名为变量路径,在值路径,你会发现像一个java的路径C:\ ProgramData \ ORACLE \的Java \ javapath,只是将其更改为C:\ Program Files文件\的Java \ jdk1.x.x_x \斌

Hope that helps.

希望有帮助。

回答by user5446695

Path is defined as the filename. Ex, C://aklsej;dlfkj/blahblah

路径被定义为文件名。例如,C://aklsej;dlfkj/blahblah

You will need to specify the full path in the system control panel, advanced system settings, edit variables, edit path, put a semicolon after the last entry and don't delete anything, and then add the full path wherever you installed java to.

您需要在系统控制面板中指定完整路径,高级系统设置,编辑变量,编辑路径,在最后一个条目后添加分号并且不要删除任何内容,然后在安装java的任何位置添加完整路径。

to make this easy, do a search for javac in the search panel and then just add the full path to the environmental variables from there.

为方便起见,在搜索面板中搜索 javac,然后从那里添加到环境变量的完整路径。

回答by Shahrukh Sohail

To solve the aforementioned problem follow the mentioned steps:

要解决上述问题,请按照上述步骤操作:

1) Copy the address location of your Java\jdk\bin folder usually installed in your C: drive. It should look something like this:

1) 复制通常安装在 C: 驱动器中的 Java\jdk\bin 文件夹的地址位置。它应该是这样的:

C:\Program Files (x86)\Java\jdk1.8.0_65\bin

C:\Program Files (x86)\Java\jdk1.8.0_65\bin

2) Right click on My Computer-->Properties-->Change settings--> Advanced-->Environment Variables.. -->New..

2) 右键单击​​我的电脑--> 属性--> 更改设置--> 高级--> 环境变量.. --> 新建..

3) Now,

3)现在,

 Set Variable name: PATH
 Variable value: C:\Program Files (x86)\Java\jdk1.8.0_65\bin

4) Press OK, re-open your cmd and compile your program.

4)按OK,重新打开你的cmd并编译你的程序。

Hopefully it worked!

希望它奏效了!

回答by Dhruvil Shah

Download Java from given link according to your requirements.

根据您的要求从给定的链接下载 Java。

http://www.oracle.com/technetwork/java/javase/downloads/index.html

http://www.oracle.com/technetwork/java/javase/downloads/index.html

then follow below steps: Step-1 : Right Click on MyComputer and click on properties .

然后按照以下步骤操作: 第 1 步:右键单击 MyComputer 并单击属性。

Step 2 : Click on Advanced tab

第 2 步:单击高级选项卡

Step 3 : Click on Environment Variables

第 3 步:单击环境变量

Step 4 : Create a new class path for JAVA_HOME

第 4 步:为 JAVA_HOME 创建一个新的类路径

Step 5 : Enter the Variable name as JAVA_HOME and the value to your jdk bin path ie c:\Programfiles\Java\jdk-1.6\bin and

第 5 步:输入变量名称作为 JAVA_HOME 和 jdk bin 路径的值,即 c:\Programfiles\Java\jdk-1.6\bin 和

NOTE Make sure u start with .; in the Value so that it doesn't corrupt the other environment variables which is already set.

注意确保你以 .; 开头 在 Value 中,这样它就不会破坏已经设置的其他环境变量。

Step 6 : Follow the Above step and edit the Path in System Variables add the following ;c:\Programfiles\Java\jdk-1.6\bin in the value column.

第 6 步:按照上述步骤编辑系统变量中的路径,在值列中添加以下 ;c:\Programfiles\Java\jdk-1.6\bin。

Step 7 :Your are done setting up your environment variables for your Java , In order to test it go to command prompt and type

第 7 步:您已完成为 Java 设置环境变量,为了测试它,请转到命令提示符并键入

java
who will get a list of help doc

java
谁将获得帮助文档列表

In order make sure whether compiler is setup Type in cmd

为了确定编译器是否设置在cmd中输入

javac

爪哇

who will get a list related to javac

谁将获得与 javac 相关的列表

Hope this Helps !

希望这可以帮助 !