8215019: Allow --install-dir on windows JDK-8200758-branch
authorherrick
Tue, 26 Mar 2019 08:57:28 -0400
branchJDK-8200758-branch
changeset 57283 0b0be19f79e4
parent 57282 c9c2c08854f5
child 57284 8786618d2a55
8215019: Allow --install-dir on windows Submitten-by: almatvee Reviewed-by: herrick
src/jdk.jpackage/share/classes/jdk/jpackage/internal/CLIHelp.java
src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources.properties
src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_ja.properties
src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_zh_CN.properties
src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinAppBundler.java
src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinExeBundler.java
src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiBundler.java
src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsBundlerParam.java
src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources.properties
src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_ja.properties
src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_zh_CN.properties
src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/template.iss
test/jdk/tools/jpackage/createimage/JPackageCreateImageModularJarTest.java
test/jdk/tools/jpackage/createinstaller/windows/base/JPackageCreateInstallerFileAssociationsBase.java
test/jdk/tools/jpackage/createinstaller/windows/base/JPackageCreateInstallerInstallDirBase.java
test/jdk/tools/jpackage/createinstaller/windows/exe/JPackageCreateInstallerFileAssociationsInstallDirTest.java
test/jdk/tools/jpackage/createinstaller/windows/exe/JPackageCreateInstallerFileAssociationsTest.java
test/jdk/tools/jpackage/createinstaller/windows/exe/JPackageCreateInstallerInstallDirTest.java
test/jdk/tools/jpackage/createinstaller/windows/exe/install.bat
test/jdk/tools/jpackage/createinstaller/windows/exe/uninstall.bat
test/jdk/tools/jpackage/createinstaller/windows/msi/JPackageCreateInstallerFileAssociationsInstallDirTest.java
test/jdk/tools/jpackage/createinstaller/windows/msi/JPackageCreateInstallerFileAssociationsTest.java
test/jdk/tools/jpackage/createinstaller/windows/msi/JPackageCreateInstallerInstallDirTest.java
test/jdk/tools/jpackage/createinstaller/windows/msi/install.bat
test/jdk/tools/jpackage/createinstaller/windows/msi/uninstall.bat
test/jdk/tools/jpackage/helpers/JPackagePath.java
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/CLIHelp.java	Tue Mar 26 08:54:43 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/CLIHelp.java	Tue Mar 26 08:57:28 2019 -0400
@@ -46,39 +46,48 @@
         if (noArgs) {
             Log.info(I18N.getString("MSG_Help_no_args"));
         } else {
-            Platform platform = (Log.isDebug()) ? 
+            Platform platform = (Log.isDebug()) ?
                     Platform.UNKNOWN : Platform.getPlatform();
             String types;
             String pLaunchOptions;
             String pInstallOptions;
+            String pInstallDir;
             switch (platform) {
                 case MAC:
                     types = "{\"pkg\", \"dmg\"}";
 		    pLaunchOptions = "";
                     pInstallOptions = I18N.getString("MSG_Help_mac_install");
+                    pInstallDir
+                            = I18N.getString("MSG_Help_mac_linux_install_dir");
                     break;
                 case LINUX:
                     types = "{\"rpm\", \"deb\"}";
 		    pLaunchOptions = "";
                     pInstallOptions = I18N.getString("MSG_Help_linux_install");
+                    pInstallDir
+                            = I18N.getString("MSG_Help_mac_linux_install_dir");
                     break;
                 case WINDOWS:
                     types = "{\"exe\", \"msi\"}";
 		    pLaunchOptions = I18N.getString("MSG_Help_win_launcher");
                     pInstallOptions = I18N.getString("MSG_Help_win_install");
+                    pInstallDir
+                            = I18N.getString("MSG_Help_win_install_dir");
                     break;
                 default:
-                    types = 
+                    types =
                       "{\"exe\", \"msi\", \"rpm\", \"deb\", \"pkg\", \"dmg\"}";
 		    pLaunchOptions = I18N.getString("MSG_Help_win_launcher");
                     pInstallOptions = I18N.getString("MSG_Help_win_install")
                             + I18N.getString("MSG_Help_mac_install")
                             + I18N.getString("MSG_Help_linux_install");
+                    pInstallDir
+                            = I18N.getString("MSG_Help_default_install_dir");
                     break;
             }
             Log.info(MessageFormat.format(I18N.getString("MSG_Help"),
                     File.pathSeparator, types, pLaunchOptions,
-                    pInstallOptions));
+                    pInstallOptions, pInstallDir));
         }
     }
 }
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources.properties	Tue Mar 26 08:54:43 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources.properties	Tue Mar 26 08:57:28 2019 -0400
@@ -166,7 +166,7 @@
 \          The format must be a DNS name in reverse order,\n\
 \          such as com.example.myapplication.\n\
 \  --install-dir <file path>\n\
