Not able to run Appium {"message":"A new session could not be created. (Original error: 'java -version' failed

Checking if an update is available
Update not available
Starting Node Server
info: Welcome to Appium v1.3.7 (REV 72fbfaa116d3d9f6a862600ee99cf02f6d0e2182)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {“app”:“D:\apk\Calculator.apk”,“address”:“127.0.0.1”,“logNoColors”:true,“deviceName”:“emulator-5554”,“platformName”:“Android”,“platformVersion”:“18”,“automationName”:“Appium”}
info: Console LogLevel: debug
info: → POST /wd/hub/session {“desiredCapabilities”:{“appPath”:“D:\apk\Calculator.apk”,“platformVersion”:“4.4”,“platformName”:“Android”,“deviceName”:“tt”,“appActivity”:“com.android.calculator2.Calculator”,“appPackage”:“com.android.calculator2”}}
info: Client User-Agent string: Apache-HttpClient/4.3.2 (java 1.5)
info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : appPath
error: Failed to start an Appium session, err was: Error: ‘java -version’ failed. Error: spawn ENOENT
info: [debug] Using local app from command line: D:\apk\Calculator.apk
info: [debug] Creating new appium session fb45c483-63bb-4776-bf90-440fa066f539
info: Starting android appium
info: [debug] Getting Java version
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] Error: ‘java -version’ failed. Error: spawn ENOENT
at C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:1032:17
at exithandler (child_process.js:633:7)
at ChildProcess.errorhandler (child_process.js:649:5)
at ChildProcess.EventEmitter.emit (events.js:95:17)
at Process.ChildProcess._handle.onexit (child_process.js:795:12)
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: ‘java -version’ failed. Error: spawn ENOENT)”,“origValue”:“‘java -version’ failed. Error: spawn ENOENT”},“sessionId”:null}
info: ← POST /wd/hub/session 500 13.133 ms - 208

Please help me in solving this error

Hi Am not sure, but please try by adding latest java-Client-2.1 jar to the project and try it once.

i got this one… i think you are using java 1.5 version… which is not compatible with Appium… Please install java latest version 8 which is very much compatible with Appium. Please let me know the status.

Thanks,

Hi Suresh,

Thanks for the reply.I am using java 1.8 version. Please check the above image.

Thanks

Are you using lastest java-client-2.1 jar in ur project?

And also please me make sure that the Enviroment variable PATH is given correctly or not…

Yes I am using java-client-2.1 jar. Please let me knw which is suitable for appium.

I am hoping the culprit is ChromeDriver. Upgrade your chromedriver as described in the below link.

Please check below thread for more details.

Access stock browser or Chrome browser in Emulator

ok thank you…Will try this

@UD Thank you…I tried it. It is not working

Once while running make sure that no other Chrome browser is opened. Open Task Manager and close all the chrome browsers.

Thank you…It is not working for me:(

Hi @Manasa ,

The same error i got previously…In my case i was using build.xml for compilation.so in that i had java version as 1.8.x , but in my PC it was 1.7.x …so i made a change for java version to 1.7.x in build.xml , got resolved.

Hope this info will helps you :smile:

Hi Bhaskar,

Thanks for reply.I am using java version 1.7 in build.xml and both versions 7 and 8 are present in my pc.

Which Appium version are u using?.. if its not latest try it with latest one. Am using Appium 1.3.7.2 version.

Sorry I haven’t mentioned it… u have Installed JRE system Library [jdk1.8.0_20] (java development Kit) but for me I have add JRE System Library[jre1.8.0_45] (java Run time environment)… Please check it once.

hi @Manasa ,
May i know , did u came across with the solution? If yes, please let me know how it was done…!!!

Thanks,
Vj Bhaskar.

Hi All,

Adding system32 location “%SystemRoot%\system32” as PATH variable under System variables will resolve the issue because basically appium might need something from system32 directory to interact with adb command during run time.

Hope this resolves the issue.

Regards
@Abdul_Sathar_Beigh

Hi all,

I am trying to run appium @ ubuntu.

I have set the desired capabilities in my code but when i execute it, the app closes as soon as it launches hence all my test fails. I have attached the screenshot of the terminal. It is taking force-stop as one of the arguments which i am not passing anywhere in my code. Please see my screenshot and share a solution. TIA.

I got same kind of issue Not able to run Appium program {“message”:”A new session could not be created. (Original error: ‘java -version’ failed
My environment

Jdk jdk1.8.0_101 and JRE 1.8.0_101
Classpath set properly
Eclipse Kepler Service Release 2 with JDK1.8 support

I observed that Java comment gives Error to initialization of VM (java/lang/NoClassDefFoundError: java/lang/Object)

Solution:

  1. Uninstall all Java packages of all versions.(Uninstalled JRE and JDK completely)
  2. Download last packages Java SE or JRE for your 32 or 64 Windows and install it.
  3. First install JRE and second is Java SE( Installed JRE 1.8 then Installed JDK 1.8)
    Set Classpath check Java coomand works or not and its working also able to execute the Appium program