FindJava2+WinLauncher2 MFC app for Windows.

In the code base we have a "find_java" directory
that compiles using mingw32 + an Android.mk; it is
used to create the find_java.dll used by the NSIS
installer, the find_java.exe that is used by android.bat
to locate java before executing the SDK/AVD Manager
and finally also used by the Android Studio WinLauncher.

This reworks find_java to create 2 new MFC apps:
- FindJava2 is a straight replacement for the previous find_java.exe.
- WinLauncher2 will be a replacement for the Studio launcher.

The main change is that the new app has a UI so it lists
all the Java.exe paths and let the user add his/her own.
Then it remembers the selected path using a registry key
and reuses the next time if it's available.

The app is built using VS2013 and MFC and there's no
Android.mk for it. The goal is to just make prebuilts
(that's how find_java.exe/dll and WinLauncher are actually
used right now.)

The FindJava2 part is final.
What's left to do:
- Merge the code of WinLauncher into WinLauncher2 to
  actually run Studio (they will be a need for both a
  32-bit version and 64-bit version support.)
- Create a new FindJava2.dll for NSIS once we decide how
  we want to use this in the new installer (e.g. do we
  just want to make sure there is "some" version of Java
  or do we want to include the select-and-register functionality
  too so that the user doesn't have to be asked again later?)

Change-Id: I814ed46711ac17a66cd63b9e7c7d485632169ff1
diff --git a/find_java2/FindJava2/FindJava2.cpp b/find_java2/FindJava2/FindJava2.cpp
new file mode 100755
index 0000000..1435e1b
--- /dev/null
+++ b/find_java2/FindJava2/FindJava2.cpp
@@ -0,0 +1,199 @@
+/*

+* Copyright (C) 2014 The Android Open Source Project

+*

+* Licensed under the Apache License, Version 2.0 (the "License");

+* you may not use this file except in compliance with the License.

+* You may obtain a copy of the License at

+*

+*      http://www.apache.org/licenses/LICENSE-2.0

+*

+* Unless required by applicable law or agreed to in writing, software

+* distributed under the License is distributed on an "AS IS" BASIS,

+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+* See the License for the specific language governing permissions and

+* limitations under the License.

+*/

+

+#include "stdafx.h"

+#include "FindJava2.h"

+#include "utils.h"

+#include "JavaFinder.h"

+#include "FindJava2Dlg.h"

+

+#ifdef _DEBUG

+#define new DEBUG_NEW

+#endif

+

+// The one and only MFC application object

+class CFindJava2App : public CWinApp {

+public:

+    CFindJava2App() {

+    }

+

+    // Set CWinApp default registry key. Must be consistent with all apps using findjava2.

+    void initRegistryKey() {

+        SetRegistryKey(_T("Android-FindJava2"));

+    }

+};

+

+CFindJava2App theApp;

+

+using namespace std;

+

+int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) {

+

+    // Init utils; use default app name based on VERSIONINFO.FileDescription

+    initUtils(NULL);

+

+    // initialize MFC and print and error on failure

+    HMODULE hModule = ::GetModuleHandle(NULL);

+    if (hModule == NULL) {

+        displayLastError(_T("Fatal Error: "));

+        return -2;

+    }

+    if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), 0)) {

+        displayLastError(_T("Fatal Error: "));

+        return -3;

+    }

+

+    theApp.initRegistryKey();

+

+    gIsConsole = true; // tell utils to to print errors to stderr

+    gIsDebug = (getenv("ANDROID_SDKMAN_DEBUG") != NULL);

+

+    // Parse command line

+    bool doTests = false;

+    bool doShortPath = false;

+    bool doVersion = false;

+    bool doJavaW = false;

+    bool doForceUi = false;

+    bool doJava1_7 = false;

+

