Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
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 6307 times)
0 Members and 1 Guest are viewing this topic.
Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Posted 2014-03-04 01: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:
http://ninjacave.com/jarsplice
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
- Library Handling: MAKE SURE TO SELECT "COPY REQUIRED LIBRARIES INTO A SUB FOLDER NEXT TO THE GENERATED JAR"!. No really, make sure you do.

**Edit**
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 01: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 Member


Medals: 1
Exp: 2 years



« Reply #2 - Posted 2014-03-04 01: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
« Reply #3 - Posted 2014-03-04 01: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 opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #4 - Posted 2014-03-04 01: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: 238
Projects: 11
Exp: 2 years


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


« Reply #5 - Posted 2014-03-04 03: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 opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


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

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

Offline HeroesGraveDev

JGO Kernel


Medals: 238
Projects: 11
Exp: 2 years


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


« Reply #7 - Posted 2014-03-04 04: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 Member


Medals: 1
Exp: 2 years



« Reply #8 - Posted 2014-03-04 13: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 16: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

Junior Member





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

Where do I put my textures. from my res folder.

I'm not drunk, I've just been up late coding.
Pages: [1]
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (18 views)
2014-07-24 01:59:36

Riven (17 views)
2014-07-23 21:16:32

Riven (14 views)
2014-07-23 21:07:15

Riven (17 views)
2014-07-23 20:56:16

ctomni231 (45 views)
2014-07-18 06:55:21

Zero Volt (40 views)
2014-07-17 23:47:54

danieldean (32 views)
2014-07-17 23:41:23

MustardPeter (36 views)
2014-07-16 23:30:00

Cero (51 views)
2014-07-16 00:42:17

Riven (50 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org 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‑gaming.org
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!