简体   繁体   English

我如何定义我的可执行 jar 文件的正确类路径?

[英]How do i define the right class path to my executable jar file?

I am having problem with creating an executable JAR file where i can double click an icon and make my program start.我在创建可执行 JAR 文件时遇到问题,我可以在其中双击图标并启动我的程序。 I've made a fun little app for my friend for him to try this Xmas, but i've spent way too many hours trying to make this work.我为我的朋友制作了一个有趣的小应用程序,让他尝试这个圣诞节,但我花了太多时间来尝试让它发挥作用。

When i try to execute the jar file, i get a ClassNotFoundException and i cannot for the life of me figure it out.当我尝试执行 jar 文件时,我得到一个 ClassNotFoundException 并且我一生都无法弄清楚。 I am using Intellij and believe the fault is under file>projet structure>artifacts>JavaFX and under application class.我正在使用 Intellij 并相信故障出在文件>项目结构>工件>JavaFX和应用程序类下。 What is supposed to be there?那里应该有什么? i tried class path to the main class我尝试了主类的类路径

If you are using maven or gradle to build your application, the simplest thing you can do to make a self sufficient, runnable jar is, to create a fatjar (or uber jar ).如果您正在使用 maven 或 gradle 来构建您的应用程序,那么制作一个自给自足、可运行的 jar 的最简单的方法就是创建一个fatjar (或uber jar )。 A fatjar is nothing but a jar containing your classes along with the dependencies. fatjar 只不过是一个包含类和依赖项的 jar。

Refer answer below for maven based project : How can I create an executable JAR with dependencies using Maven?请参阅以下基于 Maven 的项目的答案: 如何使用 Maven 创建具有依赖项的可执行 JAR?

Or for gradle based project : How do I create an executable fat jar with Gradle with implementation dependencies或者对于基于 gradle 的项目: How do I create an executable fat jar with Gradle with implementation dependencies

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使我的.jar可执行文件? - How do I make my .jar executable? 当我的班级和文本文件位于可执行JAR中时,如何编写代码访问文本文件? - How can I write code to access a text file when my class and the text file are in an Executable JAR? 如何从我的intellij项目中创建可执行的JAR文件? - How do I create an executable JAR file from my intellij project? 如何将 .jar 文件转换为 Unix 可执行文件? (苹果电脑) - How do I convert a .jar file to a Unix executable file? (Mac) 将测试导出到可执行jar时如何在可执行Jar文件中包含Chrome驱动程序 - How to include Chrome Driver in executable Jar file when I export my tests to a Executable jar 如何使用 Maven 为我的 webapp 创建可执行 jar? - How do I create an executable jar for my webapp with Maven? 如何在可执行文件 jar 中运行 lombok 功能? - How can I run lombok features in my executable jar file? 如何将“jar:file”URI转换为Jar文件的路径? - How do I convert a “jar:file” URI to the path of Jar file? 如何使用Eclipse将GWT项目导出到可执行JAR文件中? - How do I export a GWT project into a executable JAR file with Eclipse? 我是一名初级Java程序员,正在寻求有关如何将.class或.java源文件导入可执行jar文件的帮助 - I am a beginning java coder looking for help on how to import my .class or .java source file into an executable jar file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM