Program launch failed. Unable to locate Java VM. Please set JAVA_HOME environment variable.

You must Login before you can answer or comment on any questions.

Hi all. I am working on titanium android on windows 7 environment. I wrote a simple application for printing hello world in titanium android and now i just thought of the way to create the apk so that i can plan for distributing any future applications easily. I clicked on the distribute icon and i got the a dialog where i entered distribution location , keystore location , password and alias name and clicked on publish. But it ended with an error.

[ERROR] Program launch failed. Unable to locate Java VM. Please set JAVA_HOME environment variable. [ERROR] Unabled to prepare JavaScript for packaging. Error code 4.

I tried following the link but i didnt get this working. Could anyone suggest me how to solve this issue. Thanks in advance

— asked 1 year ago by sharath g
1 Comment
  • Hi Sharath, can you tell about windows architecture? 64 bit or 32 bit?

    — commented 1 year ago by Ashish Nigam

3 Answers

Accepted Answer

Set environment variables

Note that both (JAVA_HOME & Path ) variables are added as system variables


C:\Program Files\Java\jdk1.6.0_37



there are already some paths added by system in Path variable , don't remove them. In my computer path look like


C:\android-sdk\platforms\android-16\;C:\android-sdk\tools\;%JAVA_HOME%\bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Windows Live\Shared;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\

Setting Android Sdk Path :

After adding these path you have to give android sdk path to your titanium. Open titanium studio ,there will be a window tab on top (title bar) after clicking it you will see preferences in bottom. On clicking preferences you can see Titanium Studio on left,expand it and click titanium . Browse and point your android sdk home directory ,apply and ok

— answered 1 year ago by Muhammad Adnan
answer permalink
  • Thanks for the reply Muhammad Adnan. I set the environment variables. My JAVA_HOME path is C:\Program Files\Java\jdk1.6.0_38;

    and my path is

    %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.6.0_38\bin;C:\Program Files (x86)\nodejs\;E:\android-sdk-windows\tools;

    and set the same sdk in titanium too. But i am getting the same error

    [ERROR] Program launch failed. Unable to locate Java VM. Please set JAVA_HOME environment variable. [ERROR] Unabled to prepare JavaScript for packaging. Error code 4.

    Is there anything more to do?

    — commented 1 year ago by sharath g

  • you have to add andorid-sdk, JAVA_HOME nad JDK path at front of path . C:\android-sdk\platforms\android-16\;C:\android-sdk\tools\;%JAVA_HOME%\bin; C:.......system paths

    — commented 1 year ago by Muhammad Adnan

  • run javac command to varify java installation Android Settings

    — commented 1 year ago by Muhammad Adnan

  • Show 13 more comments

i am setting the java jdk path directly instead of using the JAVA_HOME variable. Does it have any impact?

Wasted lot of time in doing all these crappy stuff. Answer lies in following:

  1. If Titanium IDE is 32 bit installation, You have to use 32 bit JDK otherwise 64 bit for both.
  2. Also I have manually added variable to following batch ( C:\Users\temp\AppData\Local\Titanium Studio\studio3.bat ) as SET JAVA_HOME="c:\jdk1.7.0.60"

where c:\jdk1.7.0.60 is 32 bit installation for me

I guess Adnan's intent by including JDK and SDK path at the very begining of PATH was to ensure that its not the JDK and SDK path in use and avoid any duplicate hit of same in path,

Your Answer

Think you can help? Login to answer this question!