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

user3801619 picture user3801619 · Jul 3, 2014 · Viewed 82.3k times · Source

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.

Answer

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