ganesh
ganesh

Reputation: 899

Java Path Error in Titanium

I have been trying to set up Titanium and Android for 3 days. Still I am stuck with an issue. I am getting this Java related error. I have seen the discussions and forum for this error. I followed all their trials. Still I am unable to make it work. Through command prompt test I can say like path is proper for Java. Even JAVA_HOME variable shows proper path.

I have tried the environmental variables by setting JAVA_HOME value to:

C:\PROGRA~1\Java\jdk1.7.0  

and set PATH value to

C:\PROGRA~1\Java\jdk1.7.0\bin

I can run and compile a sample file Hello.java using command prompt, but still I get this error in Titanium IDE :

[ERROR] Required jarsigner not found<br>
[ERROR] Required javac not found<br>
[ERROR] Required java not found<br>
[ERROR] One or more required files not found - please check your JAVA_HOME environment variable

please help me guys... Thanks in Advance.
GANESH M

Upvotes: 1

Views: 4132

Answers (3)

MrCroft
MrCroft

Reputation: 21

allright, for all those who never managed to make it work even after trying everything you've read. I'm running Win7 x64.

Here are the exact steps I've followed (plus something else I've discovered - step B):

A)

  1. First of all, after installing titanium, the Titanium Home SDK didn't work (error: Could not locate a Titanium Mobile SDK at the given path). The fix for this was to download The "Titanium Mobile SDK 1.7" from inline link text and overwrite everithing in [C:\Users\YourUserName\AppData\Roaming\Titanium] with the folders from that archive (you can backup first if you like - I did it anyway, just in case), but this worked for me... the error for Titanium Home SDK was gone.
  2. Regarding the Java SDK: I've downloaded the 1.6.x_xx version (the 64bit one in my case) - don't know if it would also work with the latest, but after 2 days of trials I'm kind of not in the mood for another un/install of any kind :). And don't worry where you install it, just don't user spaces in the environment variable path/JAVA_HOME.
  3. Grabbed the zip version of android sdk (maybe it would have also worked with the installer, I've just grabbed the zip because I've read there may be problems with the installer - but i think those problems were just because of the incorect environment variable Path to Java). Anyway, zip or installer, in order to make the next step work (in order for titanium to recocnize the android sdk) you need to download/install theese packages (in the SDK Manager.exe of the android sdk) : a) The "Tools" section; b) Android 2.1 and Android 2.2 (api 7 & 8) - maybe just one of them is mandatory, but I just didn't have the patience to check which one after so much time spent fot getting everything to work; c) from the "Extras" section I've installed everything, although I've read that "Google USB" and "Android support" are enough. d) install every other package you want (you don't have to develop for 2.1 or 2.2 only, it's just that they are mandatory to have installed in order for titanium to aknowledge the sdk - if you ask me, it's a bug).

    P.S. I've installed the android sdk in C:\android-sdk - a path with no spaces (ie. Program Files (x86))

  4. in Titanium studio preferences, I've set Android SDK Home to C:\andoird-sdk

  5. Set the environment variable: Right click "My Computer" then "Properties". In the new window, click "Advanced system settings" from the left. In the new window make sure you're in the "Advanced" tab and you should see a button labeled "Environment variables" at the bottom. Click it and in the new window there are 2 lists (User variables and System variables). You need to work with the System variables because in builder.py it checks for system vars, not user. So, in the System variables click "New" and for "Variable name" put JAVA_HOME, as for the "Variable value" put the path to your Java SDK instalation folder (WITHOUT bin ata the end) and make sure it's with no spaces, make sure it's old DOS Mode. Mine is C:\Progra~1\Java\jdk1.6.0_31. Click OK and now in the same list (System variables) look for the variable "Path" and edit it by adding %JAVA_HOME%; at the beginning (make sure you don't miss the semicolon). You should have it at the begining, in case there is another/different path for java in that string there, otherwise it shouldn't matter.

B)

NOW...

After following all the steps above, after creating my first android app, when I've tried to run it I got the followind errors:

  • Required jarsigner/javac/java not found
  • One or more required files not found - please check your JAVA_HOME environment variable

So... From the Titanium SDK (mine is at C:\Users\ MyUserName \AppData\Roaming\Titanium) I've opened mobilesdk\win32\2.0.1.GA2\android\builder.py And went to the def set_java_commands(self) block (mine started at line 268).

I've replaced the string value ("Required jarsigner not found") in one of the errors there with home_jarsigner so now in titanium console, when trying to run the app, I got : C:\Progra~1\Java\jdk1.6.0_31\bin\bin so i've noticed that the os.path.join function adds bin TWICE to the path... HECK IF I KNOW WHY !

In order to fix this, I've changed the following lines by removing "bin" from the path concatenation :

~~~
line 274: home_jarsigner = os.path.join(os.environ["JAVA_HOME"], "bin", "jarsigner.exe")
line 275: home_javac = os.path.join(os.environ["JAVA_HOME"], "bin", "javac.exe")
line 276: home_java = os.path.join(os.environ["JAVA_HOME"], "bin", "java.exe")
~~~

Just removed "bin", from those lines and then everything was fine, my android app launched and i was finally SO SO HAPPY after TWO days of knocking my head against the wall.

Upvotes: 2

Chris Laplante
Chris Laplante

Reputation: 29658

Titanium on 64-bit Windows requires the 32-bit version of the Java SDK. Make sure the 32-bit path is set in your JAVA_HOME environment variable.

Upvotes: 0

Xhandros
Xhandros

Reputation: 36

I was able to fix this issue on Window 7 with these steps:

  1. Left click to our “Computer” Icon and click “Properties” .
  2. The window should appear with the Left Hand Side menu saying “Control Panel Home” , we will click the “Advanced System Settings”.
  3. A popup window appears after that, and then we click the button ” Environment Variables “.
  4. Another window appears and it is for Environment Variables, on the appear part of it, there is a list for System Variables . Let’s add variables or update our “path” variable if it is already existing.
  5. Click ”New” to create a variable JAVA_HOME with your java path ej. C:\Java\jdk1.6.0_20
  6. Edit your PATH variable and add at the begining %JAVA_HOME%; without "bin" because in builder.py the word bin is added.

Upvotes: 2

Related Questions