简体   繁体   English

slick2d(lwjgl),漂亮,kryonet-如何构建一个.jar?

[英]slick2d(lwjgl), nifty, kryonet - how to build a .jar?

i'm using the libraries stated above. 我正在使用上述库。 I'm quite confused how to build a executionable .jar file tho. 我很困惑如何构建可执行的.jar文件。 It wont work somehow. 它不会以某种方式工作。

I'm using the maven assembly plugin and so far I was able to create a .jar for my server. 我正在使用maven程序集插件,到目前为止,我已经能够为服务器创建一个.jar。 My server only uses kryonet and javafx, which i have in maven. 我的服务器仅使用我在maven中拥有的kryonet和javafx。

Nifty GUI unfortunately i only have locally on my drive, I added a local repository to my pom.xml. 不幸的是,Nifty GUI只有本地驱动器,我在pom.xml中添加了本地存储库。

Due to lwjgl natives I chose to use the maven-nativedependencies-plugin, the copy process does work and stuff and the .jar is succesfully created. 由于lwjgl本机,我选择使用maven-nativedependencies-plugin,因此复制过程可以正常工作,并且可以成功创建.jar。

I'm not sure where my problem is. 我不确定我的问题在哪里。 To create my server .jar file wasn't a big deal but i'm hanging on the game client, i think this has it's origin in slick2d / lwjgl and or nifty gui. 创建我的服务器.jar文件没什么大不了,但是我挂在游戏客户端上,我认为这源于slick2d / lwjgl和或漂亮的gui。

You can find my pom here: 您可以在这里找到我的pom:

http://pastebin.com/PzG1cSuF http://pastebin.com/PzG1cSuF

Maven Screenshot if that helps: Maven屏幕截图(如果有帮助):

http://i.stack.imgur.com/osbnI.jpg (click for better size) http://i.stack.imgur.com/osbnI.jpg (单击可获得更大的尺寸)

mavenscreenshot

Thanks in advance ! 提前致谢 !

There are several approaches you could take. 您可以采取几种方法。

I would suggest: 我会建议:

  1. Add an explicit "Class-path" entry in your .jars MANIFEST.MF that includes your dependent libraries: 在您的.jars MANIFEST.MF中添加一个显式的“类路径”条目,其中包括您的依赖库:

    http://alvinalexander.com/blog/post/java/how-build-executable-jar-file-reference-dependencies http://alvinalexander.com/blog/post/java/how-build-executable-jar-file-reference-dependencies

    Example build.xml snippet: 示例build.xml片段:

     <tstamp/><!-- needed for TODAY --> <manifest file="MANIFEST.MF"> <attribute name="Built-By" value="${manifest.built.by}"/> <attribute name="Created-By" value="${manifest.created.by}"/> <attribute name="Main-Class" value="${manifest.main.class}"/> <attribute name="Implementation-Version" value="${version.number}-${build.number}"/> <attribute name="Built-Date" value="${TODAY}"/> <attribute name="Class-Path" value="${mf.classpath}" /> </manifest> 
  2. Ship the dependent .jar's along with your application's jar. 将依赖的.jar和您的应用程序的jar一起运输。 In other words, copy the dependent .jars to the same install directory when you install your app. 换句话说,在安装应用程序时,将相关的.jars复制到同一安装目录。

Another, different approach might be: 另一种不同的方法可能是:

  1. Create a "fat/uber" .jar: 创建一个“ fat / uber” .jar:

http://www.mkyong.com/maven/create-a-fat-jar-file-maven-assembly-plugin/ http://www.mkyong.com/maven/create-a-fat-jar-file-maven-assembly-plugin/

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM