Computer Hope

Microsoft => Microsoft DOS => Topic started by: Jerry Ford on November 21, 2014, 06:49:26 PM

Title: luanch of executable from within .bat file fails
Post by: Jerry Ford on November 21, 2014, 06:49:26 PM
I am trying to get started with Google's Android Studio. I have installed the studio software and the Android SDK on my d:\ drive, as follows...

d:\dev\android\android-studio
d:\dev\android\sdk

In the SDK, there is a .bat file, android.bat, that in turn calls another .bat file, find_java.bat.

When I run android.bat, it fails to launch the second file...

d:\dev\android\sdk\tools>android
'"d:\dev\android\sdk\tools\lib\\find_java.bat" -s' is not recognized as an internal or external command,
operable program or batch file.

The following command entered on the command line does in fact run the find_java.bat file...

d:\dev\android\sdk\tools\lib\\find_java.bat -s

...but the find_java.bat file cannot be found from within the android.bat file.

I have sought help from Google, and the engineer assigned to the problem reports that when he runs android.bat on his machine, it works fine.

Any suggestions as to why the same .bat file works on the Google machine and not on mine?

The Google OS is Windows 7 Home Premium x64, mine is Windows 7 Ultimate x64.

Thanks.

Jerry
Title: Re: luanch of executable from within .bat file fails
Post by: Geek-9pm on November 21, 2014, 07:30:35 PM
Well, the two commands are not the same.
Please copy and paste the command so we can see it.

The -s must come right after the find command.
Title: Re: luanch of executable from within .bat file fails
Post by: Squashman on November 21, 2014, 10:10:16 PM
Would probably help to see the contents of each batch file.
Title: Re: luanch of executable from within .bat file fails
Post by: Jerry Ford on November 24, 2014, 05:59:11 PM
Sorry if I was not precise in my initial description of the problem. I was trying to keep my discussion brief.  But it's a complicated situation that, I guess, requires more verbiage.

When I install the Android SDK, the installer offers to run the SDK Manager at the conclusion of the installation.  I say yes, and I get the following error message...

Failed to execute tools\android.bat:
The system cannot find the file specified.

But I have already set an Environment Variable, ANDROID_SDK_HOME, to d:\dev\android\sdk and added that variable to my PATH, so I expect there to be no problem reaching tools\android.bat from anywhere on the system. 

When I open a command window and cd to the SDK directory and run android.bat manually, I get this...

D:\dev\android\sdk\tools>android
'"D:\dev\android\sdk\tools\lib\\find_java.exe" -s' is not recognized as an internal or external command,
operable program or batch file.

There is now a problem running another file, find_java.exe, in the tools\lib folder. 

Actually, android.bat runs lib\find_java.bat, which in turn attempts, and fails, to run find_java.exe, with this command...

for /f "delims=" %%a in ('"%~dps0\find_java.exe" -s') do set java_exe=%%a

And yet, if I go to the tools directory in a command window and enter that exact same command that just failed, it does in fact run...

D:\dev\android\sdk\tools>lib\find_java.exe -s
C:\PROGRA~3\Oracle\Java\javapath\java.exe
D:\dev\android\sdk\tools>

(And yes, I have tried it with and without the double quotes, and with and without the double slash in the path. Nothing works.)

The batch files, BTW, appear to be correct, with no broken syntax.  These files do run on other systems.  In fact, as a test, I installed the SDK on my wife's machine and the batch files all work fine.  The difference:  My machine, where they don't work, runs Windows 7 Ultimate, my wife's machine runs Windows 7 Home Professional.  (And no, using my wife's machine for Android development is not an option. I need to make it work on mine.)

Thanks.

Jerry
Title: Re: luanch of executable from within .bat file fails
Post by: foxidrive on November 25, 2014, 06:23:13 AM
I get the following error message...

Failed to execute tools\android.bat:
The system cannot find the file specified.

The message shows a relative path is being used.


Title: Re: luanch of executable from within .bat file fails
Post by: Jerry Ford on November 25, 2014, 01:35:51 PM
foxidrive:

Yes, a relative path.  That particular error message is displayed when SDK Manager.exe runs. That .exe is in the sdk folder, android .bat is in the sdk\tools folder, so the .bat file is in the tools folder relative to the exe.

But it makes no difference how I initiate the process, something is preventing the android tools from traversing the Windows path. 

Again, these files do all work on some systems.  I'm pretty sure it is not a coding error in the various .exe/.bat files. My current best guess is there is a permission conflict.  I just don't know what permissions, where to find them, and how to fix the problem.  I've looked at the security settings in various Windows peroperty dialogs for the files and folders, nothing works. 

