project_creation.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]--><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="Asciidoctor 1.5.4"><meta name="keywords" content="documentation, project, deployment, sdk"><title>jMonkeyEngine SDK: Creating Projects</title><link rel="stylesheet" href="./asciidoctor.css">
  2. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
  3. <link rel="stylesheet" href="./coderay-asciidoctor.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css"></head><body class="article toc2 toc-left"><div id="header"><div id="toolbar"><a href="https://github.com/jMonkeyEngine/wiki/edit/master/src/docs/asciidoc/sdk/project_creation.adoc"><i class="fa fa-pencil-square" aria-hidden="true"></i></a><a href="https://github.com/jMonkeyEngine/wiki/new/master/src/docs/asciidoc/sdk/"><i class="fa fa-plus-square" aria-hidden="true"></i></a><input dir="auto" style="position: relative; vertical-align: top;" spellcheck="false" autocomplete="off" class="searchbox__input aa-input" id="doc-search" name="search" placeholder="Search in the doc" required="required" type="search"><i class="fa fa-navicon" aria-hidden="true"></i></div><h1>jMonkeyEngine SDK: Creating Projects</h1><div class="details"><span class="author" id="author"></span><br><span id="revnumber">version ,</span> <span id="revdate">2016/03/17 20:48</span></div><div id="toc" class="toc2"><div id="toctitle">Table of Contents</div><ul class="sectlevel1"><li><a href="#creating-a-new-jmonkeyengine-project">Creating a New jMonkeyEngine Project</a><ul class="sectlevel2"><li><a href="#project-structure">Project Structure</a></li><li><a href="#directory-structure">Directory Structure</a></li></ul></li><li><a href="#running-sample-projects">Running Sample Projects</a></li></ul></div></div><div id="content"><div id="preamble"><div class="sectionbody"><div class="paragraph"><p>The jMonkeyEngine SDK makes it easy to get started with developing 3-D games based on the jMonkeyEngine.</p></div></div></div>
  4. <div class="sect2"><h3 id="creating-a-new-jmonkeyengine-project">Creating a New jMonkeyEngine Project</h3><div class="olist arabic"><ol class="arabic"><li><p>Choose File &gt; New Project from the main menu.</p></li><li><p>In the New Project Wizard, select the template JME3 &gt; Basic Game</p></li><li><p>Click next to specify a project name, and the path where to store your new project.</p></li><li><p>Click Finish. A skeleton application is created and opens in the Project Explorer.</p><div class="ulist"><ul><li><p>This basic jme3 application is based on the SimpleApplication class to allow an easy start with jme3.</p></li><li><p>You can click the run button to run it: You will see a jMonkey cube.</p></li></ul></div></li></ol></div>
  5. <div class="sect2"><h3 id="project-structure">Project Structure</h3><div class="imageblock right"><div class="content"><img src="../sdk/jmonkeyplatform-docu-4.png" alt="jmonkeyplatform-docu-4.png" width="421" height="298"></div></div>
  6. <div class="paragraph"><p>Let&#8217;s have a look at the abstract project structure in the Project Explorer (ctrl-1).</p></div>
  7. <div class="ulist"><ul><li><p><strong>Project Assets node:</strong> These directories have been created for you to store your games assets, such as fonts, materials, models, shaders, sounds, and textures. For a newly created project, these directories are empty.</p></li><li><p><strong>Source Packages node:</strong> This is where you manage your packages and classes. For a newly created project, it contains one package and one class, <code>Main.java</code>. Double click <code>Main.java</code> to open it in the editor.</p></li><li><p><strong>Libraries node:</strong> An overview of all libraies on your game&#8217;s classpath. The classpath is already set-up for the jme3 framework (including LWJGL, Bullet, Nifty <abbr title="Graphical User Interface">GUI</abbr>, etc).</p></li></ul></div></div>
  8. <div class="sect2"><h3 id="directory-structure">Directory Structure</h3><div class="paragraph"><p>Now let&#8217;s have a look at the project&#8217;s file structure in the File Explorer (ctrl-2). This explorer shows the physical directory structure on your hard drive.</p></div>
  9. <div class="ulist"><ul><li><p><strong>assets</strong> – This directory corresponds to the Project Assets node. It is needed for the assetManager. This is the recommended internal structure:</p><div class="ulist"><ul><li><p><code>assets/Interface</code></p></li><li><p><code>assets/MatDefs</code></p></li><li><p><code>assets/Materials</code></p></li><li><p><code>assets/Models</code></p></li><li><p><code>assets/Scenes</code></p></li><li><p><code>assets/Shaders</code></p></li><li><p><code>assets/Sounds</code></p></li><li><p><code>assets/Textures</code></p></li></ul></div></li><li><p><strong>src</strong> – This directory corresponds to the Source Packages node. Your sources code goes here.</p></li><li><p><strong>nbproject</strong> – This is meta data used by the jMonkeyEngine SDK (don&#8217;t edit).</p></li><li><p><strong>build.xml</strong> – This is an Ant build script that is hooked up to the clean/build/run/test actions in the jMonkeyEngine SDK. It loads a default build script, and allows you to further customize the build process. The Ant script also assures that you are able to clean/build/run/test your application outside of the jMonkeyEngine SDK – e.g. from the command line.</p></li><li><p><strong>build</strong> – This directory contains the compiled classes. (Will be generated by the jMonkeyEngine SDK when you build the project.)</p></li><li><p><strong>dist</strong> – This directory contains the executable JAR files. (Will be generated by the jMonkeyEngine SDK when you build the project.)</p></li><li><p><strong>test</strong> – The jMonkeyEngine SDK will store JUnit tests here if you create any. (Optional.)</p></li></ul></div>
  10. <div class="paragraph"><p>Project Configuration</p></div>
  11. <div class="paragraph"><p>Right-Click the project to open the Project properties.</p></div>
  12. <div class="paragraph"><p>In the Run section, specify the main class of your project. (Pressing F6 runs this main class.)
  13. In the Run section, you can optionally configure JVM options and command line parameters <strong>(in most cases set the-Xms VMOption [NUMBER] m for the memory usage. for example (-Xms500m). see <a href="http://performance.netbeans.org/howto/jvmswitches/">http://performance.netbeans.org/howto/jvmswitches/</a>)</strong>.
  14. In the Application section, specify the game title (by default the game will be named BasicGame).
  15. In the Application section, specify the vendor name (your name), a short description, your project&#8217;s homepage, and a splash screen.</p></div>
  16. <div class="sect3"><h4 id="project-configuration">Project Configuration</h4><div class="paragraph"><p>Right-Click the project to open the Project properties.</p></div>
  17. <div class="ulist"><ul><li><p>In the Run section, specify the main class of your project. (Pressing F6 runs this main class.)</p></li><li><p>In the Run section, you can optionally configure JVM options and command line parameters.</p></li><li><p>In the Application section, specify the game title (by default the game will be named <code>BasicGame</code>).</p></li><li><p>In the Application section, specify the vendor name (your name), a short description, your project&#8217;s homepage, and a splash screen.</p></li></ul></div></div>
  18. <div class="sect3"><h4 id="clean-build-and-run-cycle">Clean, Build and Run Cycle</h4><div style="text-align: right;" class="imageblock"><div class="content"><img src="../sdk/jmonkeyplatform-docu-5.png" alt="jmonkeyplatform-docu-5.png" width="421" height="298"></div></div>
  19. <div class="admonitionblock important"><table><tr><td class="icon"><i class="fa icon-important" title="Important"></i></td><td class="content"><div class="paragraph"><p>Pressing <strong>F6 builds &amp; runs</strong> the <em>main</em> class of the <em>main project</em>. If there are several classes, or several projects, you have to specify which one you want F6 to run. Right-click a project and choose Set As Main Project, then right-click the project again and choose Properties &gt; Run and choose a Main Class.<br>
  20. To build and run the main() of <em>any file that is open in the editor</em>, press <strong>Shift-F6</strong> !</p></div></td></tr></table></div>
  21. <div class="ulist"><ul><li><p>Right-Click the project and use the context-menu to clean all generated classes and JARs.</p></li><li><p>Right-Click individual files with a main method to build and run them. (Shift-F6)</p></li><li><p>Press the Run button (green arrow in the toolbar) to build and run the project. (F6)</p></li></ul></div>
  22. <div class="paragraph"><p><strong>More than one project open?</strong> The toolbar buttons and the F-keys are bound to the main project, which is shown in bold in the Project Explorer. Right-click a project and select Set As Main Project to make it respond to the toolbar buttons and F-keys.</p></div>
  23. <div class="paragraph"><p><strong>Worried About Proprietary Lock-in?</strong> You are never locked into the jMonkeyEngine SDK: At any time, you can change into your project directory on the command line, and clean, build, and run your project, using non-proprietary Apache Ant commands:</p></div>
  24. <div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code>ant clean; ant jar; ant run;</code></pre></div></div></div>
  25. <div class="sect3"><h4 id="development-process">Development Process</h4><div class="ulist"><ul><li><p><strong>Creating new files and packages:</strong> Select the Source Packages node (or any of its subnodes), and press ctrl-N (File→New File): Use the New File wizard to create new Java classes, Java packages, Java beans, Swing forms, JUnit files, j3m Materials, j3o scenes, j3f filters, and many more.</p></li><li><p><strong>Editing files:</strong> Open the Projects Explorer and double-click a Java file from the Source Packages to open it in the Editor. The <a href="../sdk/code_editor.html">jMonkeyEngine SDK Code Editor</a> assists you in many ways, including syntactic and semantic code coloring, code completion, and javadoc.</p></li><li><p><strong>Adding Assets:</strong></p><div class="ulist"><ul><li><p>You can <a href="../sdk/model_loader_and_viewer.html">import models, scenes, and materials</a> as assets into your project.</p></li><li><p>To add sound files and images, use your operating system&#8217;s file explorer and copy the files into your project&#8217;s asset directory.</p></li></ul></div></li><li><p><strong>ToDo List:</strong> The tasks window automatically lists all lines containing errors and warnings, and all lines that you have marked with the comment keywords</p><div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="html">FIXME</code></pre></div></div>
  26. <div class="paragraph"><p>, @todo, or TODO.</p></div></li><li><p><strong>Integrated tools:</strong> <a href="../sdk/debugging_profiling_testing.html">Debugging, Testing, Profiling</a>.</p></li></ul></div></div>
  27. <div class="sect3"><h4 id="adding-external-jar-libraries">Adding external jar libraries</h4><div class="paragraph"><p>You may want to use external Java libraries in your jME project, for example content generators or artificial intelligence implementations.</p></div>
  28. <div class="paragraph"><p>Add the library to the global library list:</p></div>
  29. <div class="ulist"><ul><li><p>Select Tools→Libraries in the main menu.</p></li><li><p>Click “New Library, enter a name for the library, and press OK</p></li><li><p>In the “Classpath tab, press “Add JAR/Folder and select the jar file(s) needed for the library</p></li><li><p>(Optional) In the “JavaDoc tab, press “Add ZIP/Folder and select the javadoc for the library, as zip file or folder.</p></li><li><p>(Optional) In the “Sources tab you can select a folder or jar file containing the source files of the library.</p></li><li><p>Press OK</p></li></ul></div>
  30. <div class="paragraph"><p>Add the library to a project:</p></div>
  31. <div class="ulist"><ul><li><p>Right-Click your project and select “Properties</p></li><li><p>Select “Libaries on the left and then press “Add Library</p></li><li><p>Select the library from the list and press OK</p></li></ul></div>
  32. <div class="paragraph"><p>That&#8217;s it, your project can now use the external library. If you also linked the javadoc and sources, the SDK will assist you with javadoc popups, code completion (ctrl-space) and source navigation (ctrl-click).</p></div></div>
  33. <div class="sect3"><h4 id="application-deployment">Application Deployment</h4><div class="ulist"><ul><li><p>You can <a href="../sdk/application_deployment.html">deploy</a> your game as desktop application (JAR), browser applet, WebStart (JNLP), or on the Android platform.</p></li></ul></div></div></div></div>
  34. <div class="sect1"><h2 id="running-sample-projects">Running Sample Projects</h2><div class="sectionbody"><div class="paragraph"><p>The SDK contains <a href="../sdk/sample_code.html">Sample Code</a> (read more).</p></div>
  35. <div class="paragraph"><p>Open the Source Packages node of the JmeTests project.</p></div>
  36. <div class="ulist"><ul><li><p>Right-click the <code>JME3Tests</code> project and choose Run.<br>
  37. Choose samples from the TestChooser and try out the included demos.</p></li><li><p>Browse a demo&#8217;s source code in the SDK&#8217;s Project window to learn how a feature is implemented and used.</p></li><li><p>Feel free to modify the code samples and experiment! If you break something, you can always recreate the packaged samples from the <code>JME3 Tests</code> template.</p></li></ul></div></div></div></div><div id="footer"><div id="footer-text">Version <br>Last updated 2017-10-09 23:30:27 +00:00</div></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script><script>docsearch({
  38. apiKey: 'a736b6d93de805e26ec2f49b55013fbd',
  39. indexName: 'jmonkeyengine',
  40. inputSelector: '#doc-search',
  41. debug: false // Set debug to true if you want to inspect the dropdown
  42. });</script></body></html>