The Coder's Handbook
Jarsplice
MAKING A RUNNABLE JAR IN ECLIPSE
What's a Jar?
A jar is simply a Java ARchive file. It's basically a zip file that contains a bunch of Java program stuff. But there are special ones that can be easily run with a simple click.
Runnable Jar
To make a program you can share easily with people who have Java installed on their machine, but might not have access to your code or Eclipse, you can export to something called a Runnable Jar.
Steps
Select your project in the Package Explorer and Choose Export
Under export, choose Java --> Runnable Jar File
Make sure your correct project is chosen under Launch Configuration
Use Browse to choose an Export Destination. Give it a name and location that you'll remember.
Note: This isn't your final version, so make it something simple you should use a different name from what you want your actual final program to be called.
Warnings
It's okay if your project compiles with warnings. This just means that one or more of your files has a warning. Most commonly this is just an unused variable or import.
OPENING JARSPLICE
Click here to download a copy of Jarsplice and Portable Java Launcher
Using Slick2D means we need extra stuff
Slick 2D includes files that lets your computer interact with Open GL and the operating system, which is what helps it run fast. These files are called natives. We'll need to use a program called Jarsplice to combine our Runnable Jar with the natives to make something called a Fat Jar which contains everything we need.
Extra Step @ School
So to run a jar file, you will need to have Java installed on the machine. However, BCPS has decided to not allow us to have Java on our computers. Madness. This means we'll have to use an extra program just to open Jarsplice and our final products.
The file above contained Portable Java Launcher. You simply click on that executable then use it to find Jarsplice and load it up. You should see a program that looks like the screenshot on the right.
ADD JARS AND NATIVES
#1 Adding Jars
Click on 1) Add Jars
Click on Add Jar(s)
Find the Runnable Jar File you just created
#2 Adding Natives
Click on 1) Add Natives
Click on Add Natives(s)
Find the Natives from your project folder (under libs). Add all of them.
MAIN CLASS AND THE FAT JAR
#3 - Main Class
Click on 3) Main Class
Type in the location of your main class. This is the file which has the main method in it. Not the path, just the package and name.
#4 - Create Fat Jar
Make a folder to contain your project. This is what you'll eventually submit your running project in. It should have your project name.
For example, if your game is named Gecko you can call this "Gecko Runnable"
Click on 4) Fat Jar
Choose Create Fat Jar
SUPPORTING FILES
All the Resources
Your project almost certainly has a number of supporting files:
Images
Music
Map Files
Save Files
You'll need to copy all of those from Eclipse and put them in the folder in the same directory structure.
Most projects keep their media in a "res" folder.
You can literally copy-paste this from Eclipse to Windows.
Warning
In eclipse, your media files are not case sensitive. Once you make it a jar, they will be. If you've been careless with file capitalization and the program crashes, you'll need to check every media file and start over.
RUN IT
At Home or on a Personal PC
Click on the Jar and it'll run like an executable.
At School or on a BCPS Laptop
Open Up the Portable Java Launcher and find the file to run it.