# HG changeset patch # User herrick # Date 1551314726 18000 # Node ID 8018ecf829bc00e5e775f853c6a89e32bdad58fa # Parent b1291b2cedc9ad328b85d156cd323d8be8369673 8217902: jpackage fails with --app-image option on mac Reviewed-by: almatvee diff -r b1291b2cedc9 -r 8018ecf829bc src/jdk.jpackage/share/classes/jdk/jpackage/internal/DeployParams.java --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/DeployParams.java Wed Feb 27 08:53:56 2019 -0500 +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/DeployParams.java Wed Feb 27 19:45:26 2019 -0500 @@ -410,14 +410,9 @@ Arguments.CLIOptions.PREDEFINED_APP_IMAGE.getId()); if (appImage != null) { File appImageDir = new File(appImage); - if (!appImageDir.exists()) { + if (!appImageDir.exists() || appImageDir.list().length == 0) { throw new PackagerException("ERR_AppImageNotExist", appImage); } - - File appImageAppDir = new File(appImage + File.separator + "app"); - if (!appImageAppDir.exists()) { - throw new PackagerException("ERR_AppImageInvalid", appImage); - } } // Validate build-root diff -r b1291b2cedc9 -r 8018ecf829bc src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinAppBundler.java --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinAppBundler.java Wed Feb 27 08:53:56 2019 -0500 +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinAppBundler.java Wed Feb 27 19:45:26 2019 -0500 @@ -29,6 +29,7 @@ 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; import java.util.Collection; @@ -118,14 +119,23 @@ if (appName == null) { // Use WIN_APP_IMAGE here, since we already copy pre-defined // image to WIN_APP_IMAGE - File appImageDir = new File( - WIN_APP_IMAGE.fetchFrom(p).toString() + "\\app"); - File [] files = appImageDir.listFiles( + File appImageDir = WIN_APP_IMAGE.fetchFrom(p); + + File appDir = new File(appImageDir.toString() + "\\app"); + File [] files = appDir.listFiles( (File dir, String name) -> name.endsWith(".cfg")); if (files == null || files.length == 0) { - throw new RuntimeException(MessageFormat.format( - I18N.getString("error.cannot-find-launcher"), - appImageDir)); + String name = APP_NAME.fetchFrom(p); + Path exePath = appImageDir.toPath().resolve(name + ".exe"); + Path icoPath = appImageDir.toPath().resolve(name + ".ico"); + if (exePath.toFile().exists() && + icoPath.toFile().exists()) { + return name; + } else { + throw new RuntimeException(MessageFormat.format( + I18N.getString("error.cannot-find-launcher"), + appImageDir)); + } } else { appName = files[0].getName(); int index = appName.indexOf(".");