Skip to content

Getting Started with The 2DX Libraries

Brian Groenke edited this page Feb 16, 2014 · 7 revisions

2DX-GL and Snap2D are both Java libraries contained in a standard JAR file and can be easily linked to in your project for use.

First download a release or development build of 2DX-GL/Snap2D. Release builds are available for 2DX-GL alone or 2DX/Snap2D. Development builds all include both 2DX-GL and Snap2D.

Instructions for Eclipse Users

Right click on your project and select Build Path -> Configure Build Path.

Click the button that says "Add External Archives" and locate the 2DX JAR file on your file system. This will link your project with the 2DX libraries.

When you export your project, you have a few options for how to include 2DX at runtime:

A) Extract the 2DX and/or Snap2D JAR file into your own JAR file. This is permitted AS LONG AS YOU COMPLY with the terms of the Mozilla Public License. You may not patent or trademark the software in this form, as it includes (rather than links to) open source software from the 2DX project.

B) Put the 2DX library JAR in a directory next to your JAR file when it is executed. This is the best method to use if possible. Eclipse will do this for you AND enter the necessary 'Class-path' attribute into the manifest when you choose Export -> Runnable JAR. If you export the JAR with your own manifest, make sure to include the 2DX JAR in the class-path either in the manifest or when executed at run time.

C) Package the 2DX JAR into your JAR. This is NOT recommended. It may cause problems when 2DX tries to load native libraries or other internal resources, as loading resources from a JAR within a JAR typically doesn't work.

Other libraries: Snap2D uses third party libraries to power many of its functions. You may include these dependencies using the same options listed above. The by-default currently supported versions of these libraries are in the project's /lib folder. /lib/bundles contains pre-assembled dependency bundles of the third party libraries for convenience. You may choose to include each library individually at your discretion, or you may include the all-in-one dependency bundle alongside the 2DX JAR. You may exclude 'jogl-all.jar' and 'gluegen.jar' if you are not using the JOGL rendering engine.

Other IDE Users

Your IDE should have functionality to link or package required libraries when exporting your application. If not, you can use the built-in JDK tools to include the library or modify the manifest.