+    for (int i = 1; i < argc; i++) {

+        if (_tcsnccmp(argv[i], _T("-t"), 2) == 0) {

+            doTests = true;

+

+        } else if (_tcsnccmp(argv[i], _T("-d"), 2) == 0) {

+            gIsDebug = true;

+

+        } else if (_tcsnccmp(argv[i], _T("-s"), 2) == 0) {

+            doShortPath = true;

+

+        } else if (_tcsnccmp(argv[i], _T("-v"), 2) == 0) {

+            doVersion = true;

+

+        } else if (_tcsnccmp(argv[i], _T("-f"), 2) == 0) {

+            doForceUi = true;

+

+        } else if (_tcsnccmp(argv[i], _T("-7"), 2) == 0) {

+            doJava1_7 = true;

+

+        } else if (_tcscmp(argv[i], _T("-w")) == 0 || _tcscmp(argv[i], _T("-javaw")) == 0) {

+            doJavaW = true;

+

+        } else {

+            printf(

+                "Outputs the path of the first Java.exe found on the local system.\n"

+                "Returns code 0 when found, 1 when not found.\n"

+                "Options:\n"

+                "-h / -help   : This help.\n"

+                "-t / -test   : Internal test.\n"

+                "-f / -force  : Force UI selection.\n"

+                "-7           : Java 1.7 minimum instead of 1.6.\n"

+                "-s / -short  : Print path in short DOS form.\n"

+                "-w / -javaw  : Search a matching javaw.exe; defaults to java.exe if not found.\n"

+                "-v / -version: Only prints the Java version found.\n"

+                );

+            return 2;

+        }

+    }

+

+

+    CJavaFinder javaFinder(JAVA_VERS_TO_INT(1, doJava1_7 ? 7 : 6));

+    CJavaPath javaPath = javaFinder.getRegistryPath();

+

+    if (doTests) {

+        std::set<CJavaPath> paths;

+        javaFinder.findJavaPaths(&paths);

+        bool regPrinted = false;

+        for (const CJavaPath &p : paths) {

+            bool isReg = (p == javaPath);

+            if (isReg) {

+                regPrinted = true;

+            }

+            _tprintf(_T("%c [%s] %s\n"), isReg ? '*' : ' ', p.getVersion(), p.mPath);

+        }

+

+        if (!regPrinted && !javaPath.isEmpty()) {

+            const CJavaPath &p = javaPath;

+            _tprintf(_T("* [%s] %s\n"), p.getVersion(), p.mPath);

+        }

+        return 0;

+    }

+

+    if (doForceUi || javaPath.isEmpty()) {

+        CFindJava2Dlg dlg;

+        dlg.setJavaFinder(&javaFinder);

+        INT_PTR nResponse = dlg.DoModal();

+

+        if (nResponse == IDOK) {

+            // Get java path selected by user and save into registry for later re-use

+            javaPath = dlg.getSelectedPath();

+            javaFinder.setRegistryPath(javaPath);

+        } else if (nResponse == -1) {   // MFC boilerplate

+            TRACE(traceAppMsg, 0, "Warning: dialog creation failed, so application is terminating unexpectedly.\n");

+            return 1;

+        }

+    }

+

+    if (javaPath.isEmpty()) {

+        fprintf(stderr, "No java.exe path found");

+        return 1;

+    }

+

+    if (doShortPath) {

+        PVOID oldWow64Value = disableWow64FsRedirection();

+        if (!javaPath.toShortPath()) {

+            revertWow64FsRedirection(&oldWow64Value);

+            _ftprintf(stderr,

+                    _T("Failed to convert path to a short DOS path: %s\n"),

+                    javaPath.mPath);

+            return 1;

+        }

+        revertWow64FsRedirection(&oldWow64Value);

+    }

+

+    if (doVersion) {

+        // Print version found. We already have the version as an integer

+        // so we don't need to run java -version a second time.

+        _tprintf(_T("%s"), javaPath.getVersion());

+        return 0;

+    }

+

+    if (doJavaW) {

+        // Try to find a javaw.exe instead of java.exe at the same location.

+        CPath javawPath = javaPath.mPath;

+        javawPath.RemoveFileSpec();

+        javawPath.Append(_T("javaw.exe"));

+        javawPath.Canonicalize();

+

+        // Only accept it if we can actually find the exec

+        PVOID oldWow64Value = disableWow64FsRedirection();

+        bool exists = javawPath.FileExists() == TRUE; // skip BOOL-to-bool warning

+        revertWow64FsRedirection(&oldWow64Value);

+

+        if (!exists) {

+            _ftprintf(stderr,

+                    _T("Failed to find javaw at: %s\n"),

+                    javawPath);

+            return 1;

+        }

+

+        javaPath.mPath = javawPath;

+    }

