### Packr JSON Configuration Example Source: https://github.com/libgdx/packr/blob/master/README.md Provides an example of a JSON configuration file used to define Packr packaging parameters. This allows for a more structured and reusable way to specify settings like platform, JDK, executable, classpath, main class, VM arguments, resources, and output. ```json { "platform": "mac", "jdk": "/Users/badlogic/Downloads/OpenJDK8U-jdk_x64_mac_hotspot_8u252b09.tar.gz", "executable": "myapp", "classpath": [ "myjar.jar" ], "removelibs": [ "myjar.jar" ], "mainclass": "com.my.app.MainClass", "vmargs": [ "-Xmx1G" ], "resources": [ "src/main/resources", "path/to/other/assets" ], "minimizejre": "soft", "output": "out-mac" } ``` -------------------------------- ### Packr Command-Line: Custom Minimization Source: https://context7.com/libgdx/packr/llms.txt Example of using the Packr command-line interface with a custom JRE minimization profile. This command bundles a Linux 64-bit application, specifying the JDK, executable name, classpath, main class, VM arguments, output directory, and a custom minimization JSON file. ```bash # Use custom minimization profile java -jar packr-all.jar \ --platform linux64 \ --jdk /path/to/jdk8 \ --executable myapp \ --classpath myapp.jar \ --mainclass com.example.Main \ --minimizejre my-custom-minimize.json \ --output dist/linux ``` -------------------------------- ### JRE Minimization Configuration (JSON) Source: https://github.com/libgdx/packr/blob/master/README.md A JSON configuration file used by Packr to specify which files and directories within a JRE should be removed or modified to reduce its size. This example shows a 'soft' profile that removes specific packages from rt.jar and certain platform-specific executables. ```json { "reduce": [ { "archive": "jre/lib/rt.jar", "paths": [ "com/sun/corba", "com/sun/jndi", "com/sun/media", "com/sun/naming", "com/sun/rowset", "sun/applet", "sun/corba", "sun/management" ] } ], "remove": [ { "platform": "*", "paths": [ "jre/lib/rhino.jar" ] }, { "platform": "windows", "paths": [ "jre/bin/*.exe", "jre/bin/client" ] } ] } ``` -------------------------------- ### Packr Configuration and Execution in Java Source: https://github.com/libgdx/packr/blob/master/README.md This Java code demonstrates how to configure and use the Packr library to package an application. It involves creating a PackrConfig object, setting various parameters like platform, JDK path, executable name, classpath, and main class, and then invoking the Packr.pack() method. ```java PackrConfig config = new PackrConfig(); config.platform = PackrConfig.Platform.Windows32; config.jdk = "/User/badlogic/Downloads/openjdk-for-mac.zip"; config.executable = "myapp"; config.classpath = Arrays.asList("myjar.jar"); config.removePlatformLibs = config.classpath; config.mainClass = "com.my.app.MainClass"; config.vmArgs = Arrays.asList("-Xmx1G"); config.minimizeJre = "soft"; config.outDir = new java.io.File("out-mac"); config.useZgcIfSupportedOs = true; new Packr().pack(config); ``` -------------------------------- ### Packr CLI: Show Help (Shell) Source: https://github.com/libgdx/packr/blob/master/README.md Command to display the available options for Packr's extended command-line interface. This helps users understand the different parameters they can use. ```bash ./myapp -c --help ``` -------------------------------- ### Packr Command Line with JSON Configuration Source: https://context7.com/libgdx/packr/llms.txt These commands demonstrate how to run Packr using a JSON configuration file. The first command shows a basic invocation, while the second illustrates how to override JSON settings with command-line arguments. ```bash java -jar packr-all.jar my-packr-config.json ``` ```bash java -jar packr-all.jar --output target/custom-output --vmargs Xms512m -- my-packr-config.json ``` -------------------------------- ### Packr Command-Line Invocation Source: https://github.com/libgdx/packr/blob/master/README.md Demonstrates how to invoke Packr from the command line with various parameters to package a Java application. This includes specifying the platform, JDK, executable name, classpath, main class, VM arguments, resources, and output directory. ```bash java -jar packr-all.jar \ --platform mac \ --jdk OpenJDK11U-jre_x64_mac_hotspot_11.0.10_9.tar.gz \ --useZgcIfSupportedOs \ --executable myapp \ --classpath myjar.jar \ --mainclass com.my.app.MainClass \ --vmargs -Xmx1G \ --resources src/main/resources path/to/other/assets \ --output out-mac ``` -------------------------------- ### macOS Code Signing and Notarization Workflow (Bash) Source: https://context7.com/libgdx/packr/llms.txt This bash script outlines the steps for packaging, signing, and notarizing a macOS application using Packr. It includes creating the initial bundle, signing executables and libraries, signing the app bundle, creating a zip archive, submitting for notarization via `altool`, and stapling the ticket. ```bash # Step 1: Create the Packr bundle java -jar packr-all.jar \ --platform mac \ --jdk OpenJDK11U-jdk_x64_mac_hotspot_11.0.15_10.tar.gz \ --executable MyApp \ --classpath myapp.jar \ --mainclass com.example.Main \ --icon resources/icon.icns \ --bundle com.mycompany.myapp \ --output MyApp.app # Step 2: Sign all executables and shared libraries find MyApp.app -type f \( -name "*.dylib" -o -perm +111 \) -exec \ codesign --sign "Developer ID Application: Your Name (TEAMID)" \ --verbose=10 --timestamp --force --options runtime \ --entitlements entitlements.plist {} \; # Step 3: Sign the app bundle codesign --sign "Developer ID Application: Your Name (TEAMID)" \ --verbose=10 --timestamp --force --options runtime \ --entitlements entitlements.plist MyApp.app # Step 4: Create zip for notarization /usr/bin/ditto -c -k --keepParent MyApp.app MyApp.zip # Step 5: Submit for notarization xcrun altool --notarize-app \ --primary-bundle-id com.mycompany.myapp \ --username "developer@mycompany.com" \ --password "@keychain:AC_PASSWORD" \ --file MyApp.zip # Step 6: Staple the notarization ticket (after approval) xcrun stapler staple --verbose MyApp.app ``` -------------------------------- ### macOS Code Signing and Notarization Commands Source: https://github.com/libgdx/packr/blob/master/README.md This section provides command-line instructions for signing and notarizing an application on macOS using Packr. It includes steps for codesigning executables and libraries, zipping the application bundle, and submitting it for notarization using xcrun altool. ```bash codesign --sign --verbose=10 --timestamp --force --options runtime --entitlements /usr/bin/ditto -c -k --keepParent .zip xcrun altool --notarize-app --verbose --primary-bundle-id com.mydomain.myproduct --username '' --password "@keychain:" --file .zip ``` -------------------------------- ### Packr Command Line Invocation for Windows Source: https://context7.com/libgdx/packr/llms.txt This command illustrates creating a Windows bundle with Packr, including verbose output. It specifies the platform, JDK URL, executable name, classpath, main class, VM arguments, and output directory. ```bash java -jar packr-all.jar \ --platform windows64 \ --jdk https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15%2B10/OpenJDK11U-jdk_x64_windows_hotspot_11.0.15_10.zip \ --executable MyWindowsApp \ --classpath target/myapp.jar \ --mainclass com.example.Main \ --vmargs Xmx1G \ --verbose \ --output out-windows ``` -------------------------------- ### Packr Command Line Invocation for Linux Source: https://context7.com/libgdx/packr/llms.txt This command shows how to create a Linux bundle using Packr. It includes options for platform, JDK path, executable name, classpath, main class, VM arguments, and output directory. ```bash java -jar packr-all.jar \ --platform linux64 \ --jdk /path/to/OpenJDK11U-jdk_x64_linux_hotspot_11.0.15_10.tar.gz \ --executable mylinuxapp \ --classpath build/libs/myapp.jar \ --mainclass com.example.MyApplication \ --vmargs Xms64M \ --vmargs Xmx512M \ --output dist/linux ``` -------------------------------- ### Packr Command-Line with JSON Override Source: https://github.com/libgdx/packr/blob/master/README.md Illustrates how to combine command-line arguments with a JSON configuration file. Command-line options can override JSON settings, and for multi-value options, they are merged. The `--` delimiter is used when VM arguments follow the config file. ```bash java -jar packr-all.jar --output target/out-mac --vmargs -Xms256m -- my-packr-config.json ``` -------------------------------- ### Packr Command Line Invocation for macOS Source: https://context7.com/libgdx/packr/llms.txt This command demonstrates how to use Packr from the command line to create a macOS bundle. It specifies the platform, JDK, executable name, classpath, main class, VM arguments, resources, and output directory. ```bash java -jar packr-all.jar \ --platform mac \ --jdk OpenJDK11U-jre_x64_mac_hotspot_11.0.10_9.tar.gz \ --useZgcIfSupportedOs \ --executable myapp \ --classpath myjar.jar \ --mainclass com.my.app.MainClass \ --vmargs Xmx1G \ --resources src/main/resources path/to/other/assets \ --output out-mac ``` -------------------------------- ### Platform-Specific Output Structures (Text) Source: https://context7.com/libgdx/packr/llms.txt Illustrates the directory structures generated by Packr for Windows, Linux, and macOS. Understanding these structures is crucial for post-processing steps like signing and distribution, as they contain the native launcher, JVM configuration, application JAR, and the bundled JRE. ```text # Windows output structure dist/windows/ MyApp.exe # Native launcher executable MyApp.json # JVM configuration myapp.jar # Application JAR jre/ # Bundled JRE bin/ lib/ ... # Linux output structure dist/linux/ MyApp # Native launcher executable (chmod +x) MyApp.json # JVM configuration myapp.jar # Application JAR jre/ # Bundled JRE bin/ lib/ ... # macOS output structure (App Bundle) MyApp.app/ Contents/ Info.plist # App bundle metadata MacOS/ MyApp # Native launcher executable Resources/ myapp.jar # Application JAR MyApp.json # JVM configuration icons.icns # Application icon (if specified) jre/ # Bundled JRE bin/ lib/ ... ``` -------------------------------- ### Build Packr from Source (Gradle) Source: https://github.com/libgdx/packr/blob/master/README.md Command to build the Packr JAR file from its source code using Gradle. This command cleans the project and then assembles the final JAR artifact. ```bash ./gradlew clean assemble ``` -------------------------------- ### Packr Command-Line Invocation with JSON Config Source: https://github.com/libgdx/packr/blob/master/README.md Shows how to invoke Packr using a JSON configuration file. This simplifies the command line by referencing a separate configuration file that contains all the necessary packaging parameters. ```bash java -jar packr-all.jar my-packr-config.json ``` -------------------------------- ### Native Executable CLI Usage (Bash) Source: https://context7.com/libgdx/packr/llms.txt Demonstrates how to interact with the native executable generated by Packr using its command-line interface (CLI). The CLI is accessed by passing `-c` or `--cli` as the first argument, allowing for debugging, verbose output, and passing arguments to the Java application. ```bash # Show native launcher help ./myapp -c --help # Run with verbose JVM output ./myapp -c --verbose -- arg1 arg2 # Windows: spawn console window for terminal output myapp.exe -c --console --verbose -- arg1 arg2 # Pass arguments to Java application ./myapp -c -- --config=production --port=8080 # Normal execution (arguments passed directly to Java main()) ./myapp --config=production --port=8080 ``` -------------------------------- ### Packr Java API Configuration Source: https://context7.com/libgdx/packr/llms.txt This Java code snippet shows how to programmatically configure Packr using the `PackrConfig` class. It sets up parameters for a Windows build, including platform, JDK, executable name, classpath, main class, VM arguments, JRE minimization, and output directory, before executing the packaging process. ```java import com.badlogicgames.packr.Packr; import com.badlogicgames.packr.PackrConfig; import java.io.File; import java.util.Arrays; public class BuildDistribution { public static void main(String[] args) throws Exception { // Create configuration for Windows build PackrConfig config = new PackrConfig(); config.platform = PackrConfig.Platform.Windows64; config.jdk = "/path/to/OpenJDK11U-jdk_x64_windows_hotspot_11.0.15_10.zip"; config.executable = "MyApplication"; config.classpath = Arrays.asList("build/libs/myapp.jar", "libs/lwjgl.jar"); config.removePlatformLibs = Arrays.asList("build/libs/myapp.jar"); config.mainClass = "com.mycompany.app.Main"; config.vmArgs = Arrays.asList("Xmx1G", "Xms256M", "Djava.awt.headless=false"); config.minimizeJre = "soft"; config.outDir = new File("dist/windows"); config.useZgcIfSupportedOs = true; config.verbose = true; // Execute packaging new Packr().pack(config); System.out.println("Windows distribution created successfully!"); } } ``` -------------------------------- ### Create Minimal JRE and Package with Packr (Shell) Source: https://context7.com/libgdx/packr/llms.txt This snippet demonstrates creating a custom JRE using `jlink` and then packaging a Java application with this custom JRE using Packr. It specifies modules to include, optimizations like stripping debug info, and Packr's configuration for a Linux 64-bit platform. ```shell jlink \ --module-path $JAVA_HOME/jmods \ --output custom-jre \ --add-modules java.base,java.desktop,java.logging \ --strip-debug \ --no-header-files \ --no-man-pages \ --compress=2 java -jar packr-all.jar \ --platform linux64 \ --jdk custom-jre \ --executable myapp \ --classpath myapp.jar \ --mainclass com.example.Main \ --output dist/linux ``` -------------------------------- ### Create Minimal JRE and Package with Packr (Gradle Kotlin) Source: https://context7.com/libgdx/packr/llms.txt This Gradle task automates the creation of a custom JRE using `jlink` and then packages a Java application with Packr. It uses Kotlin DSL to define the task, specifying the JRE output directory and modules to include. ```kotlin // Gradle task to create jlink JRE and package with Packr tasks.register("createJlinkJre") { doLast { exec { executable = "${System.getProperty("java.home")}/bin/jlink" args("--module-path", "${System.getProperty("java.home")}/jmods") args("--output", "${buildDir}/custom-jre") args("--add-modules", "java.base,java.desktop,java.logging,java.sql") args("--strip-debug") args("--no-header-files") args("--no-man-pages") args("--compress=2") } } } ``` -------------------------------- ### macOS Entitlements for Notarization (XML) Source: https://context7.com/libgdx/packr/llms.txt This XML configuration file defines the necessary entitlements for macOS applications to be signed and notarized. It includes permissions for JIT, unsigned executable memory, and library validation, which are often required for packaged Java applications. ```xml com.apple.security.cs.allow-jit com.apple.security.cs.allow-unsigned-executable-memory com.apple.security.cs.disable-executable-page-protection com.apple.security.cs.disable-library-validation com.apple.security.cs.allow-dyld-environment-variables ``` -------------------------------- ### Packr CLI: Show Console Output on Windows (Shell) Source: https://github.com/libgdx/packr/blob/master/README.md Command to enable a console window for displaying output when running a Packr-built application on Windows. This is necessary because Windows executables do not show output by default. ```bash myapp.exe -c --console [arguments] ``` -------------------------------- ### Packr JSON Configuration File Source: https://context7.com/libgdx/packr/llms.txt This JSON file defines the configuration for Packr, allowing for a declarative approach to bundling applications. It includes settings for platform, JDK, executable name, classpath, main class, VM arguments, resources, JRE minimization, and output directory. ```json { "platform": "mac", "jdk": "/Users/developer/Downloads/OpenJDK11U-jdk_x64_mac_hotspot_11.0.15_10.tar.gz", "executable": "MyAwesomeApp", "classpath": [ "build/libs/myapp.jar", "libs/dependency1.jar", "libs/dependency2.jar" ], "removelibs": [ "build/libs/myapp.jar" ], "mainclass": "com.mycompany.app.MainClass", "vmargs": [ "Xmx1G", "Xms256m", "Dsun.java2d.noddraw=true" ], "resources": [ "src/main/resources", "assets/images", "config" ], "minimizejre": "soft", "useZgcIfSupportedOs": true, "icon": "resources/app-icon.icns", "bundle": "com.mycompany.myapp", "output": "dist/mac" } ``` -------------------------------- ### Gradle Integration: Create Distribution Task Source: https://context7.com/libgdx/packr/llms.txt Shows how to integrate Packr into a Gradle build script using Kotlin (`build.gradle.kts`). It defines a custom task `createDistribution` that depends on the `jar` task and executes Packr programmatically. Requires `com.badlogicgames.packr:packr` dependency. ```kotlin // build.gradle.kts plugins { application } repositories { mavenCentral() maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") } } dependencies { implementation("com.badlogicgames.packr:packr:3.0.3") } val packrAllArchive by configurations.creating dependencies { packrAllArchive("com.badlogicgames.packr:packr:3.0.3:all") } tasks.register("createDistribution") { dependsOn("jar") doLast { val javaHome = System.getProperty("java.home") exec { executable = "$javaHome/bin/java" args("-jar") args(packrAllArchive.resolve().first().absolutePath) args("--platform", "linux64") args("--jdk", "/path/to/jdk") args("--executable", "MyApp") args("--classpath", "${buildDir}/libs/myapp.jar") args("--mainclass", "com.example.Main") args("--vmargs", "Xmx1G") args("--output", "${buildDir}/dist/linux") } } } ``` -------------------------------- ### Packr Gradle Dependency Source: https://github.com/libgdx/packr/blob/master/README.md Demonstrates how to add Packr as a dependency in a Gradle build script. This allows for programmatic integration of Packr into the build process, enabling automated packaging of Java applications. ```kotlin repositories { mavenCentral() // Packr artifacts will be published to Maven Central in the future maven(uri("https://oss.sonatype.org/content/repositories/snapshots/")) // Packr snapshot artifacts will be published to Maven Central in the future // The following repositories are available until artifacts can be published to Maven Central maven(uri("http://artifactory.nimblygames.com/artifactory/ng-public-snapshot/")) } ``` -------------------------------- ### macOS Entitlements for Code Signing Source: https://github.com/libgdx/packr/blob/master/README.md This XML snippet defines the necessary entitlements for signing a PackrLauncher executable on macOS 10.15 (Catalina) with Java 14. These entitlements control security features like JIT execution and library validation. ```xml com.apple.security.cs.allow-jit com.apple.security.cs.allow-unsigned-executable-memory com.apple.security.cs.disable-executable-page-protection com.apple.security.cs.disable-library-validation com.apple.security.cs.allow-dyld-environment-variables ``` -------------------------------- ### Packr CLI: Enable Extended Interface (Shell) Source: https://github.com/libgdx/packr/blob/master/README.md Command to enable Packr's extended command-line interface, which allows passing parameters to the native executable itself, separated from Java application arguments by '--'. This is useful for accessing help or console output. ```bash ./myapp -c [arguments] -- -x y.z ``` -------------------------------- ### Packr Java API: Pack Application Source: https://context7.com/libgdx/packr/llms.txt Demonstrates using the Packr Java API to bundle a Java application for multiple platforms. It configures platform-specific JDKs, classpath, main class, VM arguments, and output directories. Dependencies include `com.badlogicgames.packr:packr`. ```java import com.badlogicgames.packr.Packr; import com.badlogicgames.packr.PackrConfig; import java.io.File; import java.util.Arrays; import java.util.List; public class MultiPlatformBuild { public static void main(String[] args) throws Exception { List classpath = Arrays.asList("build/libs/game.jar"); String mainClass = "com.mygame.GameLauncher"; List vmArgs = Arrays.asList("Xmx2G", "XstartOnFirstThread"); // Build for all platforms buildForPlatform(PackrConfig.Platform.Windows64, "jdks/OpenJDK11U-jdk_x64_windows_hotspot_11.0.15_10.zip", classpath, mainClass, vmArgs, "dist/windows"); buildForPlatform(PackrConfig.Platform.Linux64, "jdks/OpenJDK11U-jdk_x64_linux_hotspot_11.0.15_10.tar.gz", classpath, mainClass, vmArgs, "dist/linux"); buildForPlatform(PackrConfig.Platform.MacOS, "jdks/OpenJDK11U-jdk_x64_mac_hotspot_11.0.15_10.tar.gz", classpath, mainClass, vmArgs, "dist/mac"); } private static void buildForPlatform(PackrConfig.Platform platform, String jdk, List classpath, String mainClass, List vmArgs, String outputDir) throws Exception { PackrConfig config = new PackrConfig(); config.platform = platform; config.jdk = jdk; config.executable = "MyGame"; config.classpath = classpath; config.mainClass = mainClass; config.vmArgs = vmArgs; config.outDir = new File(outputDir); config.useZgcIfSupportedOs = true; config.resources = Arrays.asList(new File("assets"), new File("config")); new Packr().pack(config); System.out.println("Built for " + platform.desc); } } ``` -------------------------------- ### JRE Minimization Configuration (JSON) Source: https://context7.com/libgdx/packr/llms.txt A JSON configuration file for Packr's JRE minimization feature, primarily for Java 8 applications. It specifies paths to `reduce` from within archives and paths to `remove` entirely, with platform-specific rules. This helps reduce the size of the bundled JRE. ```json { "reduce": [ { "archive": "jre/lib/rt.jar", "paths": [ "com/sun/corba", "com/sun/jndi", "com/sun/media", "com/sun/naming", "com/sun/rowset", "sun/applet", "sun/corba", "sun/management", "javax/swing/plaf/nimbus", "javax/swing/plaf/synth" ] } ], "remove": [ { "platform": "*", "paths": [ "jre/lib/rhino.jar", "jre/lib/javaws.jar", "jre/lib/deploy.jar" ] }, { "platform": "windows", "paths": [ "jre/bin/*.exe", "jre/bin/client", "jre/bin/kinit.dll", "jre/bin/klist.dll" ] }, { "platform": "linux", "paths": [ "jre/bin/rmid", "jre/bin/rmiregistry", "jre/bin/tnameserv" ] } ] } ``` -------------------------------- ### Gradle Dependency for Packr Source: https://github.com/libgdx/packr/blob/master/README.md This snippet shows how to add the Packr library as a dependency in a Gradle build file. It specifies the Maven repository and the Packr artifact coordinates. ```gradle maven(uri("http://artifactory.nimblygames.com/artifactory/ng-public-release/")) } dependencies { implementation("com.badlogicgames.packr:packr:3.0.3") } ``` -------------------------------- ### macOS Notarization Status Check Commands Source: https://github.com/libgdx/packr/blob/master/README.md These bash commands outline the process for checking the notarization status of an application on macOS. It involves retrieving notarization history, parsing the request UUID, and periodically checking the status until it's no longer 'in progress'. ```bash xcrun altool --notarization-history 0 -u -p "@keychain:" --output-format xml # Parse the XML output for the last request UUID, regex: "(.*?)" # In a loop, every minute check the notarization status. xcrun altool --notarization-info -u -p "@keychain:" # Parse the output for the status, regex: ".*?Status:\s+(.*?)$" xcrun stapler staple --verbose ``` -------------------------------- ### Enable JRE Caching with Packr Source: https://context7.com/libgdx/packr/llms.txt Speeds up repeated builds by caching the extracted and minimized JRE. This is particularly beneficial in CI/CD pipelines. The `--cachejre` option specifies the directory for storing the cached JRE. ```bash # Use JRE caching java -jar packr-all.jar \ --platform linux64 \ --jdk https://example.com/openjdk11.tar.gz \ --executable myapp \ --classpath myapp.jar \ --mainclass com.example.Main \ --cachejre /tmp/packr-jre-cache \ --output dist/linux # Subsequent builds reuse cached JRE (much faster) java -jar packr-all.jar \ --platform linux64 \ --jdk https://example.com/openjdk11.tar.gz \ --executable myapp \ --classpath updated-myapp.jar \ --mainclass com.example.Main \ --cachejre /tmp/packr-jre-cache \ --output dist/linux-updated ``` -------------------------------- ### Configure Custom JRE Path with Packr Source: https://context7.com/libgdx/packr/llms.txt Specifies a custom directory for the bundled JRE. This is useful for organizing the distribution or supporting multiple JRE versions. The `jrePath` option dictates where the JRE will be placed within the output directory. ```bash java -jar packr-all.jar \ --platform linux64 \ --jdk /path/to/jdk \ --executable myapp \ --classpath myapp.jar \ --mainclass com.example.Main \ --jrePath runtime/java \ --output dist/linux ``` -------------------------------- ### Configure Custom JRE Path Programmatically with Packr Source: https://context7.com/libgdx/packr/llms.txt Configures a custom JRE path using Packr's Java API. This allows for dynamic configuration within Java applications or build scripts. The `jrePath` field in `PackrConfig` specifies the relative path for the JRE within the output directory. ```java PackrConfig config = new PackrConfig(); config.platform = PackrConfig.Platform.Linux64; config.jdk = "/path/to/jdk"; config.executable = "myapp"; config.classpath = Arrays.asList("myapp.jar"); config.mainClass = "com.example.Main"; config.jrePath = "runtime/java"; // JRE will be at dist/linux/runtime/java/ config.outDir = new File("dist/linux"); new Packr().pack(config); ``` -------------------------------- ### Remove Platform-Specific Libraries with Packr Source: https://context7.com/libgdx/packr/llms.txt Strips foreign platform libraries from JAR files when bundling applications with native libraries. This reduces the size of the final distribution. The `--removelibs` option specifies which JARs to process and which library types to remove based on the target platform. ```bash # Remove non-target platform native libraries from JARs java -jar packr-all.jar \ --platform windows64 \ --jdk /path/to/jdk \ --executable mygame \ --classpath game.jar lwjgl.jar lwjgl-natives.jar \ --removelibs game.jar lwjgl-natives.jar \ --mainclass com.mygame.Main \ --output dist/windows # This removes .dylib and .so files from the specified JARs when targeting Windows # Removes .dll and .dylib when targeting Linux # Removes .dll and .so when targeting macOS ``` -------------------------------- ### Remove Platform-Specific Libraries Programmatically with Packr Source: https://context7.com/libgdx/packr/llms.txt Configures the removal of platform-specific native libraries using Packr's Java API. This is useful for dynamically managing native dependencies in build processes. The `removePlatformLibs` field in `PackrConfig` takes a list of JAR files to process. ```java PackrConfig config = new PackrConfig(); config.platform = PackrConfig.Platform.Windows64; config.jdk = "/path/to/jdk"; config.executable = "mygame"; config.classpath = Arrays.asList("game.jar", "lwjgl.jar", "lwjgl-natives.jar"); config.removePlatformLibs = Arrays.asList("game.jar", "lwjgl-natives.jar"); config.mainClass = "com.mygame.Main"; config.outDir = new File("dist/windows"); new Packr().pack(config); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.