simpleapplication_from_the_commandline.html 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1">
  6. <title>Starting a JME3 application from the command-line :: jMonkeyEngine Docs</title>
  7. <link rel="canonical" href="https://wiki.jmonkeyengine.org/docs/jme3/simpleapplication_from_the_commandline.html">
  8. <meta name="keywords" content="documentation, install">
  9. <meta name="generator" content="Antora 2.3.3">
  10. <link rel="stylesheet" href="../../_/css/site.css">
  11. <meta property="og:image" content="https://wiki.jmonkeyengine.org/_/img/iconx128.png">
  12. <meta property="og:description" content="Starting a JME3 application from the command-line">
  13. <meta property="og:title" content="jMonkeyEngine Docs">
  14. <link rel="stylesheet" href="../../_/css/site-extra.css">
  15. <link rel="stylesheet" href="../../_/css/vendor/docsearch.min.css">
  16. <!-- fetched from https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css -->
  17. <link rel="icon" href="../../_/img/favicon.ico" type="image/x-icon">
  18. </head>
  19. <body class="article">
  20. <header class="header">
  21. <nav class="navbar">
  22. <div class="navbar-brand">
  23. <a class="navbar-item" href="https://wiki.jmonkeyengine.org">
  24. <img alt="" src="../../_/img/jme-logo.png" height="32" type="image/x-icon">
  25. </a>
  26. <div class="navbar-item hide-for-print">
  27. <input id="search-input" type="text" placeholder="Search docs">
  28. </div>
  29. <button class="navbar-burger" data-target="topbar-nav">
  30. <span></span>
  31. <span></span>
  32. <span></span>
  33. </button>
  34. </div>
  35. <div id="topbar-nav" class="navbar-menu">
  36. <div class="navbar-end">
  37. <div class="navbar-item theme-switch-wrapper">
  38. <label class="theme-switch" for="checkbox">
  39. <input type="checkbox" id="checkbox" />
  40. <div class="slider round"></div>
  41. </label>
  42. </div>
  43. <a class="navbar-item" href="https://github.com/jmonkeyengine/wiki">Github</a>
  44. </div>
  45. </div>
  46. </nav>
  47. </header>
  48. <div class="body">
  49. <div class="nav-container" data-component="docs" data-version="master">
  50. <aside class="nav">
  51. <div class="panels">
  52. <div class="nav-panel-menu is-active" data-panel="menu">
  53. <nav class="nav-menu">
  54. <h3 class="title"><a href="../documentation.html">Docs</a></h3>
  55. <ul class="nav-list">
  56. <li class="nav-item" data-depth="0">
  57. <ul class="nav-list">
  58. <li class="nav-item" data-depth="1">
  59. <a class="nav-link" href="../documentation.html">Getting Started</a>
  60. </li>
  61. <li class="nav-item" data-depth="1">
  62. <a class="nav-link" href="https://javadoc.jmonkeyengine.org/v3.3.2-stable">JavaDoc</a>
  63. </li>
  64. <li class="nav-item" data-depth="1">
  65. <button class="nav-item-toggle"></button>
  66. <a class="nav-link" href="../jme3.html">jMonkeyEngine 3</a>
  67. <ul class="nav-list">
  68. <li class="nav-item" data-depth="2">
  69. <button class="nav-item-toggle"></button>
  70. <span class="nav-text">Beginner Tutorials</span>
  71. <ul class="nav-list">
  72. <li class="nav-item" data-depth="3">
  73. <a class="nav-link" href="beginner/hello_simpleapplication.html">Hello SimpleApplication</a>
  74. </li>
  75. <li class="nav-item" data-depth="3">
  76. <a class="nav-link" href="beginner/hello_node.html">Hello Node</a>
  77. </li>
  78. <li class="nav-item" data-depth="3">
  79. <a class="nav-link" href="beginner/hello_asset.html">Hello Asset</a>
  80. </li>
  81. <li class="nav-item" data-depth="3">
  82. <a class="nav-link" href="beginner/hello_main_event_loop.html">Hello Main Event Loop</a>
  83. </li>
  84. <li class="nav-item" data-depth="3">
  85. <a class="nav-link" href="beginner/hello_input_system.html">Hello Input System</a>
  86. </li>
  87. <li class="nav-item" data-depth="3">
  88. <a class="nav-link" href="beginner/hello_material.html">Hello Material</a>
  89. </li>
  90. <li class="nav-item" data-depth="3">
  91. <a class="nav-link" href="beginner/hello_animation.html">Hello Animation</a>
  92. </li>
  93. <li class="nav-item" data-depth="3">
  94. <a class="nav-link" href="beginner/hello_picking.html">Hello Picking</a>
  95. </li>
  96. <li class="nav-item" data-depth="3">
  97. <a class="nav-link" href="beginner/hello_collision.html">Hello Collision</a>
  98. </li>
  99. <li class="nav-item" data-depth="3">
  100. <a class="nav-link" href="beginner/hello_terrain.html">Hello Terrain</a>
  101. </li>
  102. <li class="nav-item" data-depth="3">
  103. <a class="nav-link" href="beginner/hello_audio.html">Hello Audio</a>
  104. </li>
  105. <li class="nav-item" data-depth="3">
  106. <a class="nav-link" href="beginner/hello_effects.html">Hello Effects</a>
  107. </li>
  108. <li class="nav-item" data-depth="3">
  109. <a class="nav-link" href="beginner/hello_physics.html">Hello Physics</a>
  110. </li>
  111. </ul>
  112. </li>
  113. <li class="nav-item" data-depth="2">
  114. <button class="nav-item-toggle"></button>
  115. <span class="nav-text">Intermediate Tutorials</span>
  116. <ul class="nav-list">
  117. <li class="nav-item" data-depth="3">
  118. <button class="nav-item-toggle"></button>
  119. <span class="nav-text">Concepts</span>
  120. <ul class="nav-list">
  121. <li class="nav-item" data-depth="4">
  122. <a class="nav-link" href="intermediate/best_practices.html">Best Practices</a>
  123. </li>
  124. <li class="nav-item" data-depth="4">
  125. <a class="nav-link" href="intermediate/simpleapplication.html">Simple Application</a>
  126. </li>
  127. <li class="nav-item" data-depth="4">
  128. <a class="nav-link" href="features.html">Features</a>
  129. </li>
  130. <li class="nav-item" data-depth="4">
  131. <a class="nav-link" href="intermediate/optimization.html">Optimization</a>
  132. </li>
  133. <li class="nav-item" data-depth="4">
  134. <a class="nav-link" href="faq.html">FAQ</a>
  135. </li>
  136. </ul>
  137. </li>
  138. <li class="nav-item" data-depth="3">
  139. <button class="nav-item-toggle"></button>
  140. <span class="nav-text">Math Concepts</span>
  141. <ul class="nav-list">
  142. <li class="nav-item" data-depth="4">
  143. <a class="nav-link" href="math_for_dummies.html">Math For Dummies</a>
  144. </li>
  145. <li class="nav-item" data-depth="4">
  146. <a class="nav-link" href="intermediate/math.html">Math</a>
  147. </li>
  148. <li class="nav-item" data-depth="4">
  149. <a class="nav-link" href="math.html">More Math</a>
  150. </li>
  151. <li class="nav-item" data-depth="4">
  152. <a class="nav-link" href="rotate.html">Rotate</a>
  153. </li>
  154. <li class="nav-item" data-depth="4">
  155. <a class="nav-link" href="math_video_tutorials.html">Math Video Tutorials</a>
  156. </li>
  157. </ul>
  158. </li>
  159. <li class="nav-item" data-depth="3">
  160. <button class="nav-item-toggle"></button>
  161. <span class="nav-text">3D Graphics Concepts</span>
  162. <ul class="nav-list">
  163. <li class="nav-item" data-depth="4">
  164. <a class="nav-link" href="intermediate/multi-media_asset_pipeline.html">Multi-Media Asset Pipeline</a>
  165. </li>
  166. <li class="nav-item" data-depth="4">
  167. <a class="nav-link" href="scenegraph_for_dummies.html">Scenegraph for Dummies</a>
  168. </li>
  169. <li class="nav-item" data-depth="4">
  170. <a class="nav-link" href="beginner/hellovector.html">Hello Vector</a>
  171. </li>
  172. <li class="nav-item" data-depth="4">
  173. <a class="nav-link" href="terminology.html">Terminology</a>
  174. </li>
  175. <li class="nav-item" data-depth="4">
  176. <a class="nav-link" href="intermediate/how_to_use_materials.html">How to Use Materials</a>
  177. </li>
  178. <li class="nav-item" data-depth="4">
  179. <a class="nav-link" href="intermediate/transparency_sorting.html">Transparency and Sorting</a>
  180. </li>
  181. <li class="nav-item" data-depth="4">
  182. <a class="nav-link" href="external/blender.html">Importing from Blender</a>
  183. </li>
  184. <li class="nav-item" data-depth="4">
  185. <a class="nav-link" href="external/3dsmax.html">Importing from 3DS Max</a>
  186. </li>
  187. </ul>
  188. </li>
  189. </ul>
  190. </li>
  191. </ul>
  192. </li>
  193. <li class="nav-item" data-depth="1">
  194. <a class="nav-link" href="../logo.html">Logo Usage</a>
  195. </li>
  196. <li class="nav-item" data-depth="1">
  197. <a class="nav-link" href="../bsd_license.html">License</a>
  198. </li>
  199. <li class="nav-item" data-depth="1">
  200. <a class="nav-link" href="../github_tips.html">Github Tips</a>
  201. </li>
  202. </ul>
  203. </li>
  204. <li class="nav-item" data-depth="0">
  205. <button class="nav-item-toggle"></button>
  206. <span class="nav-text">SDK</span>
  207. <ul class="nav-list">
  208. <li class="nav-item" data-depth="1">
  209. <a class="nav-link" href="../sdk.html">jMonkeyEngine SDK</a>
  210. </li>
  211. </ul>
  212. </li>
  213. </ul>
  214. </nav>
  215. </div>
  216. <div class="nav-panel-explore" data-panel="explore">
  217. <div class="context">
  218. <span class="title">Docs</span>
  219. <span class="version">master</span>
  220. </div>
  221. <ul class="components">
  222. <li class="component is-current">
  223. <span class="title">Docs</span>
  224. <ul class="versions">
  225. <li class="version is-current is-latest">
  226. <a href="../documentation.html">master</a>
  227. </li>
  228. </ul>
  229. </li>
  230. <li class="component">
  231. <span class="title">Wiki UI</span>
  232. <ul class="versions">
  233. <li class="version is-latest">
  234. <a href="../../wiki-ui/index.html">master</a>
  235. </li>
  236. </ul>
  237. </li>
  238. </ul>
  239. </div>
  240. </div>
  241. </aside>
  242. </div>
  243. <main class="article">
  244. <div class="toolbar" role="navigation">
  245. <button class="nav-toggle"></button>
  246. <nav class="breadcrumbs" aria-label="breadcrumbs">
  247. <ul>
  248. <li><a href="../documentation.html">Docs</a></li>
  249. <li><a href="simpleapplication_from_the_commandline.html">Starting a JME3 application from the command-line</a></li>
  250. </ul>
  251. </nav>
  252. <div class="edit-this-page"><a href="https://github.com/jMonkeyEngine/wiki/edit/master/docs/modules/ROOT/pages/jme3/simpleapplication_from_the_commandline.adoc">Edit this Page</a></div>
  253. </div>
  254. <div class="content">
  255. <article class="doc">
  256. <h1 class="page">Starting a JME3 application from the command-line</h1>
  257. <div id="preamble">
  258. <div class="sectionbody">
  259. <div class="paragraph">
  260. <p>Although we recommend the jMonkeyEngine <a href="../sdk.html" class="page">SDK</a> for developing JME3 games, you can use any IDE (integrated development environment) such as <a href="setting_up_netbeans_and_jme3.html" class="page">NetBeans</a> or <a href="setting_up_jme3_in_eclipse.html" class="page">Eclipse</a>, and even work freely from the command-line. Here is a generic IDE-independent &#8220;getting started&#8221; tutorial.</p>
  261. </div>
  262. </div>
  263. </div>
  264. <div class="sect1">
  265. <h2 id="installing-the-jme3-framework"><a class="anchor" href="#installing-the-jme3-framework"></a>Installing the JME3 Framework</h2>
  266. <div class="sectionbody">
  267. <div class="paragraph">
  268. <p>There are many ways to install the JME framework from the command-line, but for this tutorial we will narrow it down to two, the easy way and the hard way.</p>
  269. </div>
  270. </div>
  271. </div>
  272. <div class="sect1">
  273. <h2 id="installing-with-git-easy-way"><a class="anchor" href="#installing-with-git-easy-way"></a>Installing with Git (easy way)</h2>
  274. <div class="sectionbody">
  275. <div class="paragraph">
  276. <p>You can build JME3 from the sources. (Recommended for JME3 developers.) This example expects <a href="https://help.github.com/articles/set-up-git/">Git</a> to be installed on your system.</p>
  277. </div>
  278. <div class="listingblock">
  279. <div class="content">
  280. <pre class="highlightjs highlight"><code>mkdir jme3
  281. cd jme3
  282. // if you have a rsa key configured
  283. git clone [email protected]:jMonkeyEngine/jmonkeyengine.git
  284. // or
  285. // if you don't, but you'll be asked for credential after the next command
  286. git clone https://github.com/jMonkeyEngine/jmonkeyengine.git
  287. //can take a while
  288. // build the engine and install it in your local maven repo.
  289. ./gradlew install</code></pre>
  290. </div>
  291. </div>
  292. <div class="admonitionblock tip">
  293. <table>
  294. <tr>
  295. <td class="icon">
  296. <i class="fa icon-tip" title="Tip"></i>
  297. </td>
  298. <td class="content">
  299. What is an <a href="https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/">RSA key</a>?
  300. </td>
  301. </tr>
  302. </table>
  303. </div>
  304. <div class="paragraph">
  305. <p>The install command will install the built jars into your local maven repositories org.jmonkeyengine folder, which on Linux is ~/.m2, and on Windows might be in AppData, or in your home directory.</p>
  306. </div>
  307. <div class="paragraph">
  308. <p>To use the engine in a game project, you can use <a href="https://hub.jmonkeyengine.org/t/bootmonkey-bootstrap-your-jme-project/37141">BootMonkey</a> or clone a template project from GitHub.</p>
  309. </div>
  310. <div class="paragraph">
  311. <p>To use the template, first create a folder for your project:</p>
  312. </div>
  313. <div class="listingblock">
  314. <div class="content">
  315. <pre class="highlightjs highlight"><code>cd ..
  316. mkdir HelloJME3
  317. cd HelloJME3</code></pre>
  318. </div>
  319. </div>
  320. <div class="paragraph">
  321. <p>Next, clone one of these templates:</p>
  322. </div>
  323. <div class="ulist">
  324. <ul>
  325. <li>
  326. <p><a href="https://github.com/Simsilica/Examples/tree/master/simple-jme">Simsilica/Examples</a></p>
  327. </li>
  328. <li>
  329. <p><a href="https://github.com/Nehon/base-jme">Nehon/base-jme</a></p>
  330. </li>
  331. </ul>
  332. </div>
  333. <div class="paragraph">
  334. <p>After cloning, open the <code>build.gradle</code> file and uncomment the <code>mavenLocal()</code> repository, change the version variable, and uncomment any dependencies you will need:</p>
  335. </div>
  336. <div class="listingblock">
  337. <div class="content">
  338. <pre class="highlightjs highlight"><code>repositories {
  339. //This is where jme3 dependencies are stored.
  340. jcenter()
  341. //Uncomment this if you install local dependencies.
  342. mavenLocal()
  343. //Uncomment this if you use external dependencies
  344. //mavenCentral()
  345. //Uncomment this if you use jme3-niftygui
  346. //maven{url 'http://nifty-gui.sourceforge.net/nifty-maven-repo'}
  347. }
  348. ext.jmeVersion = "[3.2,)"
  349. ...
  350. dependencies {
  351. compile "org.jmonkeyengine:jme3-core:$jmeVersion"
  352. compile "org.jmonkeyengine:jme3-desktop:$jmeVersion"
  353. compile "org.jmonkeyengine:jme3-lwjgl:$jmeVersion"
  354. //Those are jme3 additional library uncomment the ones you need
  355. //compile "org.jmonkeyengine:jme3-android-native:$jmeVersion"
  356. //compile "org.jmonkeyengine:jme3-android:$jmeVersion"
  357. //compile "org.jmonkeyengine:jme3-bullet-native-android:$jmeVersion"
  358. //compile "org.jmonkeyengine:jme3-blender:$jmeVersion"
  359. //compile "org.jmonkeyengine:jme3-bullet-native:$jmeVersion"
  360. //compile "org.jmonkeyengine:jme3-bullet:$jmeVersion"
  361. //compile "org.jmonkeyengine:jme3-effects:$jmeVersion"
  362. //compile "org.jmonkeyengine:jme3-jogg:$jmeVersion"
  363. //compile "org.jmonkeyengine:jme3-jogl:$jmeVersion"
  364. //compile "org.jmonkeyengine:jme3-lwjgl3:$jmeVersion"
  365. //compile "org.jmonkeyengine:jme3-networking:$jmeVersion"
  366. //compile "org.jmonkeyengine:jme3-plugins:$jmeVersion"
  367. //compile "org.jmonkeyengine:jme3-terrain:$jmeVersion"
  368. //You need to uncomment nifty repository in the repositories section if you use this dependency
  369. //compile "org.jmonkeyengine:jme3-niftygui:$jmeVersion"
  370. runtime project(':assets')
  371. }
  372. ...</code></pre>
  373. </div>
  374. </div>
  375. <div class="paragraph">
  376. <p>For a detailed description of the separate jar files see <a href="jme3_source_structure.html#structure_of_jmonkeyengine3_jars" class="page">this list</a>.</p>
  377. </div>
  378. <div class="paragraph">
  379. <p>That&#8217;s it, you&#8217;re done. After the clone, you will have a project that contains a source package with a default blue cube JME3 app and a subproject that has the proper asset directory structure for your assets.</p>
  380. </div>
  381. <div class="paragraph">
  382. <p>Build and run your project and you should see a blue cube.</p>
  383. </div>
  384. </div>
  385. </div>
  386. <div class="sect1">
  387. <h2 id="manual-download-hard-way"><a class="anchor" href="#manual-download-hard-way"></a>Manual Download (hard way)</h2>
  388. <div class="sectionbody">
  389. <div class="paragraph">
  390. <p>This example shows how to set up and run a simple application (HelloJME3) that depends on the jMonkeyEngine3 libraries.</p>
  391. </div>
  392. <div class="paragraph">
  393. <p>The directory structure will look as follows:</p>
  394. </div>
  395. <div class="listingblock">
  396. <div class="content">
  397. <pre class="highlightjs highlight"><code>jme3/
  398. jme3/lib
  399. jme3/src
  400. ...
  401. HelloJME3/
  402. HelloJME3/lib
  403. HelloJME3/assets
  404. HelloJME3/src
  405. ...</code></pre>
  406. </div>
  407. </div>
  408. <div class="paragraph">
  409. <p>To install the development version of jme3, download the latest <a href="https://github.com/jMonkeyEngine/jmonkeyengine/releases">stable release</a>, unzip the folder into a directory named <code>jme3</code>. The filenames here are just an example, but they will always be something like <code>jME3.x-stable</code>.</p>
  410. </div>
  411. <div class="listingblock">
  412. <div class="content">
  413. <pre class="highlightjs highlight"><code>mkdir jme3
  414. cd jme3
  415. unzip jME3.2-stable.zip
  416. cd ..</code></pre>
  417. </div>
  418. </div>
  419. </div>
  420. </div>
  421. <div class="sect1">
  422. <h2 id="sample-project-directory-structure"><a class="anchor" href="#sample-project-directory-structure"></a>Sample Project Directory Structure</h2>
  423. <div class="sectionbody">
  424. <div class="paragraph">
  425. <p>First we set up the directory and source package structure for your game project. Note that the game project directory <code>HelloJME3</code> is on the same level as your <code>jme3</code> folder. In this example, we create a Java package that we call <code>mygame</code> in the source directory.</p>
  426. </div>
  427. <div class="listingblock">
  428. <div class="content">
  429. <pre class="highlightjs highlight"><code>mkdir HelloJME3
  430. mkdir HelloJME3/src
  431. mkdir HelloJME3/src/mygame</code></pre>
  432. </div>
  433. </div>
  434. </div>
  435. </div>
  436. <div class="sect1">
  437. <h2 id="libraries"><a class="anchor" href="#libraries"></a>Libraries</h2>
  438. <div class="sectionbody">
  439. <div class="paragraph">
  440. <p>Next you copy the necessary JAR libraries from the download to your project. You only have to do this set of steps once every time you download a new JME3 build. For a detailed description of the separate jar files see <a href="jme3_source_structure.html#structure_of_jmonkeyengine3_jars" class="page">this list</a>.</p>
  441. </div>
  442. <div class="listingblock">
  443. <div class="content">
  444. <pre class="highlightjs highlight"><code>mkdir HelloJME3/build
  445. mkdir HelloJME3/lib
  446. cp jme3/lib/*.* HelloJME3/lib</code></pre>
  447. </div>
  448. </div>
  449. <div class="sect2">
  450. <h3 id="sample-code"><a class="anchor" href="#sample-code"></a>Sample Code</h3>
  451. <div class="paragraph">
  452. <p>To test your setup, create the file <code>HelloJME3/src/mygame/HelloJME3.java</code> with any text editor, paste the following sample code, and save.</p>
  453. </div>
  454. <div class="listingblock">
  455. <div class="content">
  456. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">package mygame;
  457. import com.jme3.app.SimpleApplication;
  458. import com.jme3.material.Material;
  459. import com.jme3.math.Vector3f;
  460. import com.jme3.scene.Geometry;
  461. import com.jme3.scene.shape.Box;
  462. import com.jme3.math.ColorRGBA;
  463. public class HelloJME3 extends SimpleApplication {
  464. public static void main(String[] args){
  465. HelloJME3 app = new HelloJME3();
  466. app.start();
  467. }
  468. @Override
  469. public void simpleInitApp() {
  470. Box b = new Box(Vector3f.ZERO, 1, 1, 1);
  471. Geometry geom = new Geometry("Box", b);
  472. Material mat = new Material(assetManager,
  473. "Common/MatDefs/Misc/Unshaded.j3md");
  474. mat.setColor("Color", ColorRGBA.Blue);
  475. geom.setMaterial(mat);
  476. rootNode.attachChild(geom);
  477. }
  478. }</code></pre>
  479. </div>
  480. </div>
  481. </div>
  482. </div>
  483. </div>
  484. <div class="sect1">
  485. <h2 id="build-and-run"><a class="anchor" href="#build-and-run"></a>Build and Run</h2>
  486. <div class="sectionbody">
  487. <div class="paragraph">
  488. <p>We build the sample application into the build directory…</p>
  489. </div>
  490. <div class="listingblock">
  491. <div class="content">
  492. <pre class="highlightjs highlight"><code>cd HelloJME3
  493. javac -d build -cp "lib/eventbus.jar:lib/j-ogg-all.jar:lib/jme3-lwjgl.jar:lib/jme3-bullet.jar:lib/jinput.jar:lib/lwjgl.jar:lib/stack-alloc.jar:lib/vecmath.jar:lib/xpp3.jar:lib/jme3-blender.jar:lib/jme3-core.jar:lib/jme3-desktop.jar:lib/jme3-jogg.jar:lib/jme3-plugins.jar:lib/jme3-terrain.jar:lib/jme3-testdata.jar:lib/jme3-niftygui.jar:lib/nifty-default-controls.jar:lib/nifty-examples.jar:lib/nifty-style-black.jar:lib/nifty.jar:." src/mygame/HelloJME3.java</code></pre>
  494. </div>
  495. </div>
  496. <div class="paragraph">
  497. <p>… and run it.</p>
  498. </div>
  499. <div class="listingblock">
  500. <div class="content">
  501. <pre class="highlightjs highlight"><code>cd build
  502. java -cp "../lib/eventbus.jar:../lib/j-ogg-all.jar:../lib/jme3-lwjgl.jar:../lib/jme3-bullet.jar:../lib/jinput.jar:../lib/lwjgl.jar:../lib/stack-alloc.jar:../lib/vecmath.jar:../lib/xpp3.jar:../lib/jme3-blender.jar:../lib/jme3-core.jar:../lib/jme3-desktop.jar:../lib/jme3-jogg.jar:../lib/jme3-plugins.jar:../lib/jme3-terrain.jar:../lib/jme3-testdata.jar:../lib/jme3-niftygui.jar:../lib/nifty-default-controls.jar:../lib/nifty-examples.jar:../lib/nifty-style-black.jar:../lib/nifty.jar:." mygame/HelloJME3</code></pre>
  503. </div>
  504. </div>
  505. <div class="admonitionblock note">
  506. <table>
  507. <tr>
  508. <td class="icon">
  509. <i class="fa icon-note" title="Note"></i>
  510. </td>
  511. <td class="content">
  512. If you use Windows, the classpath separator is <kbd>\</kbd> instead of <kbd>/</kbd>.
  513. </td>
  514. </tr>
  515. </table>
  516. </div>
  517. <div class="paragraph">
  518. <p>If a settings dialog pops up, confirm the default settings. You should now see a simple window with a 3-D cube. Use the mouse and the WASD keys to move. It works!</p>
  519. </div>
  520. </div>
  521. </div>
  522. <div class="sect1">
  523. <h2 id="recommended-asset-directory-structure"><a class="anchor" href="#recommended-asset-directory-structure"></a>Recommended Asset Directory Structure</h2>
  524. <div class="sectionbody">
  525. <div class="paragraph">
  526. <p>For <a href="intermediate/multi-media_asset_pipeline.html" class="page">multi-media files, models, and other assets</a>, we recommend creating the following project structure:</p>
  527. </div>
  528. <div class="listingblock">
  529. <div class="content">
  530. <pre class="highlightjs highlight"><code>cd HelloJME3
  531. mkdir assets
  532. mkdir assets/Interface
  533. mkdir assets/Materials
  534. mkdir assets/MatDefs
  535. mkdir assets/Models
  536. mkdir assets/Scenes
  537. mkdir assets/Shaders
  538. mkdir assets/Sounds
  539. mkdir assets/Textures</code></pre>
  540. </div>
  541. </div>
  542. <div class="paragraph">
  543. <p>This directory structure will allow <a href="intermediate/simpleapplication.html" class="page">SimpleApplication</a>'s default <a href="advanced/asset_manager.html" class="page">AssetManager</a> to load media files from your <code>assets</code> directory, like in this example:</p>
  544. </div>
  545. <div class="listingblock">
  546. <div class="content">
  547. <pre class="highlightjs highlight"><code>import com.jme3.scene.Spatial;
  548. ...
  549. Spatial elephant = assetManager.loadModel("Models/Elephant/Elephant.meshxml");
  550. rootNode.attachChild(elephant);
  551. ...</code></pre>
  552. </div>
  553. </div>
  554. <div class="paragraph">
  555. <p>You will learn more about the asset manager and how to customize it later. For now feel free to structure your assets (images, textures, models) into further sub-directories, like in this example the <code>assets/models/Elephant</code> directory that contains the <code>elephant.mesh.xml</code> model and its materials.</p>
  556. </div>
  557. </div>
  558. </div>
  559. <div class="sect1">
  560. <h2 id="next-steps"><a class="anchor" href="#next-steps"></a>Next Steps</h2>
  561. <div class="sectionbody">
  562. <div class="paragraph">
  563. <p>Now follow the <a href="../jme3.html" class="page">tutorials</a> and write your first jMonkeyEngine game.</p>
  564. </div>
  565. </div>
  566. </div>
  567. </article>
  568. <aside class="toc sidebar" data-title="Contents" data-levels="2">
  569. <div class="toc-menu"></div>
  570. </aside>
  571. </div>
  572. </main>
  573. </div>
  574. <footer class="footer">
  575. <p>Copyright 2020 jMonkeyEngine Wiki Contributors. Licensed BSD-3.</p>
  576. </footer>
  577. <script src="../../_/js/vendor/docsearch.min.js"></script>
  578. <!-- fetched from https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js -->
  579. <script>
  580. var search = docsearch({
  581. apiKey: 'a736b6d93de805e26ec2f49b55013fbd',
  582. indexName: 'jmonkeyengine',
  583. inputSelector: '#search-input',
  584. autocompleteOptions: { hint: false, keyboardShortcuts: ['s'] },
  585. algoliaOptions: { hitsPerPage: 10 }
  586. }).autocomplete
  587. search.on('autocomplete:closed', function () { search.autocomplete.setVal() })
  588. function focusSearchInput () { document.querySelector('#search-input').focus() }
  589. if (document.querySelector('.home-link.is-current')) window.addEventListener('load', focusSearchInput)
  590. </script>
  591. <script src="../../_/js/site.js"></script>
  592. <script async src="../../_/js/vendor/highlight.js"></script>
  593. </body>
  594. </html>