+

+    // Print java.exe path found

+    _tprintf(_T("%s"), javaPath.mPath);

+    return 0;

+

+}

diff --git a/find_java2/FindJava2/FindJava2.h b/find_java2/FindJava2/FindJava2.h
new file mode 100755
index 0000000..a144bfc
--- /dev/null
+++ b/find_java2/FindJava2/FindJava2.h
@@ -0,0 +1,19 @@
+/*

+* Copyright (C) 2014 The Android Open Source Project

+*

+* Licensed under the Apache License, Version 2.0 (the "License");

+* you may not use this file except in compliance with the License.

+* You may obtain a copy of the License at

+*

+*      http://www.apache.org/licenses/LICENSE-2.0

+*

+* Unless required by applicable law or agreed to in writing, software

+* distributed under the License is distributed on an "AS IS" BASIS,

+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+* See the License for the specific language governing permissions and

+* limitations under the License.

+*/

+

+#pragma once

+

+#include "resource.h"

diff --git a/find_java2/FindJava2/FindJava2.rc b/find_java2/FindJava2/FindJava2.rc
new file mode 100755
index 0000000..ff767c6
--- /dev/null
+++ b/find_java2/FindJava2/FindJava2.rc
@@ -0,0 +1,142 @@
+// Microsoft Visual C++ generated resource script.

+//

+#include "resource.h"

+

+#define APSTUDIO_READONLY_SYMBOLS

+/////////////////////////////////////////////////////////////////////////////

+//

+// Generated from the TEXTINCLUDE 2 resource.

+//

+#include "afxres.h"

+

+/////////////////////////////////////////////////////////////////////////////

+#undef APSTUDIO_READONLY_SYMBOLS

+

+/////////////////////////////////////////////////////////////////////////////

+// English (United States) resources

+

+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)

+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US

+

+#ifdef APSTUDIO_INVOKED

+/////////////////////////////////////////////////////////////////////////////

+//

+// TEXTINCLUDE

+//

+

+1 TEXTINCLUDE 

+BEGIN

+    "resource.h\0"

+END

+

+2 TEXTINCLUDE 

+BEGIN

+    "#include ""afxres.h""\r\n"

+    "\0"

+END

+

+3 TEXTINCLUDE 

+BEGIN

+    "\r\n"

+    "\0"

+END

+

+#endif    // APSTUDIO_INVOKED

+

+

+/////////////////////////////////////////////////////////////////////////////

+//

+// Version

+//

+

+VS_VERSION_INFO VERSIONINFO

+ FILEVERSION 1,0,0,1

+ PRODUCTVERSION 1,0,0,1

+ FILEFLAGSMASK 0x3fL

+#ifdef _DEBUG

+ FILEFLAGS 0x1L

+#else

+ FILEFLAGS 0x0L

+#endif

+ FILEOS 0x40004L

+ FILETYPE 0x1L

+ FILESUBTYPE 0x0L

+BEGIN

+    BLOCK "StringFileInfo"

+    BEGIN

+        BLOCK "040904b0"

+        BEGIN

+            VALUE "CompanyName", "Android"

+            VALUE "FileDescription", "Find Java for Android SDK"

+            VALUE "FileVersion", "2.0.0.1"

+            VALUE "InternalName", "FindJava2.exe"

+            VALUE "LegalCopyright", "(c) Android.  All rights reserved."

+            VALUE "OriginalFilename", "FindJava2.exe"

+            VALUE "ProductName", "Android SDK"

+            VALUE "ProductVersion", "2.0.0.1"

+        END

+    END

+    BLOCK "VarFileInfo"

+    BEGIN

+        VALUE "Translation", 0x409, 1200

+    END

+END

+

+

+/////////////////////////////////////////////////////////////////////////////

+//

+// Dialog

+//

+

+IDD_FINDJAVA2_DIALOG DIALOGEX 0, 0, 317, 196

+STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME

+EXSTYLE WS_EX_APPWINDOW

+CAPTION "Find Java 2 for Android"

+FONT 8, "MS Shell Dlg", 0, 0, 0x1

+BEGIN

+    DEFPUSHBUTTON   "Start",IDOK,205,174,50,14

+    PUSHBUTTON      "Quit",IDCANCEL,260,174,50,14

+    PUSHBUTTON      "Add...",IDC_BUTTON_ADD,7,174,50,14

+    LTEXT           "Select which version of Java to use:",IDC_STATIC,7,7,116,8

+    CONTROL         "",IDC_PATH_LIST,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,18,300,150

+END

+

+

+/////////////////////////////////////////////////////////////////////////////

+//

+// DESIGNINFO

+//

+

+#ifdef APSTUDIO_INVOKED

+GUIDELINES DESIGNINFO

+BEGIN

+    IDD_FINDJAVA2_DIALOG, DIALOG

+    BEGIN

+    END

+END

+#endif    // APSTUDIO_INVOKED

+

+

+/////////////////////////////////////////////////////////////////////////////

+//

+// Icon

+//

+

+// Icon with lowest ID value placed first to ensure application icon

+// remains consistent on all systems.

+IDI_ANDROID_ICON        ICON                    "..\\android_icon.ico"

+#endif    // English (United States) resources

+/////////////////////////////////////////////////////////////////////////////

+

+

+

+#ifndef APSTUDIO_INVOKED

+/////////////////////////////////////////////////////////////////////////////

+//

+// Generated from the TEXTINCLUDE 3 resource.

+//

+

+

+/////////////////////////////////////////////////////////////////////////////

+#endif    // not APSTUDIO_INVOKED

+

diff --git a/find_java2/FindJava2/FindJava2.vcxproj b/find_java2/FindJava2/FindJava2.vcxproj
new file mode 100755
index 0000000..3c9ac4e
--- /dev/null
+++ b/find_java2/FindJava2/FindJava2.vcxproj
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="utf-8"?>

+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

+  <ItemGroup Label="ProjectConfigurations">

+    <ProjectConfiguration Include="Debug|Win32">

+      <Configuration>Debug</Configuration>

+      <Platform>Win32</Platform>

+    </ProjectConfiguration>

+    <ProjectConfiguration Include="Release|Win32">

+      <Configuration>Release</Configuration>

+      <Platform>Win32</Platform>

+    </ProjectConfiguration>

+  </ItemGroup>

+  <PropertyGroup Label="Globals">

+    <ProjectGuid>{E696008D-A1B8-4434-B6B4-24ED251B1676}</ProjectGuid>

+    <Keyword>Win32Proj</Keyword>

+    <RootNamespace>FindJava2</RootNamespace>

+  </PropertyGroup>

+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">

+    <ConfigurationType>Application</ConfigurationType>

+    <UseDebugLibraries>true</UseDebugLibraries>

+    <PlatformToolset>v120</PlatformToolset>

+    <CharacterSet>Unicode</CharacterSet>

+    <UseOfMfc>Dynamic</UseOfMfc>

+  </PropertyGroup>

+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">

+    <ConfigurationType>Application</ConfigurationType>

+    <UseDebugLibraries>false</UseDebugLibraries>

+    <PlatformToolset>v120</PlatformToolset>

+    <WholeProgramOptimization>true</WholeProgramOptimization>

+    <CharacterSet>Unicode</CharacterSet>

+    <UseOfMfc>Dynamic</UseOfMfc>

+  </PropertyGroup>

+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />

+  <ImportGroup Label="ExtensionSettings">

+  </ImportGroup>

+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">

+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />

+  </ImportGroup>

+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">

+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />

+  </ImportGroup>

+  <PropertyGroup Label="UserMacros" />

+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">

+    <LinkIncremental>true</LinkIncremental>

+  </PropertyGroup>

