Could not pre-launch appium: Error: 'java -version' failed. Error: spawn ENOENT

I am trying to automate a android application while running in appium it throws an error

Launching Appium server with command: C:\Program Files (x86)\Appium\node.exe lib\server\main.js --address 127.0.0.1 --port 4723 --app E:\manoimozhli\adt-bundl-android\adt-bundle\sdk\platform-tools\EBill.apk --app-activity .SplashActivity --app-pkg com.vit.ebill --platform-name Android --platform-version 23 --automation-name Appium --log-no-color
warn: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future version. Please upgrade!
info: Welcome to Appium v1.4.13 (REV c75d8adcb66a75818a542fe1891a34260c21f76a)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {“app”:“E:\manoimozhli\adt-bundl-android\adt-bundle\sdk\platform-tools\EBill.apk”,“address”:“127.0.0.1”,“logNoColors”:true,“androidPackage”:“com.vit.ebill”,“androidActivity”:“.SplashActivity”,“platformName”:“Android”,“platformVersion”:“23”,“automationName”:“Appium”}
info: Console LogLevel: debug
info: → POST /wd/hub/session {“desiredCapabilities”:{“appPackage”:“com.vit.ebill”,“appActivity”:“com.vit.ebill.SplashActivity”,“BROWSER_NAME”:“Android”,“VERSION”:“4.4.2”,“platformName”:“Android”,“deviceName”:“Emulator”}}
info: Client User-Agent string: Apache-HttpClient/4.4.1 (Java/1.8.0_65)
error: Failed to start an Appium session, err was: Error: ‘java -version’ failed. Error: spawn ENOENT
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. : BROWSER_NAME, VERSION
info: [debug] Using local app from command line: E:\manoimozhli\adt-bundl-android\adt-bundle\sdk\platform-tools\EBill.apk
info: [debug] Creating new appium session 9daefa45-540f-4e2f-a729-076b12ee324a
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 [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:1057: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 12.964 ms - 208

I have java version “1.8.0_65”
Looking for solution
Thanks in advance

Java is not on your path. It’s possible that you are using an IDE and need to set the path for Java, but you didn’t include that info. You won’t be able to run any Java code in this environment until you set the path correctly.

Hi

i am also facing the same issue. where to put the java -version information in my Eclipse IDE

I did a Google search on this that you are welcome to check out:

https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=eclipse%20set%20java%20path

But the first entry looks promising:
https://wiki.eclipse.org/Eclipse.ini

I encourage you to read up on this issue. If the above doesn’t point you in the right way, a well worded question on the Eclipse discussion board might:

I have added java in eclipse still error exist.

Launching Appium server with command: C:\Program Files (x86)\Appium\node.exe lib\server\main.js --address 127.0.0.1 --port 4723 --app E:\Wallet\app\build\outputs\apk\app-debug-unaligned.apk --app-activity com.wallet.startups.SplashActivity --app-pkg com.product.wallet --pre-launch --platform-name Android --platform-version 23 --automation-name Appium --log-no-color
warn: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future version. Please upgrade!
info: [debug] Starting Appium in pre-launch mode
info: Pre-launching app
error: Could not pre-launch appium: Error: ‘java -version’ failed. Error: spawn ENOENT

Appium server process ended

The IDE is telling you that it can’t even do a simple ‘java -version’. So whatever you did you did not do correctly.

Can you tell the procedure for installing appium in proper way and also mention the specific version.

I just did a quick google search for this. I found this page, which seems to be pretty thorough:

https://university.utest.com/how-to-set-up-your-first-android-automation-project-with-appium/

I’m sure there are others out there. If I find a better one I’ll post it.

Hi All,

Adding system32 location “%SystemRoot%\system32” as PATH variable under System variables will resolve the issue. You are getting this 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

Thanks a lot abdul . Its working fine thanks again…:slight_smile: