[[tutorials/java_java2d|{{ :logo_java2d.png }}]] ====== Getting Started I (Hello World) ====== ===== Introduction ===== In this tutorial you will prepare your development environment for use with the Java bindings for GestureWorks Core. While no code will be written in this tutorial, the steps performed here will prepare your environment for subsequent GestureWorks Core Java tutorials. For this tutorial you will need the [[http://gestureworks.com/|Gestureworks Core]] multitouch framework; a [[http://files.gestureworks.com/downloads/Core/Trial/GestureworksCoreTrialSetup.exe|free trial]] is available. Download the code for all of the Java & Java 2D multitouch tutorials here: {{:tutorials:java_java2d:tutorials_java_java2d.zip|tutorials_java_java2d.zip}} ==== GestureWorks Core "Bindings" ==== The various bindings included with GestureWorks Core allow a developer to create multitouch applications using their preferred language and framework, and are essentially mini-APIs providing an interface to the functions exported by the native GestureWorksCore library (GestureworksCore32.dll, GestureworksCore64.dll). Source code for each of the bindings is included so that you may extend or modify them as you like, as well as providing a blueprint for creating bindings for other languages or frameworks. ==== NetBeans and Java2D ==== The Java bindings for GestureWorks Core can be used by any Java project. The source code for the Java bindings is provided for portability and extensibility, but can be used quite effectively as-is in most situations. In this and the following tutorials, NetBeans IDE 7 is used for demonstrating GestureWorks Core fundamentals using the Java bindings. Java2D is Java’s native drawing framework providing two-dimensional graphics, text, and imaging. ---- ===== Requirements ===== * GestureWorks Core license * Microsoft Windows 7 or 8 * NetBeans IDE * JDK for Windows * Multitouch display device ---- ==== Process Overview ==== - [[tutorials:java_java2d:getting_started_1_hello_world#download_and_install_software_prerequisites|Download and install software prerequisites]] - [[tutorials:java_java2d:getting_started_1_hello_world#download_and_install_gestureworks_core_package|Download and install GestureWorks Core package]] - [[tutorials:java_java2d:getting_started_1_hello_world#create_a_new_Java_project_in_NetBeans|Create a new Java project in NetBeans]] - [[tutorials:java_java2d:getting_started_1_hello_world#add_project_dependencies|Add project dependencies]] - [[tutorials:java_java2d:getting_started_1_hello_world#platform_management|Platform management]] ===== Process Detail ===== ====1. Download and install software prerequisites==== Each of the following software packages must be downloaded and installed prior to continuing with the tutorial. [[http://www.oracle.com/technetwork/java/javase/downloads/jdk-netbeans-jsp-142931.html|NetBeans IDE 8.1 Java SE Bundle]] ==== 2. Download and install GestureWorks Core package ==== The GestureWorks Core installer package -- GestureWorksCoreSetup.exe -- contains the main GestureWorksCore.dll files (the "native" DLLs), various bindings (C++, .NET, etc.), and supporting documentation. GestureWorksCore must be licensed prior to use in any software project. - Download the GestureWorks Core Trial package from [[http://files.gestureworks.com/downloads/Core/Trial/GestureworksCoreTrialSetup.exe|here]]. - Double-click the downloaded installer package GestureWorksCoreSetup.exe to install GestureWorks Core. GestureWorks Core consists of the GestureWorksCore DLLs as well as various tutorials and bindings: **GestureWorksCore*.dlls** \GestureWorksCore\GestureWorksCore32.dll \GestureWorksCore\GestureWorksCore64.dll **Java bindings** \GestureWorksCore\bindings\java\gwc_java **Java tutorials** \GestureWorksCore\bindings\java\Java2D\tutorials **Assets for the tutorials** \GestureWorksCore\bindings\java\resources ==== 3. Create a new Java project in NetBeans ==== First, create a new Java project - Click File → New Project - Under Categories, click Java - Under Projects click Java Application - Click the Next button {{ :tutorials:java_java2d:java_1.1.png?nolink |}} - Name the project “GestureWorksTutorial1” - (optional) Click Browse... to select a location for the project folder - Select the Create Main Class check box - Rename the package and main class by replacing the default text with "packageA.Main" - Click Finish {{:tutorials:java_java2d:java_1.2.png?nolink|java_1.2.png}} ==== 4. Add project dependencies ==== Next we need to add the following dependencies to the project. After a few edits, you’ll be able to start using the Java bindings to work with GestureWorks Core. * gwc_java project jar (Java “bindings”) * Java Native Access jar (library the bindings use to link to the GestureWorks Core) * file resources (GML file and image for proceeding tutorials) Open the gwc_java project and select the "Clean and Build" option to build the jar file in the project's "dist" directory ([[https://netbeans.org/kb/docs/java/quickstart.html#build|https://netbeans.org/kb/docs/java/quickstart.html#build]]). Right-click on the project in the Projects Explorer, then click Properties → Libraries → Add Project... {{:tutorials:java_java2d:java_1.3.png?nolink|Java 1.3.png}} Browse to the folder containing the downloaded GestureWorks Core files, navigate to the gwc_java bindings folder, click on the file and click Add Project JAR Files. {{:tutorials:java_java2d:java_1.4.png?nolink|Java 1.4.png}} Now add the jna.jar by selecting the Add JAR/Folder in the ProjectProperties window, navigate to the same gwc_java bindings folder, select jna-3.5.1 and click Open. The last dependency we need to add is the resource files. Navigate to and copy the folder located at \GestureWorks\bindings\java\resources. Click the Files tab in NetBeans to switch to the Files view, right click on the root project folder, and click Paste. The project and file tree structures should appear as follows, indicating the successful addition of the project libraries and resource folder. This will allow using the gwc_java binding’s code and local resources in the following tutorials. {{:tutorials:java_java2d:java_1.5.png?nolink|Java 1.5.png}} {{:tutorials:java_java2d:java_1.6.png?nolink|Java 1.6.png}} ==== 5. Platform management ==== If the project’s platform is not targeting a compatible JDK, the platform settings will need to be configured. A 32 bit DLL requires a 32 bit JDK and a 64 bit DLL requires a 64 bit JDK. - Target JDK * Right-click on the project in the Projects Explorer, then click Properties→ Libraries→Manage Platforms * In the Java Platform Manager window, select Add Platform... * Navigate to and select the desired JDK and click Next * Assign a unique platform name to the JDK and click Finish * Update the project’s platform by clicking the Java Platform: drop down menu and selecting the name of the recently added JDK {{:tutorials:java_java2d:java_1.7.png?nolink|Java 1.7.png}} ---- ==== Review ==== In this tutorial we installed GestureWorks Core, the prerequisites for developing with the GestureWorks Core Java bindings, and created a project that includes the Java bindings project. From here we move on to Java: Getting Started II (Hello Multitouch) in which we dig into actual source code, initializing GestureWorks Core and working with touch and gesture event data. ---- Next tutorial: [[tutorials:java_java2d:getting_started_2_hello_multitouch|Java: Getting Started II (Hello Multitouch)]]