org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: 'java -version' failed. Error: spawn ENOENT)
<pre><code>package android.appium;


import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import org.testng.annotations.AfterTest;

import io.appium.java_client.AppiumDriver;

import java.net.URL;
import java.net.MalformedURLException;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;



public class SimpleTestCalc {

    WebDriver driver;
  @BeforeTest
  public void setup () throws MalformedURLException {
      DesiredCapabilities capabilities=new DesiredCapabilities();
        capabilities.setCapability("deviceName","ZX1PC2JJPM");
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");
        capabilities.setCapability(CapabilityType.VERSION, "5.1");
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("appPackage", "com.android.calculator2");
        capabilities.setCapability("appActivity", "com.android.calculator2.calculator");
        URL url1=new URL("http://127.0.0.1:4723/wd/hub");
        driver=new RemoteWebDriver(url1,capabilities);
        driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
  }

  @Test
  public void sum() {
      driver.findElement(By.name("2")).click();
        driver.findElement(By.name("5")).click();
        driver.findElement(By.name("+")).click();
        driver.findElement(By.name("5")).click();
        driver.findElement(By.name("=")).click();
        String result=driver.findElement(By.className("android.widget.EditText")).getText();
        System.out.print("Sum of values is"+result);

  }

  @AfterTest
  public void reset() {
        driver.quit();
  }

}
</code></pre>

<p>Output:</p>

<p>[TestNG] Running:</p>

<blockquote>
  <p>C:\Users\vgaarlap.ORADEV\AppData\Local\Temp\testng-eclipse--1070157593\testng-customsuite.xml</p>
  
  <p>FAILED CONFIGURATION: @BeforeTest setup
  org.openqa.selenium.SessionNotCreatedException: A new session could
  not be created. (Original error: 'java -version' failed. Error: spawn
  ENOENT) (WARNING: The server did not provide any stacktrace
  information) Command duration or timeout: 149 milliseconds Build info:
  version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'
  System info: host: 'VGAARLAP-LAP', ip: '192.168.56.1', os.name:
  'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version:
  '1.8.0_31' Driver info: org.openqa.selenium.remote.RemoteWebDriver    at
  sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at
  sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at
  sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)</p>
</blockquote>