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

妖精的绣舞 提交于 2019-12-01 04:01:23

问题


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:

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

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

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

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.


回答1:


  • 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 settings in the advanced tab click on Environment Variables

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

Hope that helps.




回答2:


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.

This tutorial give instructions to install JDK to your computer.




回答3:


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/




回答4:


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:

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

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

3) Now,

 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.

Hopefully it worked!




回答5:


Path is defined as the filename. Ex, 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.

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.




回答6:


Set Following Environment Variables It will works

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



回答7:


Download Java from given link according to your requirements.

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

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

Step 2 : Click on Advanced tab

Step 3 : Click on Environment Variables

Step 4 : Create a new class path for 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

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

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.

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

java
who will get a list of help doc

In order make sure whether compiler is setup Type in cmd

javac

who will get a list related to javac

Hope this Helps !




回答8:


If you receive this error, Windows cannot find the compiler (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:

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

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

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.



来源:https://stackoverflow.com/questions/24553930/javac-is-not-recognized-as-an-internal-or-external-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!