Except it does work, on other people's Windows machines.  Just not on mine.
Title: Re: luanch of executable from within .bat file fails
Post by: Squashman on November 25, 2014, 01:54:02 PM
Do you get a UAC prompt when running the installer?

What are the user account control settings for the computers that it works on and your computer?
Title: Re: luanch of executable from within .bat file fails
Post by: Squashman on November 25, 2014, 01:58:45 PM
From the Android Developer Website.
Quote
On some Windows systems, the launcher script does not find where Java is installed. If you encounter this problem, you need to set an environment variable indicating the correct location.
Select Start menu > Computer > System Properties > Advanced System Properties. Then open Advanced tab > Environment Variables and add a new system variable JAVA_HOME that points to your JDK folder, for example C:\Program Files\Java\jdk1.7.0_21.
Title: Re: luanch of executable from within .bat file fails
Post by: Jerry Ford on November 25, 2014, 06:56:09 PM
squashman:

JAVA_HOME has been set on my system for a long time prior to trying to use Android, and it remains pointed at a valid JDK.

Jerry
Title: Re: luanch of executable from within .bat file fails
Post by: Jerry Ford on November 25, 2014, 10:42:28 PM
squashman:

If I run the installer as administrator, I get the prompt.  If not, no prompt. Either way, makes no difference, files still don't run correctly.

User account control properties are the same on both computers (mine, Windows 7 Ultimate, where the SDK files don't work, and my wife's, Windows 7 Home Pro, where the SDK files do work)...

Default - Notify me only when programs try to make changes to my computer.

Something I had not noticed before, but in the SDK installer .exe's properties dialog, there is this message at the bottom...

Security - This file came from another comptuer and might be clocked to help protect the computer.

When I click the [ Unblock ] button, the text goes grey (and is not shown on subsequent openings of the properties dialog), but it makes no difference, the executables still do not work correctly.
Title: Re: luanch of executable from within .bat file fails
Post by: foxidrive on November 26, 2014, 12:35:06 PM
The batch files, BTW, appear to be correct, with no broken syntax.

Your question is sorta like saying:  "I wrote some source code and it doesn't work - can you tell me what's wrong with it?" and you don't show anyone the source code.

Code: [Select]
for /f "delims=" %%a in ('"%~dps0\find_java.exe" -s') do set java_exe=%%a
On a casual examination, the code above will only work if the find_java.exe is in the same folder as the batch file.
Title: Re: luanch of executable from within .bat file fails
Post by: patio on November 26, 2014, 02:09:18 PM
Would probably help to see the contents of each batch file.

This says it all...
Title: Re: luanch of executable from within .bat file fails
Post by: Jerry Ford on November 26, 2014, 03:01:16 PM
Okay, here are the two files where it starts. There are more, but I can't copy the whole SDK.  It is a free download though, if you really want to purse all files involved. Get it here (you'll need to create an account, but,again, free)...

https://developer.android.com/sdk/index.html?hl=i

The SDK comes in an executable installer.  When I run it (with or without administrative privileges, doesn't seem to matter, and it worked fine without on the Win7 Home machine where the SDK works), the last panel in the installer asks if I want to start the SDK Manager, which is to say run the file SDK Manager.exe that is located in the SDK top level folder.  When I do, I get the error message Failed to execute  tools\android.bat:, error 2 The system cannot find the file specified.

When I open a command window and cd to the SDK tools folder, I run android.bat from the command line and get the error message

'"D:\dev\android\sdk\tools\lib\\find_java.exe" -s' is not recognized as an internal or external command,
operable program or batch file.

The executable find_java.exe, which the message references, is actually called from within find_java.bat, both of which are in the tools\lib folder.

Here's android.bat (in the SDK's tools folder), followed by find_java.bat...

@echo off
rem Copyright (C) 2007 The Android Open Source Project
rem
rem Licensed under the Apache License, Version 2.0 (the "License");
rem you may not use this file except in compliance with the License.
rem You may obtain a copy of the License at
rem
rem      http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

rem Useful links:
rem Command-line reference:
rem   http://technet.microsoft.com/en-us/library/bb490890.aspx

rem don't modify the caller's environment
setlocal

rem Set up prog to be the path of this script, including following symlinks,
rem and set up progdir to be the fully-qualified pathname of its directory.
set prog=%~f0

rem Grab current directory before we change it
set work_dir=%cd%

rem Change current directory and drive to where the script is, to avoid
rem issues with directories containing whitespaces.
cd /d %~dp0


rem Check we have a valid Java.exe in the path.
set java_exe=
call lib\find_java.bat
if not defined java_exe goto :EOF

set jar_path=lib\sdkmanager.jar;lib\swtmenubar.jar

