< prev index next >

src/jdk.jpackage/share/classes/jdk/jpackage/internal/AbstractAppImageBuilder.java

Print this page

        

@@ -66,11 +66,10 @@
 
     public abstract void prepareApplicationFiles() throws IOException;
     public abstract void prepareJreFiles() throws IOException;
     public abstract Path getAppDir();
     public abstract Path getAppModsDir();
-    public abstract String getRelativeModsDir();
 
     public Path getRoot() {
         return this.root;
     }
 

@@ -171,11 +170,11 @@
             return result;
         }
     }
 
     public void writeCfgFile(Map<String, ? super Object> params,
-            File cfgFileName, String runtimeLocation) throws IOException {
+            File cfgFileName) throws IOException {
         cfgFileName.delete();
         File mainJar = JLinkBundlerHelper.getMainJar(params);
         ModFile.ModType mainJarType = ModFile.ModType.Unknown;
 
         if (mainJar != null) {

@@ -187,13 +186,14 @@
         try (PrintStream out = new PrintStream(cfgFileName)) {
 
             out.println("[Application]");
             out.println("app.name=" + APP_NAME.fetchFrom(params));
             out.println("app.version=" + VERSION.fetchFrom(params));
-            out.println("app.runtime=" + runtimeLocation);
+            out.println("app.runtime=" + getCfgRuntimeDir());
             out.println("app.identifier=" + IDENTIFIER.fetchFrom(params));
-            out.println("app.classpath=" + CLASSPATH.fetchFrom(params));
+            out.println("app.classpath="
+                    + getCfgClassPath(CLASSPATH.fetchFrom(params)));
 
             // The main app is required to be a jar, modular or unnamed.
             if (mainModule != null &&
                     (mainJarType == ModFile.ModType.Unknown ||
                     mainJarType == ModFile.ModType.ModularJar)) {

@@ -202,16 +202,16 @@
                 String mainClass = JLinkBundlerHelper.getMainClass(params);
                 // If the app is contained in an unnamed jar then launch it the
                 // legacy way and the main class string must be
                 // of the format com/foo/Main
                 if (mainJar != null) {
-                    out.println("app.mainjar="
+                    out.println("app.mainjar=" + getCfgAppDir()
                             + mainJar.toPath().getFileName().toString());
                 }
                 if (mainClass != null) {
                     out.println("app.mainclass="
-                            + mainClass.replaceAll("\\.", "/"));
+                            + mainClass.replace("\\", "/"));
                 }
             }
 
             out.println();
             out.println("[JavaOptions]");

@@ -221,11 +221,11 @@
             }
             Path modsDir = getAppModsDir();
 
             if (modsDir != null && modsDir.toFile().exists()) {
                 out.println("--module-path");
-                out.println("$APPDIR/" + getRelativeModsDir());
+                out.println(getCfgAppDir().replace("\\","/") + "mods");
             }
 
             out.println();
             out.println("[ArgOptions]");
             List<String> args = ARGUMENTS.fetchFrom(params);

@@ -239,6 +239,31 @@
                 }
             }
         }
     }
 
+    String getCfgAppDir() {
+        return "$APPDIR" + File.separator
+                + getAppDir().getFileName() + File.separator;
+    }
+
+    String getCfgRuntimeDir() {
+        return "$APPDIR" + File.separator + "runtime";
+    }
+
+    String getCfgClassPath(String classpath) {
+        String cfgAppDir = getCfgAppDir();
+
+        StringBuilder sb = new StringBuilder();
+        for (String path : classpath.split("[:;]")) {
+            if (path.length() > 0) {
+                sb.append(cfgAppDir);
+                sb.append(path);
+                sb.append(File.pathSeparator);
+            }
+        }
+        if (sb.length() > 0) {
+            sb.deleteCharAt(sb.length() - 1);
+        }
+        return sb.toString();
+    }
 }
< prev index next >