-\          Absolute path of the installation directory of the application\n\
+\          {4}\
 \  --installer-type <type> \n\
 \          The type of the installer to create\n\
 \          Valid values are: {1} \n\
@@ -215,6 +215,9 @@
 \  --win-upgrade-uuid <id string>\n\
 \          UUID associated with upgrades for this package\n\
 
+MSG_Help_win_install_dir=\
+\Relative sub-path under the default installation location\n\
+
 MSG_Help_mac_install=\
 \  --mac-bundle-identifier <ID string>\n\
 \          An identifier that uniquely identifies the application for MacOSX\n\
@@ -253,6 +256,14 @@
 \  --linux-rpm-license-type <type string>\n\
 \          Type of the license ("License: <value>" of the RPM .spec)\n\
 
+MSG_Help_mac_linux_install_dir=\
+\Absolute path of the installation directory of the application\n\
+
+MSG_Help_default_install_dir=\
+\Absolute path of the installation directory of the application on OS X\n\
+\          or Linux. Relative sub-path of the installation location of the application\n\
+\          such as "Program Files" or "AppData" on Windows.\n\
+
 MSG_Help_no_args=Usage: jpackage <mode> <options>\n\
 \Use jpackage --help (or -h) for a list of possible options\
 
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_ja.properties	Tue Mar 26 08:54:43 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_ja.properties	Tue Mar 26 08:57:28 2019 -0400
@@ -166,7 +166,7 @@
 \          The format must be a DNS name in reverse order,\n\
 \          such as com.example.myapplication.\n\
 \  --install-dir <file path>\n\
-\          Absolute path of the installation directory of the application\n\
+\          {4}\
 \  --installer-type <type> \n\
 \          The type of the installer to create\n\
 \          Valid values are: {1} \n\
@@ -215,6 +215,9 @@
 \  --win-upgrade-uuid <id string>\n\
 \          UUID associated with upgrades for this package\n\
 
+MSG_Help_win_install_dir=\
+\Relative sub-path under the default installation location\n\
+
 MSG_Help_mac_install=\
 \  --mac-bundle-identifier <ID string>\n\
 \          An identifier that uniquely identifies the application for MacOSX\n\
@@ -253,6 +256,14 @@
 \  --linux-rpm-license-type <type string>\n\
 \          Type of the license ("License: <value>" of the RPM .spec)\n\
 
+MSG_Help_mac_linux_install_dir=\
+\Absolute path of the installation directory of the application\n\
+
+MSG_Help_default_install_dir=\
+\Absolute path of the installation directory of the application on OS X\n\
+\          or Linux. Relative sub-path of the installation location of the application\n\
+\          such as "Program Files" or "AppData" on Windows.\n\
+
 MSG_Help_no_args=Usage: jpackage <mode> <options>\n\
 \Use jpackage --help (or -h) for a list of possible options\
 
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_zh_CN.properties	Tue Mar 26 08:54:43 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_zh_CN.properties	Tue Mar 26 08:57:28 2019 -0400
@@ -166,7 +166,7 @@
 \          The format must be a DNS name in reverse order,\n\
 \          such as com.example.myapplication.\n\
 \  --install-dir <file path>\n\
