简体   繁体   中英

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. It wont work somehow.

I'm using the maven assembly plugin and so far I was able to create a .jar for my server. My server only uses kryonet and javafx, which i have in maven.

Nifty GUI unfortunately i only have locally on my drive, I added a local repository to my 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.

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.

You can find my pom here:

http://pastebin.com/PzG1cSuF

Maven Screenshot if that helps:

http://i.stack.imgur.com/osbnI.jpg (click for better size)

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:

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

    Example build.xml snippet:

     <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. In other words, copy the dependent .jars to the same install directory when you install your app.

Another, different approach might be:

  1. Create a "fat/uber" .jar:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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