rem Set SWT.Jar path based on current architecture (x86 or x86_64)
for /f "delims=" %%a in ('"%java_exe%" -jar lib\archquery.jar') do set swt_path=lib\%%a

:MkTempCopy
    rem Copy android.bat and its required libs to a temp dir.
    rem This avoids locking the tool dir in case the user is trying to update it.

    set tmp_dir=%TEMP%\temp-android-tool
    xcopy %swt_path% %tmp_dir%\%swt_path% /I /E /C /G /R /Y /Q > nul
    copy /B /D /Y lib\common.jar         %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\commons-codec*     %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\commons-compress*  %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\commons-logging*   %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\dvlib.jar          %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\guava*             %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\httpclient*        %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\httpcore*          %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\httpmime*          %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\layoutlib-api.jar  %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\org-eclipse-*      %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\sdk*               %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\swtmenubar.jar     %tmp_dir%\lib\        > nul

    rem jar_path and swt_path are relative to PWD so we don't need to adjust them, just change dirs.
    set tools_dir=%cd%
    cd /d %tmp_dir%

:EndTempCopy

rem The global ANDROID_SWT always override the SWT.Jar path
if defined ANDROID_SWT set swt_path=%ANDROID_SWT%

if exist "%swt_path%" goto SetPath
    echo ERROR: SWT folder '%swt_path%' does not exist.
    echo Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
    goto :EOF

:SetPath
rem Finally exec the java program and end here.
REM set REMOTE_DEBUG=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
call "%java_exe% %REMOTE_DEBUG%" "-Dcom.android.sdkmanager.toolsdir=%tools_dir%" "-Dcom.android.sdkmanager.workdir=%work_dir%" -classpath "%jar_path%;%swt_path%\swt.jar" com.android.sdkmanager.Main %*

rem EOF


Here's find_java.bat...

@echo off
rem Copyright (C) 2007 The Android Open Source Project
rem
rem Licensed under the Apache License, Version 2.0 (the "License");
rem you may not use this file except in compliance with the License.
rem You may obtain a copy of the License at
rem
rem      http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

rem This script is called by the other batch files to find a suitable Java.exe
rem to use. The script changes the "java_exe" env variable. The variable
rem is left unset if Java.exe was not found.

rem Useful links:
rem Command-line reference:
rem   http://technet.microsoft.com/en-us/library/bb490890.aspx

rem Check we have a valid Java.exe in the path. The return code will
rem be 0 if the command worked or 1 if the exec failed (program not found).
for /f "delims=" %%a in ('"%~dps0\find_java.exe" -s') do set java_exe=%%a
if not defined java_exe goto :CheckFailed

:SearchJavaW
rem Check if we can find a javaw.exe at the same location than java.exe.
rem If that doesn't work, just fall back on the java.exe we just found.
for /f "delims=" %%a in ('"%~dps0\find_java.exe" -s -w') do set javaw_exe=%%a
if not exist "%javaw_exe%" set javaw_exe=%java_exe%
goto :EOF


:CheckFailed
echo.
echo ERROR: No suitable Java found. In order to properly use the Android Developer
echo Tools, you need a suitable version of Java JDK installed on your system.
echo We recommend that you install the JDK version of JavaSE, available here:
echo   http://www.oracle.com/technetwork/java/javase/downloads
echo.
echo If you already have Java installed, you can define the JAVA_HOME environment
echo variable in Control Panel / System / Avanced System Settings to point to the
echo JDK folder.
echo.
echo You can find the complete Android SDK requirements here:
echo   http://developer.android.com/sdk/requirements.html
echo.
goto :EOF
Title: Re: luanch of executable from within .bat file fails
Post by: Lemonilla on November 26, 2014, 09:47:33 PM
Try changing this line:
for /f "delims=" %%a in ('"%~dps0\find_java.exe" -s') do set java_exe=%%a
to this:
for /f "delims=" %%a in ('"%~dps0find_java.exe" -s') do set java_exe=%%a


Also check that path to make sure that find_java.exe actually exists.
Title: Re: luanch of executable from within .bat file fails
Post by: Jerry Ford on November 27, 2014, 12:03:51 AM
Lemonilla:

The change you suggest replaces the double backslash with a single backslash in the path to find_java.exe, so  D:\dev\android\sdk\tools\lib\\find_java.exe becomes D:\dev\android\sdk\tools\lib\find_java.exe but either one works as a valid Windows path.  And yes, find_java.exe does exist at that location, and when I run it from the command line it returns a valid path...

D:\dev\android\sdk\tools>lib\find_java.exe
C:\ProgramData\Oracle\Java\javapath\java.exe
D:\dev\android\sdk\tools>