+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">

+    <LinkIncremental>false</LinkIncremental>

+  </PropertyGroup>

+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">

+    <ClCompile>

+      <PrecompiledHeader>Use</PrecompiledHeader>

+      <WarningLevel>Level3</WarningLevel>

+      <Optimization>Disabled</Optimization>

+      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>

+      <AdditionalIncludeDirectories>$(ProjectDir);$(SolutionDir)\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

+    </ClCompile>

+    <Link>

+      <SubSystem>Console</SubSystem>

+      <GenerateDebugInformation>true</GenerateDebugInformation>

+      <AdditionalDependencies>version.lib</AdditionalDependencies>

+    </Link>

+  </ItemDefinitionGroup>

+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">

+    <ClCompile>

+      <WarningLevel>Level3</WarningLevel>

+      <PrecompiledHeader>Use</PrecompiledHeader>

+      <Optimization>MaxSpeed</Optimization>

+      <FunctionLevelLinking>true</FunctionLevelLinking>

+      <IntrinsicFunctions>true</IntrinsicFunctions>

+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>

+      <AdditionalIncludeDirectories>$(ProjectDir);$(SolutionDir)\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

+    </ClCompile>

+    <Link>

+      <SubSystem>Console</SubSystem>

+      <GenerateDebugInformation>true</GenerateDebugInformation>

+      <EnableCOMDATFolding>true</EnableCOMDATFolding>

+      <OptimizeReferences>true</OptimizeReferences>

+      <AdditionalDependencies>version.lib</AdditionalDependencies>

+    </Link>

+  </ItemDefinitionGroup>

+  <ItemGroup>

+    <ClInclude Include="..\src\FindJava2Dlg.h" />

+    <ClInclude Include="..\src\JavaFinder.h" />

+    <ClInclude Include="..\src\JavaPath.h" />

+    <ClInclude Include="..\src\utils.h" />

+    <ClInclude Include="FindJava2.h" />

+    <ClInclude Include="Resource.h" />

+    <ClInclude Include="stdafx.h" />

+    <ClInclude Include="targetver.h" />

+  </ItemGroup>

+  <ItemGroup>

+    <ClCompile Include="..\src\FindJava2Dlg.cpp" />

+    <ClCompile Include="..\src\JavaFinder.cpp" />

+    <ClCompile Include="..\src\JavaPath.cpp" />

+    <ClCompile Include="..\src\utils.cpp" />

+    <ClCompile Include="FindJava2.cpp" />

+    <ClCompile Include="stdafx.cpp">

+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>

+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>

+    </ClCompile>

+  </ItemGroup>

+  <ItemGroup>

+    <ResourceCompile Include="FindJava2.rc" />

+  </ItemGroup>

+  <ItemGroup>

+    <Image Include="..\android_icon.ico" />

+  </ItemGroup>

+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

+  <ImportGroup Label="ExtensionTargets">

+  </ImportGroup>

+</Project>
\ No newline at end of file
diff --git a/find_java2/FindJava2/resource.h b/find_java2/FindJava2/resource.h
new file mode 100755
index 0000000..1d5f98f
--- /dev/null
+++ b/find_java2/FindJava2/resource.h
@@ -0,0 +1,19 @@
+//{{NO_DEPENDENCIES}}

+// Microsoft Visual C++ generated include file.

+// Used by FindJava2.rc

+//

+#define IDI_ANDROID_ICON                5

+#define IDD_FINDJAVA2_DIALOG            102

+#define IDC_BUTTON_ADD                  1000

+#define IDC_PATH_LIST                   1001

+

+// Next default values for new objects

+// 

+#ifdef APSTUDIO_INVOKED

+#ifndef APSTUDIO_READONLY_SYMBOLS

+#define _APS_NEXT_RESOURCE_VALUE        101

+#define _APS_NEXT_COMMAND_VALUE         40001

+#define _APS_NEXT_CONTROL_VALUE         1000

+#define _APS_NEXT_SYMED_VALUE           101

+#endif

+#endif

