title: Correctly install Java for Matlab
body: <p>I am trying to extract a jar file from Matlab code using javac from Library Compiler (java package). </p>
  
  <p>I have set <code>JAVA_HOME</code> to: </p>
  
  <p><code>C:\Program Files\Java\jdk1.7.0_71</code> </p>
  
  <p>and added to <code>PATH</code>: </p>
  
  <p><code>C:\Program Files\Java\jdk1.7.0_71\bin</code>. </p>
  
  <p>When I enter <code>java -version</code> in my console, I get <code>java version jdk1.7.0_71</code> and running <code>javac -version</code> shows <code>jdk1.7.0_71</code>. </p>
  
  <p>However, it seems that matlab could not find javac, thus, I am not able to compile my <code>.m</code> code into a <code>.jar</code> file. When I tried to compile .m code I got the following:</p>
  
  <pre><code>Error: An error occurred while shelling out to javac (error code = -1).
  Unable to build executable.
  Executing command: ""C:\Program Files\Java\Java\jdk1.7.0_11\bin\javac" -verbose - classpath "...\MATLAB\R2014a\toolbox\javabuilder\jar\javabuilder.jar" -d   "...\features_extraction\for_testing\classes"  "...\features_extraction\for_testing\features_extraction\Class1.java" "...\features_extraction\for_testing\features_extraction\Features_extractionMCRFactory.java" "...\for_testing\features_extraction\Class1Remote.java" "...\for_testing\features_extraction\package-info.java""
  </code></pre>
  
  <p>This is the directory of my java bin folder and javac.exe exists : <code>...\Java\jdk1.7.0_71\bin\bin\javac</code>? I found this link for compatibility between Java and Matlab2014a(which is my version) <a href="http://www.mathworks.com/support/compilers/R2014a/index.html?refresh=true" rel="nofollow">here</a>. What should I check in order to correctly link Matlab to Java? A few days ago Matlab was working correctly with Java.</p>
  
  <p>In my <code>PATH</code> I noticed the existence of the following path: <code>C:\ProgramData\Oracle\Java\javapath</code> in which there are three wrong shortcuts to java.exe, javac.exe, and javax.exe. When I type in matlab console <code>getenv JAVA_HOME</code> I am getting  <code>C:\Program Files\Java\jdk1.7.0_11</code> while when I wrote <code>version -java</code> I got: <code>Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode</code>. When I write <code>javac</code> in matlab console I am getting: <code>Undefined function or variable 'javac'.</code></p>
  
  <p>When I try to built C++ library I got a similar issue: Error: An error occurred while shelling out to mbuild (error code = -1).
  Unable to build executable. </p>
  
  <p>EDIT: Does the absence of the proper MCR counts in my case?</p>