...which does point to the java executable in my JDK...

D:\dev\android\sdk\tools>C:\ProgramData\Oracle\Java\javapath\java.exe -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

But attempts to run the Android SDK Manager or andriod.bat still fail.

Title: Re: luanch of executable from within .bat file fails
Post by: foxidrive on November 27, 2014, 07:37:19 AM
Some tool called two files the same name and put them in the same folder.
Yes it can work, but no, it's not a good plan.
Quote
The executable find_java.exe, which the message references, is actually called from within find_java.bat, both of which are in the tools\lib folder.
I'm not sure which chicken or egg came first here.

'"D:\dev\android\sdk\tools\lib\\find_java.exe" -s' is not recognized as an internal or external command, operable program or batch file.


Failed to execute tools\android.bat
Title: Re: luanch of executable from within .bat file fails
Post by: Lemonilla on November 27, 2014, 09:27:24 AM
Try running a call "%~pds0\find_java.exe" -s or start "%~pds0\find_java.exe" -s.  That might fix the issue.  Are you swapping drives between the .bat and find_java.exe?
Title: Re: luanch of executable from within .bat file fails
Post by: Jerry Ford on November 27, 2014, 12:31:58 PM
foxidrive:  Yeah, I know, same name, different extensions?  Probably written by someone more experienced with Linux/Unix programming than Microsoft. Also note that the command cited in the error message---D:\dev\android\sdk\tools\lib\\find_java.exe---fails only when run from within the SDK files.  If I enter that on a command line, it returns a string containing a path to the java.exe, as it is supposed to do:

D:\dev\android\sdk>d:\dev\android\sdk\tools\lib\\find_java.exe
C:\ProgramData\Oracle\Java\javapath\java.exe

But if I change the command line to run the .bat file instead of the .exe, the .bat file runs but fails on the call to run the .exe...

D:\dev\android\sdk>d:\dev\android\sdk\tools\lib\\find_java.bat
'start "d:\dev\android\sdk\tools\lib\\find_java.exe" -s' is not recognized as an internal or external command,
operable program or batch file.

Lemonilla: 

> Try running a call "%~pds0\find_java.exe"

Did you mean ~dps0?  I tried with both call and start, still fails.

foxidrive/Lemonilla:  Thing is, all of these files do work in other Windows environments, just not my particular machine. 

Since they do run without error on some machines, I am not convinced my problem is a syntax thing in the bat files. 

I'm currently thinking some permission setting was set on the original files or directories (Linux/Unix vs Microsoft again) and somehow on my system there is a conflicting security setting.  At least, that's my current best guess.

Jerry
Title: Re: luanch of executable from within .bat file fails
Post by: Squashman on November 27, 2014, 01:42:38 PM
https://groups.google.com/forum/m/#!forum/android-developers
I think you would be better off getting help on the Google group.
Title: Re: luanch of executable from within .bat file fails
Post by: Geek-9pm on November 27, 2014, 02:04:02 PM
Just an observation.
It does run on some machines with similar setups.
Therefore, if it were me, I would put do the project on a spare backup system keep for just that kind of scenario. I would do a fresh install of Windows and and then  install all stuff needed for the project. That is a "brute force" method that take a few hours. In contrast, fining the exact error make take days.

Not really my idea. Credit is to Alexander the Great.
To Cut the Gordian Knot (http://ancienthistory.about.com/od/dmen/ss/070709damoclessword_4.htm)
 :)
Title: Re: luanch of executable from within .bat file fails
Post by: foxidrive on November 27, 2014, 04:41:25 PM
foxidrive/Lemonilla:  Thing is, all of these files do work in other Windows environments, just not my particular machine. 

Jerry, with access to the machine it would probably take less than 5 minutes to see why it fails.

To do it here we have to test things bit by bit - put this in a batch file called testme.bat and run it in the folder with find_java.exe and see what it prints. 

Code: [Select]
@echo off
for /f "delims=" %%a in ('"%~dps0\find_java.exe" -s') do echo "%%a"
pause
Title: Re: luanch of executable from within .bat file fails
Post by: Jerry Ford on November 30, 2014, 12:36:04 PM
foxidrive:

Sorry, your reply requesting results of a run of your testme.bat got shunted to my spam folder and I did not see it until just now.

Here's the output...

D:\dev\android\sdk\tools\lib>testme
'"D:\dev\android\sdk\tools\lib\\find_java.exe" -s' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .


Jerry
Title: Re: luanch of executable from within .bat file fails
Post by: Jerry Ford on November 30, 2014, 12:41:04 PM
Squashman:

> I think you would be better off getting help on the Google group.