-\          Absolute path of the installation directory of the application\n\
+\          {4}\
 \  --installer-type <type> \n\
 \          The type of the installer to create\n\
 \          Valid values are: {1} \n\
@@ -215,6 +215,9 @@
 \  --win-upgrade-uuid <id string>\n\
 \          UUID associated with upgrades for this package\n\
 
+MSG_Help_win_install_dir=\
+\Relative sub-path under the default installation location\n\
+
 MSG_Help_mac_install=\
 \  --mac-bundle-identifier <ID string>\n\
 \          An identifier that uniquely identifies the application for MacOSX\n\
@@ -253,6 +256,14 @@
 \  --linux-rpm-license-type <type string>\n\
 \          Type of the license ("License: <value>" of the RPM .spec)\n\
 
+MSG_Help_mac_linux_install_dir=\
+\Absolute path of the installation directory of the application\n\
+
+MSG_Help_default_install_dir=\
+\Absolute path of the installation directory of the application on OS X\n\
+\          or Linux. Relative sub-path of the installation location of the application\n\
+\          such as "Program Files" or "AppData" on Windows.\n\
+
 MSG_Help_no_args=Usage: jpackage <mode> <options>\n\
 \Use jpackage --help (or -h) for a list of possible options\
 
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinAppBundler.java	Tue Mar 26 08:54:43 2019 -0400
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinAppBundler.java	Tue Mar 26 08:57:28 2019 -0400
@@ -25,10 +25,7 @@
 
 package jdk.jpackage.internal;
 
-import java.io.ByteArrayOutputStream;
 import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
 import java.nio.file.Path;
 import java.text.MessageFormat;
 import java.util.Arrays;
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinExeBundler.java	Tue Mar 26 08:54:43 2019 -0400
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinExeBundler.java	Tue Mar 26 08:57:28 2019 -0400
@@ -30,8 +30,6 @@
 import java.nio.file.Files;
 import java.text.MessageFormat;
 import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 import static jdk.jpackage.internal.WindowsBundlerParam.*;
 
@@ -463,7 +461,7 @@
         data.put("PRODUCT_APP_IDENTIFIER",
                 innosetupEscape(getAppIdentifier(p)));
 
-
+        validateValueAndPut(data, "INSTALL_DIR", WINDOWS_INSTALL_DIR, p);
         validateValueAndPut(data, "INSTALLER_NAME", APP_NAME, p);
         validateValueAndPut(data, "APPLICATION_VENDOR", VENDOR, p);
         validateValueAndPut(data, "APPLICATION_VERSION", VERSION, p);
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiBundler.java	Tue Mar 26 08:54:43 2019 -0400
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiBundler.java	Tue Mar 26 08:57:28 2019 -0400
@@ -30,7 +30,6 @@
 import java.nio.file.Files;
 import java.text.MessageFormat;
 import java.util.*;
-import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import static jdk.jpackage.internal.WindowsBundlerParam.*;
@@ -965,8 +964,17 @@
             out.println(
                     "  <Directory Name=\"AppData\" Id=\"LocalAppDataFolder\">");
         }
+
+        // We should get valid folder or subfolders
+        String installDir = WINDOWS_INSTALL_DIR.fetchFrom(params);
+        String [] installDirs = installDir.split(Pattern.quote("\\"));
+        for (int i = 0; i < (installDirs.length - 1); i++)  {
+            out.println("   <Directory Id=\"SUBDIR" + i + "\" Name=\""
+                + installDirs[i] + "\">");
+        }
+
         out.println("   <Directory Id=\"APPLICATIONFOLDER\" Name=\""
-                + APP_NAME.fetchFrom(params) + "\">");
+                + installDirs[installDirs.length - 1] + "\">");
 
         // dynamic part
         id = 0;
@@ -974,7 +982,9 @@
         walkFileTree(params, WIN_APP_IMAGE.fetchFrom(params), out, "    ");
 
         // closing
