Skip to content

Commit 2d5a86a

Browse files
committed
Merge branch 'issue-325' into devel
2 parents 7c3a212 + a32cba0 commit 2d5a86a

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/main/java/io/github/fvarrui/javapackager/packagers/Context.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ public static GradleContext getGradleContext() {
8888
}
8989

9090
public File getDefaultToolchain() {
91-
return new File(System.getProperty("java.home")); // Use java.home as fallback
91+
if (System.getenv("JAVA_HOME") != null) {
92+
return new File(System.getenv("JAVA_HOME")); // Use JAVA_HOME as fallback
93+
}
94+
return new File(System.getProperty("java.home"));
9295
}
9396

9497
}

src/main/java/io/github/fvarrui/javapackager/utils/JarUtils.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,20 @@
55

66
import org.codehaus.plexus.util.cli.CommandLineException;
77

8+
import io.github.fvarrui.javapackager.packagers.Context;
9+
810
public class JarUtils {
911

10-
public static void addFileToJar(File jarFile, File newFile) throws IOException, CommandLineException {
11-
File jar = new File(System.getProperty("java.home"), "/bin/jar");
12+
/**
13+
* Runs "jar uf <jarfile> <newfile>" to add newfile into jarfile.
14+
* @param jarFile JAR file
15+
* @param newFile File to add to jar file
16+
* @throws IOException If something related to IO went wrong
17+
* @throws CommandLineException If something related to command execution went wrong
18+
*/
19+
public static void addFileToJar(File jarFile, File newFile) throws IOException, CommandLineException {
20+
File jar = new File(Context.getContext().getDefaultToolchain(), "/bin/jar");
1221
CommandUtils.executeOnDirectory(newFile.getParentFile(), jar.getAbsolutePath(), "uf", jarFile, newFile.getName());
1322
}
1423

15-
}
24+
}

0 commit comments

Comments
 (0)