Thanks for the link. I am pursuing that avenue.

But I don't think it is necessarily a Google/Android problem.  The Android tools do work. There's just something in my Microsoft environment that is preventing them from working on my machine. That seems to suggest the fix is in the Microsoft environment.

Jerry
Title: Re: luanch of executable from within .bat file fails
Post by: Geek-9pm on November 30, 2014, 12:57:52 PM
....
But I don't think it is necessarily a Google/Android problem.  The Android tools do work. There's just something in my Microsoft environment that is preventing them from working on my machine. That seems to suggest the fix is in the Microsoft environment.
...
Which is why I suggested using another PC with a fresh install just to see. Or the  OP could just shrink the Hard Drive and make another partition and install a basic copy of windows.
Title: Re: luanch of executable from within .bat file fails
Post by: Jerry Ford on November 30, 2014, 05:19:16 PM
Geek:

I have already installed it on a separate Win7 system, and yes it does work.  What I don't know is what is the difference in the two setups.

The obvious difference--Win7 Ultimate vs. Win7 Home Pro---seems to be not significant.  I have been told by an engineer at Google the the software works fine on his Win7 Ultimate machine, which he set up in response to my issue.

So, I have done what you advised---demonstrated that it works on other Win7 setups.

So that means it must be a Windows environment thing, right? But which thing? Where to fix?

Jerry
Title: Re: luanch of executable from within .bat file fails
Post by: Geek-9pm on November 30, 2014, 05:40:10 PM
OK. This is the way to solve tough problem. You divide and conquer.
You now know for yourself it does work and you can compare the two environments.
Look at the environmental values for both computers.
How to they differ?
What about he path setting for both machines?
Last, compare the registry of both machines.
Here is a link that might relate to how to differentiate registry settings.
http://support.microsoft.com/KB/171780
Quote
SUMMARY
How can you compare registry entries before and after an upgrade, the installation of a new software package, or between two computers?
Doing a registry study is as much  fun as doing memory dumps.
- OR -
Just use the machine that works.
Fix the mystery later.  :)
Title: Re: luanch of executable from within .bat file fails
Post by: Squashman on November 30, 2014, 06:12:14 PM
foxidrive:

Sorry, your reply requesting results of a run of your testme.bat got shunted to my spam folder and I did not see it until just now.

Here's the output...

D:\dev\android\sdk\tools\lib>testme
'"D:\dev\android\sdk\tools\lib\\find_java.exe" -s' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .


Jerry
that should not be possible if find_java.exe is in the same folder as the batch file.
Title: Re: luanch of executable from within .bat file fails
Post by: Jerry Ford on November 30, 2014, 07:46:51 PM
> that should not be possible if find_java.exe is in the same folder as the batch file.

And therein lies my dilemma. 

The .exe is in fact in the same folder as the .bat file. 

If I open a command window and cd to d:\dev\android\sdk\tools\lib and run .\find_java.bat, I get the "find_java.exe...is not recognized as a...command" error...

D:\dev\android\sdk\tools\lib>.\find_java.bat
'start "D:\dev\android\sdk\tools\lib\\find_java.exe" -s' is not recognized as an internal or external command,
operable program or batch file.

And yet, if I run .\find_java.exe from that very same command line, the .exe runs successfully, returning the path to java.exe as a string...

D:\dev\android\sdk\tools\lib>.\find_java.exe
C:\Program Files\Java\jdk1.8.0_11\bin\java.exe
D:\dev\android\sdk\tools\lib>

Jerry
Title: Re: luanch of executable from within .bat file fails
Post by: Geek-9pm on November 30, 2014, 08:12:24 PM
The problem is in the SDK. This was documented elsewhere.
The OP needs to check which versions he has.
http://stackoverflow.com/questions/26293528/error-launching-sdk-manager-find-java-exe-is-not-compatible-with-the-version-o
Quote
You don't say in your question, but it sounds like you have recently updated your SDK to 23.0.4. If that's the case, there's a bug in the release documented here:

https://code.google.com/p/android/issues/detail?id=77289

The bug is that there was a bad version of the find_java.exe utility shipped with that version. This is fixed in 23.0.5, which is out now.
Title: Re: luanch of executable from within .bat file fails
Post by: Jerry Ford on November 30, 2014, 08:18:22 PM
> The problem is in the SDK. This was documented elsewhere.

Any clues as to when or where this was documented?  I've been scouring the internet, asking everybody, including Google, and nobody has yet been able to tell me what the problem is, or what in the SDK is at fault.

> The OP needs to check which versions he has.

Sorry for my ignorance, but what do you mean by OP? and which versions of what?