-        out.println("   </Directory>");
+        for (int i = 0; i < installDirs.length; i++)  {
+            out.println("   </Directory>");
+        }
         out.println("  </Directory>");
 
         // for shortcuts
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsBundlerParam.java	Tue Mar 26 08:54:43 2019 -0400
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsBundlerParam.java	Tue Mar 26 08:57:28 2019 -0400
@@ -25,6 +25,7 @@
 
 package jdk.jpackage.internal;
 
+import java.text.MessageFormat;
 import java.util.Map;
 import java.util.ResourceBundle;
 import java.util.function.BiFunction;
@@ -86,4 +87,30 @@
             params -> Boolean.FALSE,
             (s, p) -> Boolean.valueOf(s)
     );
+
+    static final BundlerParamInfo<String> WINDOWS_INSTALL_DIR =
+            new StandardBundlerParam<>(
+            "windows-install-dir",
+            String.class,
+            params -> {
+                 String dir = INSTALL_DIR.fetchFrom(params);
+                 if (dir != null) {
+                     if (dir.contains(":") || dir.contains("..")) {
+                         Log.error(MessageFormat.format(I18N.getString(
+                                "message.invalid.install.dir"), dir,
+                                APP_NAME.fetchFrom(params)));
+                     } else {
+                        if (dir.startsWith("\\")) {
+                             dir = dir.substring(1);
+                        }
+                        if (dir.endsWith("\\")) {
+                             dir = dir.substring(0, dir.length() - 1);
+                        }
+                        return dir;
+                     }
+                 }
+                 return APP_NAME.fetchFrom(params); // Default to app name
+             },
+            (s, p) -> s
+    );
 }
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources.properties	Tue Mar 26 08:54:43 2019 -0400
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources.properties	Tue Mar 26 08:57:28 2019 -0400
@@ -88,4 +88,5 @@
 message.light-file-string=WiX light tool set to {0}
 message.candle-file-string=WiX candle tool set to {0}
 message.install.dir.exist=The folder [APPLICATIONFOLDER] already exist. Whould you like to install to that folder anyway?
+message.invalid.install.dir=Warning: Invalid install directory {0}. Install directory should be a relative sub-path under the default installation location such as "Program Files". Defaulting to application name "{1}".
 
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_ja.properties	Tue Mar 26 08:54:43 2019 -0400
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_ja.properties	Tue Mar 26 08:57:28 2019 -0400
@@ -88,4 +88,5 @@
 message.light-file-string=WiX light tool set to {0}
 message.candle-file-string=WiX candle tool set to {0}
 message.install.dir.exist=The folder [APPLICATIONFOLDER] already exist. Whould you like to install to that folder anyway?
+message.invalid.install.dir=Warning: Invalid install directory {0}. Install directory should be a relative sub-path under the default installation location such as "Program Files". Defaulting to application name "{1}".
 
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_zh_CN.properties	Tue Mar 26 08:54:43 2019 -0400
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_zh_CN.properties	Tue Mar 26 08:57:28 2019 -0400
@@ -88,4 +88,5 @@
 message.light-file-string=WiX light tool set to {0}
 message.candle-file-string=WiX candle tool set to {0}
 message.install.dir.exist=The folder [APPLICATIONFOLDER] already exist. Whould you like to install to that folder anyway?
+message.invalid.install.dir=Warning: Invalid install directory {0}. Install directory should be a relative sub-path under the default installation location such as "Program Files". Defaulting to application name "{1}".
 
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/template.iss	Tue Mar 26 08:54:43 2019 -0400
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/template.iss	Tue Mar 26 08:57:28 2019 -0400
@@ -10,7 +10,7 @@
 AppCopyright=APPLICATION_COPYRIGHT
 VersionInfoVersion=APPLICATION_VERSION
 VersionInfoDescription=APPLICATION_DESCRIPTION