diff --git a/find_java2/FindJava2/stdafx.cpp b/find_java2/FindJava2/stdafx.cpp
new file mode 100755
index 0000000..3baa67f
--- /dev/null
+++ b/find_java2/FindJava2/stdafx.cpp
@@ -0,0 +1,24 @@
+/*

+* Copyright (C) 2014 The Android Open Source Project

+*

+* Licensed under the Apache License, Version 2.0 (the "License");

+* you may not use this file except in compliance with the License.

+* You may obtain a copy of the License at

+*

+*      http://www.apache.org/licenses/LICENSE-2.0

+*

+* Unless required by applicable law or agreed to in writing, software

+* distributed under the License is distributed on an "AS IS" BASIS,

+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+* See the License for the specific language governing permissions and

+* limitations under the License.

+*/

+

+// stdafx.cpp : source file that includes just the standard includes

+// FindJava2.pch will be the pre-compiled header

+// stdafx.obj will contain the pre-compiled type information

+

+#include "stdafx.h"

+

+// TODO: reference any additional headers you need in STDAFX.H

+// and not in this file

diff --git a/find_java2/FindJava2/stdafx.h b/find_java2/FindJava2/stdafx.h
new file mode 100755
index 0000000..7230def
--- /dev/null
+++ b/find_java2/FindJava2/stdafx.h
@@ -0,0 +1,55 @@
+/*

+* Copyright (C) 2014 The Android Open Source Project

+*

+* Licensed under the Apache License, Version 2.0 (the "License");

+* you may not use this file except in compliance with the License.

+* You may obtain a copy of the License at

+*

+*      http://www.apache.org/licenses/LICENSE-2.0

+*

+* Unless required by applicable law or agreed to in writing, software

+* distributed under the License is distributed on an "AS IS" BASIS,

+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+* See the License for the specific language governing permissions and

+* limitations under the License.

+*/

+

+// stdafx.h : include file for standard system include files,

+// or project specific include files that are used frequently,

+// but are changed infrequently.

+

+#pragma once

+

+#include "targetver.h"

+

+

+#define _CRT_SECURE_NO_WARNINGS

+

+#include <stdio.h>

+#include <tchar.h>

+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // some CString constructors will be explicit

+#define _AFX_NO_MFC_CONTROLS_IN_DIALOGS         // remove support for MFC controls in dialogs

+

+#ifndef VC_EXTRALEAN

+#define VC_EXTRALEAN            // Exclude rarely-used stuff from Windows headers

+#endif

+

+#include <afx.h>

+#include <afxwin.h>         // MFC core and standard components

+#include <afxext.h>         // MFC extensions

+#ifndef _AFX_NO_OLE_SUPPORT

+#include <afxdtctl.h>           // MFC support for Internet Explorer 4 Common Controls

+#endif

+#ifndef _AFX_NO_AFXCMN_SUPPORT

+#include <afxcmn.h>                     // MFC support for Windows Common Controls

+#endif // _AFX_NO_AFXCMN_SUPPORT

+

+#include <iostream>

+

+

+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // some CString constructors will be explicit

+

+#include <atlbase.h>

+#include <atlstr.h>

+

+// TODO: reference additional headers your program requires here

diff --git a/find_java2/FindJava2/targetver.h b/find_java2/FindJava2/targetver.h
new file mode 100755
index 0000000..fc6d20b
--- /dev/null
+++ b/find_java2/FindJava2/targetver.h
@@ -0,0 +1,24 @@
+/*

+* Copyright (C) 2014 The Android Open Source Project

+*

+* Licensed under the Apache License, Version 2.0 (the "License");

+* you may not use this file except in compliance with the License.

+* You may obtain a copy of the License at

+*

+*      http://www.apache.org/licenses/LICENSE-2.0

+*

+* Unless required by applicable law or agreed to in writing, software

+* distributed under the License is distributed on an "AS IS" BASIS,

+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+* See the License for the specific language governing permissions and

+* limitations under the License.

+*/

+

+#pragma once

+

+// Including SDKDDKVer.h defines the highest available Windows platform.

+

+// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and

+// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.

+

+#include <SDKDDKVer.h>