Jerry
Title: Re: luanch of executable from within .bat file fails
Post by: Squashman on November 30, 2014, 08:34:21 PM
OP = Original Poster.
Title: Re: luanch of executable from within .bat file fails
Post by: Geek-9pm on November 30, 2014, 08:35:59 PM
Jerry, you are the OP.
Sorry I was late to update my post.
The SDK 23.0.4 was bad.
https://code.google.com/p/android/issues/detail?id=77289
Specifically, it is the version of find_jave that does not work right. That is what the Google link above claims. If so, you just need to use the good version of find_java and it should work.
The are dozens, maybe hundreds of posts about this problem.
Hope that is the real problem.
Title: Re: luanch of executable from within .bat file fails
Post by: foxidrive on November 30, 2014, 10:21:54 PM
D:\dev\android\sdk\tools\lib>testme
'"D:\dev\android\sdk\tools\lib\\find_java.exe" -s' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .

Change the code in the same batch file and try this:

Code: [Select]
@echo off
find_java.exe -s
pause

Title: Re: luanch of executable from within .bat file fails
Post by: Jerry Ford on December 01, 2014, 10:58:52 AM
Geek-9pm:

The issue referenced in the Google link you provided is not the same as my issue.  That issue report shows a different error message than the one I'm getting...

They get "This version of C:\Program Files\Android SDK\tools\lib\find_java.exe is not compatible with the version of Windows you're running", I get  "D:\dev\android\sdk\tools\lib\\find_java.exe" -s' is not recognized as an internal or external command".

Also, their issue seems to stem from a not yet publicly released dev build of the SDK, build  23.0.4.  I'm using the build that is still the only one available at Google's SDK download page, build 23.0.2. The fix recommended for this issue on Stackoverflow is to revert to the SDK version that I'm using.

foxidrive:

Okay, I put the echo statement into the bat file; this is what I get...

D:\dev\android\sdk\tools\lib>testme
'"D:\dev\android\sdk\tools\lib\\find_java.exe" -s' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .

Jerry
Title: Re: luanch of executable from within .bat file fails
Post by: Squashman on December 01, 2014, 11:33:51 AM

Okay, I put the echo statement into the bat file; this is what I get...

D:\dev\android\sdk\tools\lib>testme
'"D:\dev\android\sdk\tools\lib\\find_java.exe" -s' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .

Jerry
He asked you to put those exact 3 lines into the batch file and then run it.  The output would be different if you had.
Title: Re: luanch of executable from within .bat file fails
Post by: Jerry Ford on December 01, 2014, 01:07:02 PM
Squashman:

I don't follow.  His original request was to create a testme.bat, consisting of...

@echo off
for /f "delims=" %%a in ('"%~dps0\find_java.exe" -s') do echo "%%a"
pause

I did so, and got...

D:\dev\android\sdk\tools\lib>testme
'"D:\dev\android\sdk\tools\lib\\find_java.exe" -s' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .

I then understood him to say put the find_java.exe statement into the testme.bat file, which I changed to...

@echo off
rem for /f "delims=" %%a in ('"%~dps0\find_java.exe" -s') do echo "%%a"
find_java.exe -s
pause

...and ran it again. 

It produced the same results. What else should I try?

Thanks.

Jerry
Title: Re: luanch of executable from within .bat file fails
Post by: Geek-9pm on December 01, 2014, 01:39:07 PM
Jerry, I just sent you a PM.  Maybe it is possible to reproduce the error on on another Windows PC. But details are needed.
Title: Re: luanch of executable from within .bat file fails
Post by: Jerry Ford on December 01, 2014, 02:29:05 PM
Geek-9pm:

Thanks.  I realize this is getting pretty deep, and yes the problem does seem to be limited in scope, though as has been pointed out previously, there have been a ton of similar problems reported concerning running the Android tools in various Windows environments, even if they don't match my problems precisely. (Do a Google search on android.bat for a sense of scope.)

Be assured I do appreciate all of the suggestions/comments/replies that have been posted to this thread.

In answer to your specific questions, the Android SDK is version 23.0.2.

Systeminfo output...

D:\dev\android\sdk\tools\lib>systeminfo

Host Name:                 JERRY-PC
OS Name:                   Microsoft Windows 7 Ultimate
OS Version:                6.1.7601 Service Pack 1 Build 7601
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Workstation
OS Build Type:             Multiprocessor Free
Registered Owner:          Jerry
Registered Organization:
Product ID:                00426-293-0140844-85100
Original Install Date:     7/30/2011, 12:20:25 PM
System Boot Time:          12/1/2014, 9:36:50 AM
System Manufacturer:       MSI
System Model:              MS-7599
System Type:               x64-based PC
Processor(s):              1 Processor(s) Installed.
                           [01]: AMD64 Family 16 Model 4 Stepping 3 AuthenticAMD ~3300 Mhz