-DefaultDirName=APPLICATION_INSTALL_ROOT\INSTALLER_NAME
+DefaultDirName=APPLICATION_INSTALL_ROOT\INSTALL_DIR
 DisableStartupPrompt=Yes
 DisableDirPage=DISABLE_DIR_PAGE
 DisableProgramGroupPage=Yes
--- a/test/jdk/tools/jpackage/createimage/JPackageCreateImageModularJarTest.java	Tue Mar 26 08:54:43 2019 -0400
+++ b/test/jdk/tools/jpackage/createimage/JPackageCreateImageModularJarTest.java	Tue Mar 26 08:57:28 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/test/jdk/tools/jpackage/createinstaller/windows/base/JPackageCreateInstallerFileAssociationsBase.java	Tue Mar 26 08:54:43 2019 -0400
+++ b/test/jdk/tools/jpackage/createinstaller/windows/base/JPackageCreateInstallerFileAssociationsBase.java	Tue Mar 26 08:57:28 2019 -0400
@@ -136,25 +136,39 @@
         }
     }
 
-    private static void init(String name, String ext) {
+    private static void init(String name, String ext, String installDir, String testExt) {
         TEST_NAME = name;
         EXT = ext;
-        TEST_EXT = "jptest1";
+        TEST_EXT = testExt;
         OUTPUT = "output" + File.separator + TEST_NAME + "-1.0." + EXT;
-        CMD = new String[]{
-            "create-installer",
-            "--installer-type", EXT,
-            "--input", "input",
-            "--output", "output",
-            "--name", TEST_NAME,
-            "--main-jar", "hello.jar",
-            "--main-class", "Hello",
-            "--files", "hello.jar",
-            "--file-associations", "fa.properties"};
+        if (installDir == null) {
+            CMD = new String[]{
+                "create-installer",
+                "--installer-type", EXT,
+                "--input", "input",
+                "--output", "output",
+                "--name", TEST_NAME,
+                "--main-jar", "hello.jar",
+                "--main-class", "Hello",
+                "--files", "hello.jar",
+                "--file-associations", "fa.properties"};
+        } else {
+            CMD = new String[]{
+                "create-installer",
+                "--installer-type", EXT,
+                "--input", "input",
+                "--output", "output",
+                "--name", TEST_NAME,
+                "--main-jar", "hello.jar",
+                "--main-class", "Hello",
+                "--files", "hello.jar",
+                "--file-associations", "fa.properties",
+                "--install-dir", installDir};
+        }
     }
 
-    public static void run(String name, String ext) throws Exception {
-        init(name, ext);
+    public static void run(String name, String ext, String installDir, String testExt) throws Exception {
+        init(name, ext, installDir, testExt);
 
         if (JPackageInstallerHelper.isVerifyInstall()) {
             verifyInstall();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/jpackage/createinstaller/windows/base/JPackageCreateInstallerInstallDirBase.java	Tue Mar 26 08:57:28 2019 -0400
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+public class JPackageCreateInstallerInstallDirBase {
+
+    private static String TEST_NAME;
+    private static String EXT;
+    private static String OUTPUT;
+    private static String[] CMD;
+    private static String INSTALL_DIR;
+
+    private static void copyResults() throws Exception {
+        List<String> files = new ArrayList<>();
+        files.add(OUTPUT);
+        JPackageInstallerHelper.copyTestResults(files);
+    }
+
+    private static void testCreateInstaller() throws Exception {
+        JPackageHelper.executeCLI(true, CMD);
+        JPackageInstallerHelper.validateOutput(OUTPUT);
+        copyResults();
+    }
+
+    private static void verifyInstall() throws Exception {
+        String app = JPackagePath.getWinInstalledApp(INSTALL_DIR, TEST_NAME);
+        JPackageInstallerHelper.validateApp(app);
+
+        // Validate start menu
+        JPackageInstallerHelper.validateStartMenu("Unknown", TEST_NAME, false);
+
+        // Validate desktop shortcut
+        JPackageInstallerHelper.validateDesktopShortcut(TEST_NAME, true);
+    }
+
+    private static void verifyUnInstall() throws Exception {
+        String folderPath = JPackagePath.getWinInstallFolder(INSTALL_DIR);
+        File folder = new File(folderPath);
+        if (folder.exists()) {
+            throw new AssertionError("Error: " + folder.getAbsolutePath() + " exist");
+        }
+
+        // Validate start menu
+        JPackageInstallerHelper.validateStartMenu("Unknown", TEST_NAME, false);
+
+        // Validate desktop shortcut
+        JPackageInstallerHelper.validateDesktopShortcut(TEST_NAME, false);
+    }
+
+    private static void init(String name, String ext) {
+        TEST_NAME = name;
+        EXT = ext;
+        OUTPUT = "output" + File.separator + TEST_NAME + "-1.0." + EXT;
+        INSTALL_DIR = "TestVendor\\JPackageCreateInstallerInstallDirTestDir";
+        CMD = new String[]{
+            "create-installer",
+            "--installer-type", EXT,
+            "--input", "input",
+            "--output", "output",
+            "--name", TEST_NAME,
+            "--main-jar", "hello.jar",
+            "--main-class", "Hello",
+            "--files", "hello.jar",
+            "--install-dir", INSTALL_DIR,
+            "--win-shortcut"};
+    }
+
+    public static void run(String name, String ext) throws Exception {
+        init(name, ext);
+
+        if (JPackageInstallerHelper.isVerifyInstall()) {
+            verifyInstall();
+        } else if (JPackageInstallerHelper.isVerifyUnInstall()) {
+            verifyUnInstall();
+        } else {
+            JPackageHelper.createHelloInstallerJar();
+            testCreateInstaller();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/jpackage/createinstaller/windows/exe/JPackageCreateInstallerFileAssociationsInstallDirTest.java	Tue Mar 26 08:57:28 2019 -0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary jpackage create installer test
+ * @library ../../../helpers
+ * @library ../base
+ * @build JPackageHelper
+ * @build JPackagePath
+ * @build JPackageInstallerHelper
+ * @build JPackageCreateInstallerFileAssociationsBase
+ * @requires (os.family == "windows")
+ * @modules jdk.jpackage
+ * @ignore
+ * @run main/othervm -Xmx512m JPackageCreateInstallerFileAssociationsInstallDirTest
+ */
+public class JPackageCreateInstallerFileAssociationsInstallDirTest {
+    private static final String TEST_NAME = "JPackageCreateInstallerFileAssociationsInstallDirTest";
+    private static final String EXT = "exe";
+    private static final String INSTALL_DIR
+            = "TestVendor\\JPackageCreateInstallerFileAssociationsInstallDirTestDir";
+    private static final String TEST_EXT = "jptest3";
+
+    public static void main(String[] args) throws Exception {
+        JPackageCreateInstallerFileAssociationsBase.run(TEST_NAME, EXT, INSTALL_DIR, TEST_EXT);
+    }
+}
--- a/test/jdk/tools/jpackage/createinstaller/windows/exe/JPackageCreateInstallerFileAssociationsTest.java	Tue Mar 26 08:54:43 2019 -0400
+++ b/test/jdk/tools/jpackage/createinstaller/windows/exe/JPackageCreateInstallerFileAssociationsTest.java	Tue Mar 26 08:57:28 2019 -0400
@@ -38,8 +38,9 @@
 public class JPackageCreateInstallerFileAssociationsTest {
     private static final String TEST_NAME = "JPackageCreateInstallerFileAssociationsTest";
     private static final String EXT = "exe";
+    private static final String TEST_EXT = "jptest1";
 
     public static void main(String[] args) throws Exception {
-        JPackageCreateInstallerFileAssociationsBase.run(TEST_NAME, EXT);
+        JPackageCreateInstallerFileAssociationsBase.run(TEST_NAME, EXT, null, TEST_EXT);
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/jpackage/createinstaller/windows/exe/JPackageCreateInstallerInstallDirTest.java	Tue Mar 26 08:57:28 2019 -0400
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary jpackage create installer install dir test
+ * @library ../../../helpers
+ * @library ../base
+ * @build JPackageHelper
+ * @build JPackagePath
+ * @build JPackageInstallerHelper
+ * @build JPackageCreateInstallerInstallDirBase
+ * @requires (os.family == "windows")
+ * @modules jdk.jpackage
+ * @ignore
+ * @run main/othervm -Xmx512m JPackageCreateInstallerInstallDirTest
+ */
+public class JPackageCreateInstallerInstallDirTest {
+    private static final String TEST_NAME = "JPackageCreateInstallerInstallDirTest";
+    private static final String EXT = "exe";
+
+    public static void main(String[] args) throws Exception {
+        JPackageCreateInstallerInstallDirBase.run(TEST_NAME, EXT);
+    }
+}
--- a/test/jdk/tools/jpackage/createinstaller/windows/exe/install.bat	Tue Mar 26 08:54:43 2019 -0400
+++ b/test/jdk/tools/jpackage/createinstaller/windows/exe/install.bat	Tue Mar 26 08:57:28 2019 -0400
@@ -11,4 +11,6 @@
 JPackageCreateInstallerLicenseTest-1.0.exe
 JPackageCreateInstallerWinUpgradeUUIDTest-1.0.exe
 JPackageCreateInstallerWinUpgradeUUIDTest-2.0.exe
+JPackageCreateInstallerInstallDirTest-1.0.exe
+JPackageCreateInstallerFileAssociationsInstallDirTest-1.0.exe
 PAUSE
--- a/test/jdk/tools/jpackage/createinstaller/windows/exe/uninstall.bat	Tue Mar 26 08:54:43 2019 -0400
+++ b/test/jdk/tools/jpackage/createinstaller/windows/exe/uninstall.bat	Tue Mar 26 08:57:28 2019 -0400
@@ -8,4 +8,6 @@
 "%ProgramFiles%\JPackageCreateInstallerWinShortcutTest\unins000.exe"
 "%ProgramFiles%\JPackageCreateInstallerLicenseTest\unins000.exe"
 "%ProgramFiles%\JPackageCreateInstallerWinUpgradeUUIDTest\unins000.exe"
+"%ProgramFiles%\TestVendor\JPackageCreateInstallerInstallDirTestDir\unins000.exe"
+"%ProgramFiles%\TestVendor\JPackageCreateInstallerFileAssociationsInstallDirTestDir\unins000.exe"
 PAUSE
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/jpackage/createinstaller/windows/msi/JPackageCreateInstallerFileAssociationsInstallDirTest.java	Tue Mar 26 08:57:28 2019 -0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary jpackage create installer test
+ * @library ../../../helpers
+ * @library ../base
+ * @build JPackageHelper
+ * @build JPackagePath
+ * @build JPackageInstallerHelper
+ * @build JPackageCreateInstallerFileAssociationsBase
+ * @requires (os.family == "windows")
+ * @modules jdk.jpackage
+ * @ignore
+ * @run main/othervm -Xmx512m JPackageCreateInstallerFileAssociationsInstallDirTest
+ */
+public class JPackageCreateInstallerFileAssociationsInstallDirTest {
+    private static final String TEST_NAME = "JPackageCreateInstallerFileAssociationsInstallDirTest";
+    private static final String EXT = "msi";
+    private static final String INSTALL_DIR
+            = "TestVendor\\JPackageCreateInstallerFileAssociationsInstallDirTestDir";
+    private static final String TEST_EXT = "jptest3";
+
+    public static void main(String[] args) throws Exception {
+        JPackageCreateInstallerFileAssociationsBase.run(TEST_NAME, EXT, INSTALL_DIR, TEST_EXT);
+    }
+}
--- a/test/jdk/tools/jpackage/createinstaller/windows/msi/JPackageCreateInstallerFileAssociationsTest.java	Tue Mar 26 08:54:43 2019 -0400
+++ b/test/jdk/tools/jpackage/createinstaller/windows/msi/JPackageCreateInstallerFileAssociationsTest.java	Tue Mar 26 08:57:28 2019 -0400
@@ -38,8 +38,9 @@
 public class JPackageCreateInstallerFileAssociationsTest {
     private static final String TEST_NAME = "JPackageCreateInstallerFileAssociationsTest";
     private static final String EXT = "msi";
+    private static final String TEST_EXT = "jptest1";
 
     public static void main(String[] args) throws Exception {
-        JPackageCreateInstallerFileAssociationsBase.run(TEST_NAME, EXT);
+        JPackageCreateInstallerFileAssociationsBase.run(TEST_NAME, EXT, null, TEST_EXT);
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/jpackage/createinstaller/windows/msi/JPackageCreateInstallerInstallDirTest.java	Tue Mar 26 08:57:28 2019 -0400
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary jpackage create installer install dir test
+ * @library ../../../helpers
+ * @library ../base
+ * @build JPackageHelper
+ * @build JPackagePath
+ * @build JPackageInstallerHelper
+ * @build JPackageCreateInstallerInstallDirBase
+ * @requires (os.family == "windows")
+ * @modules jdk.jpackage
+ * @ignore
+ * @run main/othervm -Xmx512m JPackageCreateInstallerInstallDirTest
+ */
+public class JPackageCreateInstallerInstallDirTest {
+    private static final String TEST_NAME = "JPackageCreateInstallerInstallDirTest";
+    private static final String EXT = "msi";
+
+    public static void main(String[] args) throws Exception {
+        JPackageCreateInstallerInstallDirBase.run(TEST_NAME, EXT);
+    }
+}
--- a/test/jdk/tools/jpackage/createinstaller/windows/msi/install.bat	Tue Mar 26 08:54:43 2019 -0400
+++ b/test/jdk/tools/jpackage/createinstaller/windows/msi/install.bat	Tue Mar 26 08:57:28 2019 -0400
@@ -11,4 +11,6 @@
 JPackageCreateInstallerLicenseTest-1.0.msi
 JPackageCreateInstallerWinUpgradeUUIDTest-1.0.msi
 JPackageCreateInstallerWinUpgradeUUIDTest-2.0.msi
+JPackageCreateInstallerInstallDirTest-1.0.msi
+JPackageCreateInstallerFileAssociationsInstallDirTest-1.0.msi
 PAUSE
--- a/test/jdk/tools/jpackage/createinstaller/windows/msi/uninstall.bat	Tue Mar 26 08:54:43 2019 -0400
+++ b/test/jdk/tools/jpackage/createinstaller/windows/msi/uninstall.bat	Tue Mar 26 08:57:28 2019 -0400
@@ -8,4 +8,6 @@
 MSIEXEC /uninstall JPackageCreateInstallerWinShortcutTest-1.0.msi
 MSIEXEC /uninstall JPackageCreateInstallerLicenseTest-1.0.msi
 MSIEXEC /uninstall JPackageCreateInstallerWinUpgradeUUIDTest-2.0.msi
+MSIEXEC /uninstall JPackageCreateInstallerInstallDirTest-1.0.msi
+MSIEXEC /uninstall JPackageCreateInstallerFileAssociationsInstallDirTest-1.0.msi
 PAUSE
\ No newline at end of file
--- a/test/jdk/tools/jpackage/helpers/JPackagePath.java	Tue Mar 26 08:54:43 2019 -0400
+++ b/test/jdk/tools/jpackage/helpers/JPackagePath.java	Tue Mar 26 08:57:28 2019 -0400
@@ -220,6 +220,11 @@
                 + testName + ".exe";
     }
 
+    public static String getWinInstalledApp(String installDir, String testName) {
+        return getWinProgramFiles() + File.separator + installDir + File.separator
+                + testName + ".exe";
+    }
+
     public static String getOSXInstalledApp(String testName) {
         return File.separator + "Applications" + File.separator + testName
                 + ".app" + File.separator + "Contents" + File.separator