Eclipse Setup / Export Ant Build to Jar tutorial

Started by darknet, March 15, 2007, 16:24:06

Previous topic - Next topic

darknet

Eclipse Setup / Export Ant Build to Jar tutorial
Require:
-Eclipse
-lwjgl
website Lwjgl > demo > WindowCreationTest (Need to test out for java)

This will quick lesson for learn how to setup files and export it that make it work. This the simple way that I get to put. The project name will be “gameproject“. Once you create the project name that is your own or use this sample. Open the dir of the project name “gameproject” folder. Leave the project folder open so we will put the files that are need to be running from the project folder.

Extract lwjgl into the folder. Once you got the file Extract. Get the .jar files and .dlls files ( Depend on the files for the ext. to run it )in into “gameproject” folder.

Layout project folder area:

gameproject folder
-.class path
-.project
-jinput-dx8.dll
-jinput-raw.dll
-lwjgl.dll
-OpenAL32.dll
-jinput.jar
-lwjgl.jar
-lwjgl_test.jar
-lwjgl_util.jar
-lwjgl_util_applet.jar

Everything should be there. Go to  eclipse where the project area that we are going to be working. Click on the game project and press F5 to refresh it. New lists appear from the file that you put in. Right click on the project folder. Go to properties > java build path > libraries. Here getting the jars that we going to be test the java if needed or not.

Add external jars > jinput.jar
Add external jars >  lwjgl.jar
Add external jars >  lwjgl.jar
Add external jars > etc. (depend which jar files are need to run the game)

lwjgl.jar > expand it
Native Library location > edit..
Click on workspace. > ok > ok again
This where the lib. Will know where to get the .dlls
This will help you run the java code.

Next part is to set up file.
Create src folder “src”.
Create package “main”

We will create the class name “WindowCreationTest” will be using the demo from lwjgl to test if it work out. Don’t forget to edit the package name. Once done. Right click on WindowCreationTest.java > run as > java application. The window will show up. If not you might miss a step. That how you run the app. For the library files are include.

Then part is exporting.
We be using the ant build.
Right click project name > new > file > current project > name the file “build.xml”.

Double click on the build.xml file. Copy and paste.
//=====================================
<?xml version="1.0" encoding="UTF-8"?>

<project name="gameproject" default="Engine" basedir="bin"><!-- This where to be export to the local dir -->
<description>Ant targets for Engine into jar</description>

<target name="Engine" description="Make the engine">
   <!-- Export File for jar -->
   <jar jarfile="gameproject.jar" basedir=".">
       <manifest>
         <attribute name="Class-Path" value="lwjgl.jar lwjgl_test.jar lwjgl_util.jar"/>
         <!-- Main Class to Run Program -->
         <attribute name="Main-Class" value="main.WindowCreationTest"/>
       </manifest>
    </jar>
</target>
</project>
//=====================================
This will export file to the bin file. Why is it? Because it find the main file that is currently in the bin. Like the main folder that we create in the project area.
Once that done click on the window > show view > ant.

There the ant menu that should pop up on the right side. The first icon should say “add build” click on it. Current select project expand it you will see build.xml and selected it and ok it. The next part is to double click or right click on the “game project” on the ant menu.  Run as > ant build. Then the console will start to export the gameproject.jar to the bin. We are going to the copy the files for the jar to support the file.

Bin folder
-main
-game project.jar
-jinput-dx8.dll
-jinput-raw.dll
-lwjgl.dll
-OpenAL32.dll
-jinput.jar
-lwjgl.jar
-lwjgl_test.jar
-lwjgl_util.jar
-lwjgl_util_applet.jar

Double click on the gameproject.jar that should run and the support files. I hope this is helpful. I did try my best writing this out and making this work out.

Trouble shooting:
Double click on the export file and nothing happen (1) Missing file that are needed for jar or .dlls (2)check on the ant build file that are missing for jars. and others.

Main Error!
If your exporting make sure it goes to the bin so it will know it there to complie there.

If your testing the java app to run it if missing something check the console if you missing your jar and added to the libaries in the properties. Expand the jar for lwjgl to check the native library for .dlls(other native) dir.

If your exporting the file again delete the jar that you export before.