BIOS Version:              American Megatrends Inc. V17.8, 1/10/2011
Windows Directory:         C:\Windows
System Directory:          C:\Windows\system32
Boot Device:               \Device\HarddiskVolume3
System Locale:             en-us;English (United States)
Input Locale:              en-us;English (United States)
Time Zone:                 (UTC-08:00) Pacific Time (US & Canada)
Total Physical Memory:     16,383 MB
Available Physical Memory: 13,050 MB
Virtual Memory: Max Size:  32,765 MB
Virtual Memory: Available: 28,963 MB
Virtual Memory: In Use:    3,802 MB
Page File Location(s):     C:\pagefile.sys
Domain:                    WORKGROUP
Logon Server:              \\JERRY-PC

Output from set command...

D:\dev\android\sdk\tools\lib>set
ALLUSERSPROFILE=C:\ProgramData
ANDROID_HOME=d:\dev\android
ANDROID_SDK_HOME=d:\dev\android\sdk
ANDROID_SWT=d:\dev\android\sdk\tools\lib\x86_64
APPDATA=C:\Users\Jerry\AppData\Roaming
asl.log=Destination=file
CATALINA_HOME="E:\Program Files\apache-tomcat-6.0.29"
CINT=d:\dev\cint\cint-5.16.19
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=JERRY-PC
ComSpec=C:\Windows\system32\cmd.exe;c:\mingw\bin;c:\mingw\msys\1.0\bin
DEV_RESOURCES=E:\dev\resources
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Users\Jerry
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_11
LOCALAPPDATA=C:\Users\Jerry\AppData\Local
LOGONSERVER=\\JERRY-PC
NANT_HOME=E:\dev\nant-0.86-beta1
NUMBER_OF_PROCESSORS=2
OS=Windows_NT
Path=C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Common Files\Microsoft Shared\Microsoft Online Services;C:\Program Files (x86)\Common Files\
Microsoft Shared\Microsoft Online Services;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\W
bem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.8.0_11\bin;"C:\Program Files (x86)\PuTTY\";"c:\Program Files (x86)\Vim\Vim7
3";E:\dev\nant-0.86-beta1;c:\MinGW\bin;c:\minGW\msys\1.0\bin;c:\cygwin\bin;d:\dev\cint\cint-5.16.19;d:\dev\resources\tools;d:\dev\android\sdk\tools;d:
\dev\android\sdk
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=AMD64 Family 16 Model 4 Stepping 3, AuthenticAMD
PROCESSOR_LEVEL=16
PROCESSOR_REVISION=0403
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
PUTTY_HOME="C:\Program Files (x86)\PuTTY\"
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\Jerry\NEWAPP~1\Local\Temp
TMP=C:\Users\Jerry\NEWAPP~1\Local\Temp
TOOLS=d:\dev\resources\tools
USERDOMAIN=Jerry-PC
USERNAME=Jerry
USERPROFILE=C:\Users\Jerry
VBOX_INSTALL_PATH=C:\Program Files\Oracle\VirtualBox\
VIM="c:\Program Files (x86)\Vim\Vim73"
windir=C:\Windows

Jerry
Title: Re: luanch of executable from within .bat file fails
Post by: foxidrive on December 01, 2014, 03:45:48 PM
I then understood him to say put the find_java.exe statement into the testme.bat file, which I changed to...

@echo off
rem for /f "delims=" %%a in ('"%~dps0\find_java.exe" -s') do echo "%%a"
find_java.exe -s
pause

...and ran it again. 

It produced the same results.

 There are only two possible reasons why it fails 

EDIT: See my next post

1) find_java.exe is not in the same directory
2) you are elevating the batch file to admin when you launch it


Test this in the same folder:

Code: [Select]
@echo off
echo "%cd%"
dir f* /b
find_java.exe -s
pause
Title: Re: luanch of executable from within .bat file fails
Post by: foxidrive on December 01, 2014, 03:52:09 PM
ComSpec=C:\Windows\system32\cmd.exe;c:\mingw\bin;c:\mingw\msys\1.0\bin

How did this happen?

Comspec only accepts one target, which should be C:\Windows\system32\cmd.exe

