Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Wondering how to use JarSplice? This is the thread for you!  (Read 40171 times)
0 Members and 1 Guest are viewing this topic.
Offline Opiop
« Posted 2014-03-04 00:06:11 »

Alright, let me preface this entire thread by saying I pretty much made this tutorial after I offered to do it for someone who was struggling with it, so hopefully this will help that person and anyone else that finds this. Here we go!

First off, you're going to need JarSplice of course. You can obtain a copy from the following link:
The download link is just above the comment section, it's pretty tiny actually. You will use JarSplice if you need to deploy your program to multiple operating systems which require different native files. It's relatively easy after you get the hang of it, which is what I'm here for! I assume you are using Eclipse, so sorry if you aren't I have no idea how to export Jar files in any other IDEs.

First step, figure out what libraries your project is using:

In this picture you can see I use the following libraries:

- lwjgl.jar
- lwjgl_util.jar
- GLUtils.jar

The last library is of my own creation, so don't worry if you have no idea what it is!

Second step, Export the Jar with the libraries your program utilizes
Fortunately, this step is very easy if you are using Eclipse. Again, I have no idea how to do this in other IDEs, sorry! Follow the steps:

1. Right click on the project you wish to export.
2. Click Export

You will be presented with the following screen

Its very important you select Runnable JAR file.

Third step, setup the export options

You need to select the following options:

- Launch configuration: Set to be the "Main" class in your project. This is a drop down box, Eclipse automatically adds class files to this list when you run your project.
- Export Destination: Should be pretty obvious, just set where you want the Jar file to be exported

Apparently you can choose any of the three options when exporting, I didn't realize this. Sorry for the misleading information!

That's it! Hit Finish.

Ha, tricked you! We really aren't finished, we still need to use the dreaded JarSplice.

Fourth step, make sure you have the following files
Navigate to wherever you set the Jar file to export to, and make sure you have a Jar file and a folder that look something along the lines of this

(I wanted to show off my amazing Snarf Vader background!)

The "project_lib" folder contains all the libraries my project uses.

Fifth step, open JarSplice
I don't know why this is even a step, but you do actually have to open JarSplice to use... so be sure to do that!

Sixth step, add the libraries Eclipse put into that "project_lib" folder!
On the left side of JarSplice, click the Add Jar tab and then at the bottom click Add Jar(s).
Navigate to the export path and open your "project_lib" folder. Select all the Jar files in that folder and hit Add. Done!

Seventh step, add the natives
This is the trickiest part because many newbies don't know what the hell natives are, or where they are stored. It's pretty simple actually! Generally speaking, most people are using JarSplice to splice their OpenGL driven programs, and they use LWJGL as the wrapper to access it with Java. So, you had to have downloaded LWJGL to use it. Navigate to your LWJGL folder and go into the native folder. You should be presented with the following options:

The amazing thing about JarSplice is that it allows you to create one Jar with all those natives so you only have to maintain and deploy one file. You can, of course, deploy one Jar file per OS to cut down on the size, but native files are tiny. Anyway, add all the natives from these folders into JarSplice. You're almost done!

Eight step, select the main class
Easy step, just enter in the path to the main class of your project. But be careful! JarSplice doesn't need to know where you store the file on your computer, it just wants to navigate to the file as if it were you, the coder. What the hell am I talking about? I explained that poorly, so here's an example:

Say my "main" class is in package "com.mywebsite.mygame.Main". You would type this into JarSplice!

Last step, generate the Jar!
Click the Create Fat Jar tab and hit Create Fat Jar, then select a place to save it. Hit Save and done!

If you have any questions, feel free to comment! Thanks for reading, I hope I made your life easier!
Offline Jacob Pickens
« Reply #1 - Posted 2014-03-04 00:46:48 »

Thank you very much! I see exactly what I did wrong. Just to be honest here when I first started posting here I really didn't like you, but after I 'got to know you', your a pretty nice guy. Anyways thx!

Offline Sabomoth

Junior Devvie

Medals: 4
Exp: 3 years

« Reply #2 - Posted 2014-03-04 00:50:44 »

Why not just put the libraries in the jar with eclipse? Works just fine.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline BurntPizza

« JGO Bitwise Duke »

Medals: 485
Exp: 7 years

« Reply #3 - Posted 2014-03-04 00:54:45 »

@Sabomoth Exactly my thoughts, I mean, sure some of the extra functionality provided by JarSplice is fine, but the first two export options in Eclipse have always worked fine for me, with 'Package into' usually providing more compression.
Offline Opiop
« Reply #4 - Posted 2014-03-04 00:55:24 »

It's the way I do it, maybe I shouldn't have said you have to do it the way I do it, but oh well. And thanks Jacob, and haha it's ok, many people don't like me when they first meet me!
Offline HeroesGraveDev

JGO Kernel

Medals: 382
Projects: 11
Exp: 4 years

┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻

« Reply #5 - Posted 2014-03-04 02:52:25 »

Perhaps since this in the articles/tutorials section the title should be more formal? ("How to use JarSplice")

It might just be me.

Offline Opiop
« Reply #6 - Posted 2014-03-04 02:53:39 »

You're right, I was trying to be goofy. Obviously I need to learn when it is and isn't appropriate... changed!
Apparently you cannot change the title of a tutorial... oops! Maybe a mod can change it for me please?
Offline HeroesGraveDev

JGO Kernel

Medals: 382
Projects: 11
Exp: 4 years

┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻

« Reply #7 - Posted 2014-03-04 03:13:11 »

I'm not sure if it really is an issue.

If you can't change it easily it's probably not worth the trouble.

Offline Sabomoth

Junior Devvie

Medals: 4
Exp: 3 years

« Reply #8 - Posted 2014-03-04 12:21:57 »

If there is more functionality in JarSplice maybe you could add some text about that? Would be nice to know what i am 'missing out' on if i only use eclipse.
Offline SHC
« Reply #9 - Posted 2014-03-05 15:45:44 »

I've used this tutorial to pack the natives in the main jar of my engine. I now just had to add my engine to the build path and eclipse can automatically re-pack the libraries along with all the natives in the jar and a single jar is the result.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Mr.CodeIt

Senior Devvie

Medals: 2
Projects: 1

« Reply #10 - Posted 2014-05-09 20:03:34 »

Where do I put my textures. from my res folder.
Pages: [1]
  ignore  |  Print  

EgonOlsen (76 views)
2018-06-10 19:43:48

EgonOlsen (56 views)
2018-06-10 19:43:44

EgonOlsen (76 views)
2018-06-10 19:43:20

DesertCoockie (256 views)
2018-05-13 18:23:11

nelsongames (156 views)
2018-04-24 18:15:36

nelsongames (155 views)
2018-04-24 18:14:32

ivj94 (896 views)
2018-03-24 14:47:39

ivj94 (157 views)
2018-03-24 14:46:31

ivj94 (809 views)
2018-03-24 14:43:53

Solater (173 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!