You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu下JavaFX项目:寻求免费独立JAR打包工具

Hey there! Let's work through your JAR packaging issue for your JavaFX app on Ubuntu. You're looking for free, standalone tools that let you manually add all required JARs and specify a main class to build a command-line-runnable JAR—here are some solid options, including the ones you've already found, plus a few more worth checking out:

Free Standalone JAR Packaging Tools for Ubuntu JavaFX Apps

1. Tools You've Already Identified

  • InstallBuilder: Its open-source free version fits your needs perfectly. It lets you manually add all dependency JARs, specify your main class, and build a runnable JAR (it can also create cross-platform installers if you ever need that later). It's command-line friendly, no fancy UI required, and works great on Ubuntu.
  • lzPack: This lightweight tool is exactly the kind of no-frills option you're after. You can manually manage your dependencies, set your main class, and generate an executable JAR with minimal setup—definitely worth testing.

2. Additional Free Tools to Try

  • Apache Maven: While it's a build tool, it gives you full manual control over dependencies and main class configuration. Just add a few lines to your pom.xml and run a terminal command to build your JAR. Here's a quick snippet for your setup:

    <build>
        <plugins>
            <!-- Basic JAR with main class and classpath -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>your.full.main.class.path</mainClass>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <!-- Optional: Build a single JAR with all dependencies included -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.4.2</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>your.full.main.class.path</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>build-fat-jar</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    

    Run mvn package in your project directory, and you'll get your runnable JAR in the target folder.

  • Gradle: Similar to Maven but with a more concise configuration. You can define your main class and dependencies in a build.gradle file, then build via the terminal. Example config:

    plugins {
        id 'java'
        id 'application'
    }
    
    mainClassName = 'your.full.main.class.path'
    
    // Build a basic JAR with classpath references
    jar {
        manifest {
            attributes(
                'Main-Class': mainClassName,
                'Class-Path': configurations.runtimeClasspath.files.collect { "lib/${it.name}" }.join(' ')
            )
        }
    }
    
    // Optional: Build a fat JAR with all dependencies included
    task fatJar(type: Jar) {
        manifest { attributes 'Main-Class': mainClassName }
        from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
        with jar
    }
    

    Run ./gradlew fatJar to generate your all-in-one runnable JAR.

  • JarSplice: A tiny, standalone Java tool that's perfect for quick JAR packaging. You can launch it via java -jar jarsplice.jar on Ubuntu, manually add all your dependency JARs (including JavaFX ones), set your main class, and export a runnable JAR in a few clicks. It has a simple, no-nonsense interface—exactly what you're looking for.

Quick Note for JavaFX Apps

Don't forget to include JavaFX's core JARs in your dependencies when using these tools. For Maven/Gradle, you can add JavaFX dependencies directly to your build file; for tools like JarSplice or lzPack, just add the JavaFX JARs from your SDK alongside your other dependencies.

内容的提问来源于stack exchange,提问作者user1300214

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:34:20