Comspec is used to launch Batch files and command lines.
Title: Re: luanch of executable from within .bat file fails
Post by: Geek-9pm on December 01, 2014, 04:09:04 PM
Thanks Jerry.
This is one of many links about find_java.exe where they don'  know the answer.
http://www.freefixer.com/library/file/find_java.exe-139508/
To be explicit, they can not find the vendor or version. They gave two hash.
Quote
Hashes [?]
MD5   77ab253165158f703dec3edb31b984db
SHA256   8e82f0875a0f394f970e07efbcc689e49c102a4 6aed4cc78fe526cd0d53
If anybody needs to know more about MD5, look here:
Quote
The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32 digit hexadecimal number. MD5 has been utilized in a wide variety of cryptographic applications, and is also commonly used to verify data integrity.
MD5 - Wikipedia, the free encyclopedia
http://en.wikipedia.org/wiki/MD5
Wikipedia
So MD5 can be used to compare a file in one location with the the same file in another location to see if it has been corrupted, or revised. This could be just part in a process of verification of the relevant composts of the SDK.
Perhaps others can publish hash values for their copies to find_jave.exe to see if there was an undocumented revision.

Thee are free windows versions of ND5.
http://www.winmd5.com/
Title: Re: luanch of executable from within .bat file fails
Post by: Jerry Ford on December 01, 2014, 04:24:14 PM
foxidrive:

> How did this happen?

>  Comspec only accepts one target, which should be C:\Windows\system32\cmd.exe

Thank you so much!!! Problem appears to be solved!!! Android tools appear to be working!!!

The mingw entries on the CommSpec variable seem to be preventing the android .bat/.exe files from being executed by CMD.

Mingw is a GNU package that (among other things) adds C++ capability to Eclipse.  Whether I did it or an installer did it I do not know, but I do have mingw installed into my installation of Eclipse and the CommSpec environment variable it is set to the value you flagged.

I have now edited the CommSpec environment variable as follows...

ComSpec=C:\Windows\system32\cmd.exe

...and the Android files are now working correctly.

A big Thank You to all who have contributed to this thread.

:)

Jerry.

Title: Re: luanch of executable from within .bat file fails
Post by: Geek-9pm on December 01, 2014, 05:15:04 PM
So this thread is now solved!  ;D
The CommSpec variable was wrongly set by another installer.

Title: Re: luanch of executable from within .bat file fails
Post by: Squashman on December 02, 2014, 07:40:15 PM
Hmmm. I am pretty sure I have installed that in the past and do not recall it ever screwing up the comspec variable.
Title: Re: luanch of executable from within .bat file fails
Post by: Geek-9pm on December 02, 2014, 07:44:02 PM
Hmmm. I am pretty sure I have installed that in the past and do not recall it ever screwing up the comspec variable.
You are right. The right SDK does not mess with it.
The OP had installed some other thing that ruined Com spec.
It happens.
Title: Re: luanch of executable from within .bat file fails
Post by: Squashman on December 02, 2014, 07:52:58 PM
I am saying that the mingw install did not do that. It looks like someone accidentally added those paths to the compspec variable instead of the path variable.
Title: Re: luanch of executable from within .bat file fails
Post by: Geek-9pm on December 02, 2014, 08:02:18 PM
I am saying that the mingw install did not do that. It looks like someone accidentally added those paths to the compspec variable instead of the path variable.
Yes, that makes sense. Blame it on the human.  ;D
Title: Re: luanch of executable from within .bat file fails
Post by: Jerry Ford on December 03, 2014, 06:35:00 PM
The human may in fact be guilty.  :)

I do not recall the steps I took when I installed mingw, just that I did, and now that I review the mingw install instructions, it says the person doing the installing needs  to add the mingw references to PATH.  It's possible I accidentally added them to ComSpec, though they were also present in my path as well as the comspec variable. Possibly, I recognized my error and then failed to remove the erroneous entries.

So I wouldn't be so brash as to point a finger at the mingw installer.  It may very well have been me.

It's interesting to note, however, that as soon as I posted my successful resolution to the problem on the Google bug report site (I did file a Google bug before coming here), someone else replied encountering the same problem, nearly identical except that his ComSpec value had python references added to it instead of mingw. 

So, I may be guilty, but at least I'm not alone. 

Jerry
Title: Re: luanch of executable from within .bat file fails
Post by: foxidrive on December 03, 2014, 07:00:13 PM
It's interesting to note, however, that as soon as I posted my successful resolution to the problem on the Google bug report site (I did file a Google bug before coming here), someone else replied encountering the same problem, nearly identical except that his ComSpec value had python references added to it instead of mingw. 

So, I may be guilty, but at least I'm not alone. 

Jerry

It's nice to hear the outcome Jerry, and that it's likely to be just human error.

None of us are immune from that. :D

The thought did occur to me yesterday wondering how any of us would have solved the problem if you hadn't posted the SET output.
That was such a fluke.

Eventually, with enough test batch files and copies of the error data, it may have been revealed - but you might have given up way before then!

:)