title: Unable to run java Program. Error inside docker
body: <p>I am just a beginner to Docker and was exploring the various features. I have successfully installed java inside docker</p>
  
  <pre><code>**OS version**:Windows Server 2016
  
  PS C:\testing&gt; docker version
  Client:
   Version:      17.03.1-ee-3
   API version:  1.27
   Go version:   go1.7.5
   Git commit:   3fcee33
   Built:        Thu Mar 30 19:31:22 2017
   OS/Arch:      windows/amd64
  Server:
     Version:      17.03.1-ee-3
  
   API version:  1.27 (minimum version 1.24)
   Go version:   go1.7.5
   Git commit:   3fcee33
   Built:        Thu Mar 30 19:31:22 2017
   OS/Arch:      windows/amd64
   Experimental: false
  PS C:\testing&gt;
  </code></pre>
  
  <p>Created a Dockerfile in the path <code>C:\java-windows-docker\Dockerfile</code>, and put the following lines inside:</p>
  
  <pre><code> FROM windowsservercore  
    RUN powershell (new-object     
  System.Net.WebClient).Downloadfile('http://javadl.oracle.com/webapps/download/AutoDL?
  BundleId=210185', 'C:\jre-8u91-windows-x64.exe')
  RUN powershell start-process -filepath C:\jre-8u91-windows-x64.exe -passthru -wait -argumentlist"/s,INSTALLDIR=c:\Java\jre1.8.0_91,/L,install64.log"
  RUN del C:\jre-8u91-windows-x64.exe
  CMD [ "c:\\Java\\jre1.8.0_91\\bin\\java.exe", "-version"]
  It downloads the Java 8 Update 91 Windows installer and silently installs it to c:\Java\jre1.8.0_91.
  </code></pre>
  
  <p><code>docker build -t java-windows-docker C:\java-windows-docker</code>
  And if we run it, after start, the container launches Java and prints out its version.</p>
  
  <pre><code>PS C:\Windows\system32&gt; docker run java-windows-docker
  java version "1.8.0_91"
  Java(TM) SE Runtime Environment (build 1.8.0_91-b15)
  Java HotSpot(TM) 64-Bit Server VM (build 25.91-b15, mixed mode)
  We have Java running. inside a Windows docker container which is hosted on a Windows server 2016
  </code></pre>
  
  <p>I want to run a simple java program. The code within java files are as below:</p>
  
  <pre><code>    class Hello{  
  public static void main(String[] args){  
  System.out.println("This is java app \n by using Docker");  
  } 
  }
  </code></pre>
  
  <p>Then as the next step I built the image for the above program. <code>Dockerfile</code> for building java program</p>
  
  <pre><code>FROM testing
  WORKDIR C:\\testing
  RUN javac Hello.java
  CMD ["java","Hello"]
  </code></pre>
  
  <p>When I build the image, I get shown the below error:</p>
  
  <blockquote>
    <p>PS C:\testing> docker build -t testing C:\testing Sending build
    context to Docker daemon 11.78 kB   Step 1/5 : FROM
    java-windows-docker  ---> 534f46817a18    Step 2/5 : WORKDIR
    C:\testing  ---> fc954983c8b0 Removing intermediate container
    5e30071d9159 Step 3/5 : RUN javac Hello.java  ---> Running in
    c91c62ba707c javac' is not recognized as an internal or external
    command, operable program or batch file. The command 'cmd /S /C javac
    Hello.java' returned a non-zero code: 1</p>
  </blockquote>
  
  <p>Any advise on this would be helpful. If possible Kindly help me with the sample Dockerfile to run this java program. I have been working on this for the past two days i can't get this to work. 
  I'm wondering how to set the path inside the docker image and how this actually works.i have also tried to set the path </p>
  
  <pre><code>ENV JAVA_HOME C:\Java\jre1.8.0_91\bin;
  RUN setx PATH %PATH%;%JAVA_HOME%\bin
  RUN setx CLASSPATH %CLASSPATH%;C:\Java\jre1.8.0_91;C:\testing;.;
  </code></pre>
  
  <p>But it doesn't work. I dont know when to set this path while building the java image or running the java program. Kindly advise.Thanks in advance</p>