Original error: 'java -version' failed. Error: spawn ENOENT

Hi,

Im encountering the below error ,when I try to execute my tests:
A new session could not be created. (Original error: ‘java -version’ failed. Error: spawn ENOENT) (WARNING: The server did not provide any stacktrace information)

Below is the APPIUM log trace:

info: Welcome to Appium v1.3.4 (REV c8c79a85fbd6870cd6fc3d66d038a115ebe22efe)
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,“platformName”:“Android”,“platformVersion”:“17”,“automationName”:“Appium”}
info: Console LogLevel: debug
info: → POST /wd/hub/session {“desiredCapabilities”:{“platformVersion”:“4.2”,“deviceName”:“test”,“platformName”:“Android”,“appActivity”:“com.android.calculator2.Calculator”,“browserName”:“”,“appPackage”:“com.android.calculator2”}}
info: Client User-Agent string: Apache-HttpClient/4.3.4 (java 1.5)
info: [debug] Using local app from command line: D:\apk\Calculator.apk
info: [debug] Creating new appium session 0b165cb9-2ed2-44c3-b29c-d1375c4d610e
error: Failed to start an Appium session, err was: Error: ‘java -version’ failed. Error: spawn ENOENT
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 D:\AppiumForWindows\AppiumForWindows-1.3.4.1\Appium\node_modules\appium\lib\devices\android\android-common.js:1033: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 39.414 ms - 208

Kindly help to resolve this issue.

Hi,

Could you check if JDK 1.7 is installed on your machine?

Thanks,
Sujata

Hello Sujata,
I have installed JDK 1.7 on my machine, but still I am getting the same error.

Regards,
Akshatha

Hi,

Is Java JDK location added to path (System environment variable), and also when you type “java -version” on a new command window, what message do you get?
Could you verify above?

Thanks,
Sujata

yes sujata I have added the path of java in environment variables.
I get the message as java version “1.7.0_67”

Hi Aksatha,

Is your issue resolved?

Thanks,
Sujata

No sujata.
That issue is still there

Thank you

Hi @Akshatha We also getting the same issue , Please let me know the solution if the issue has been solved from your side.

Hi Rakesh,

did you get any resolution for the above issue?

Thanks,
Rohit

No… That issue still exists.

Thanks,
Akshatha

check u have added java home in environment variable

if already added then try below link

http://www.mytechtricks.com/2014/10/resolved-appium-could-not-find-devices-restarting-adb-server-and-enoent-issue.html

2 Likes

@guneetgarg solution worked for me. @Akshatha, you may try updating system 32 in path.

Issue got resolved.
I added %SystemRoot%system32 in path variable of System variable.

Regards,
Akshatha

1 Like

Thanks a lot guys. . am stuck up with this issue for two days. but now got solved.

Thanks so much

In Android Home give path till SDK only … apart from this don’t give any path to android home

that would work for sure.
C:\adt-bundle-windows-x86_64-20131030\adt-bundle-windows-x86_64-20131030\sdk

Hi All,

I am facing the same error from past few days. Not able to figure out where it went get wrong. Initially it was working fine but I have done some changes so not sure what went wrong.

Configurations:

java version- 1.8.0_66
Appium version - 1.4.13.1
Environment Variables are perfectly set i…e ANROID_HOME , JRE_HOME , PATH, JAVA_HOME

Could any one please suggest some solution for it.

Thanks
Sakshi

I added %SystemRoot%system32 in path variable of System variable.

Add it in environment variable and check.

Hi Akshatha,

Thanks for the reply,

I have resolved it yesterday itself.

I was giving incorrect path of SDK tools in system variables > Path