Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon

7. November 2011

In one of those all time "my timing sucks" moments, Google's Fred Sauer just announced PlayN 1.0 was just added to the Maven repository, which makes the install process a few orders of magnitude easier to get up and running.


When I get off a tablet and back to a computer, I will document the process... it will be a short document, the process is now a heck of a lot easier.  It's a mix of ahh crap, since I just finished my installer and great news as frankly the process needed to get easier.


6. November 2011



Hmm, kinda realized I missed this part in my recent PlayN installer post.  After you go ahead and create your game, it creates a new project hierarchy and… then what?  This post shows the various ways you can start your game.


Assuming you used my installer to install PlayN, you can run your game from the command line using the following steps.  I will assume your game’s name was “mygame” in these examples and that you installed to c:\playn.




Running the desktop Java app with Maven



cd playn\playn\mygame\core

..\..\..\maven\apache-maven3.0.3\bin\mvn install compile exec:java



Running the HTML target with Maven


cd playn\playn\mygame

..\..\maven\apache-maven3.0.3\bin\mvn package  ( wait, this takes a bit )

..\..\maven\apache-maven3.0.3\bin\mvn –Ptest-html


This will currently through a bunch of errors in your face since the Flash build seems to currently be broken, ignore them.  Once you run that second command, a web server Jetty will be downloaded and installed.


Now open a browser and go to http://localhost:8080 to see your game running in a browser.


When done, you can use CTRL+C in the dos window to get Jetty to stop.


Running the Flash target with Maven


You can’t, it’s currently broken, I’m looking into it and will update with details or a fix if possible.


Running the Android target with Maven


This process is a bit too involved and requires other steps ( like configuring the emulator or a physical device, which we didn’t do during the initial install.  I will cover this in detail in a later post.


There is a problem in that the fact Flash is broken, and before Android in the build order, your Android target will never be built!  This can easily be fixed by opening pom.xml in your game folder and remove the line <module>flash</module>.


Running the Java and HTML targets with Ant


If you have Apache ant installed, you can also use it to run Java and HTML targets. Currently you cannot run Flash or Android this way.


Running desktop:

cd playn\playn\mygame



Running HTML:

cd playn\playn\mygame

ant run-html


Just like with Maven ( but a whole lot quicker ) it runs Jetty and you can reach your website using a browser.  However, unlike the maven install, for some reason the ant install is in a subdirectory, so your URL is http://localhost:8080/mygame.



Of course, if you are using an IDE like Eclipse or NetBeans, they can automate many of these tasks.  If you add Maven’s bin folder to your PATH variable, it will save you a ton of typing.  Of course you could also make a simply script to run your game in a much more terse syntax.


6. November 2011


 EDIT: 11/7/2011 Google has published to Maven Central, which makes this entire process obsolete.  Refer to here for new instructions.  Fortunately the new process is much nicer and faster.

PlayN is a wonder piece of technology with a horrible installation process, which is a shame as I think more people should check it out.  So I decided to do something about it, I wrote an installer!


I have made the process (almost ) as simple as possible.  For much more detailed process or if you encounter a problem more detailed instructions are available here.



First download the tools available here.


Extract the zip file to any folder ( make sure you extract though, do not run from the zip ) and run Install.cmd.


Now it is simply a matter of answering a couple Yes/No questions, and (optionally) point the installer at your JDK folder and telling it where you want PlayN to be installed.  Except the gotcha… read about that below before running the install!



The Gotcha


The only major gotcha is you *must* install the Android 3.0 SDK Platform, and you have to do it in a bit of a hurry, as the SDK install will happen in parallel to the PlayN install which is eventually going to need the Android SDK installed to continue.  I chose to do this because both installs are fairly long and the Android install *should* be completed long before it is needed.  When this screen appears, move quickly! To keep the install quick, click “deselect all” then choose Android 3.0 (API11)->SDK Platform.  You can run the Android SDK Manager again later if you want to add more features.  If for some reason the installer outpaced the Android SDK Manager, simply run the installer again.








If you already have the Android SDK installed, this process *may* hijack your ANDROID_HOME environment variable.  When complete, simply change it back if you wish.



Technical Details

The installer and wizard consist of about 500 lines of Powershell script.  For the record, I have never used Powershell before, so it’s 500 lines of ugly Powershell script! Smile


The entire script is documented, so before running you can see exactly what it is going to do, and if it has a problem or you want to install different versions of Maven, Git or the JDK, you can change those URLs right at the top.


Over the course of execution, the script:

- downloads and configured the JDK [optional]

- downloads 7zip for later use ( from )

- downloads and installs ( local ) Git

- downloads and runs the Android SDK

- Git’s PlayN from googlecode

- Downloads and installs Maven

- Runs Maven on the PlayN code

- Downloads and installed the New Game Wizard from

- Runs the New Game Wizard [optional]




System requirements:


Java runtime.  The java sdk will be installed as part of this process, but the java runtime will not.

Powershell 2.0.  Tested on Windows 7 with Powershell 2.0, should work on Windows Server 2008 but untested. *May* work on Vista, untested.  *Should* work on Windows XP, but you will need to download and install Powershell 2.0 first.  Powershell 2.0 ships with Windows 7, and Powershell 1.0 ships with Vista and may require updating using the link above.


What files are created?


Everything is created under the PlayN installation folder you selected, except a few temp files such as the JDK installer.  These are located in your %TEMP% folder and can be deleted whenever you wanted.


How do I uninstall?


Simply delete the downloaded scripts.  If you want to erase your PlayN install, first stop adb  ( the Android debugger ).  To do so, load the task manager ( CTRL + SHIFT + ESC ), find adb.exe, right click and end process.  Now simply delete the PlayN folder you created as part of the install.


Anything else I need to know?


Yeah, the install won’t have touched your Maven or Git configurations if those are already installed, but unfortunately as part of the process we had to update the ANDROID_HOME environment variable.  So if you already have the Android SDK installed on your machine, you will need to update ANDROID_HOME to point to your installed SDK.  This can be accomplished from a command prompt by typing:

    Setx ANDROID_HOME “c:\your\androidsdk\location”



The new game wizard is installed as part of this process and can be located at [PlayN Folder]\PlayN\NewGame.cmd if you want to create a new game in the future.



If you want to install more Android SDK features after the install is complete, the Android SDK is located at PlayN\Android\SDK Manager.exe.  Yes, there is a space in the name, and no, I don’t know what the hell Google was thinking when they did that…



Running Maven after the fact is a bit of a pain in the ass.  I did not set the environment variable as part of the installed ( in case you already had Maven installed I didn’t want to break anything ) so now you have to fully resolve Maven to run it, such as c:\Playn\maven\apache-maven-3.0.3\bin\mvn.bat  [your command]  if you think that gets old in a hurry, you are correct!  The easiest answer is to add the maven Bin directory to your path, such as:

Setx PATH = “%PATH%;c:\playn\maven\apache-maven-3.0.3\bin”

Be careful with the above syntax as you don’t want to screw up your PATH variable.  Try it with a straight SET first ( no X ), then type “SET PATH” to verify it looks correct.  If you are sure it does, run it again using SETX.  At this point you can run Mvn from any directory.








That’s not really shocking, there are a ton of moving pieces!  Also, I made NO checks to make sure files existed across the network or that your internet connection was up, as both of these would simply be catastrophic failures anyways.  My first suggestion is checking all the URLs at the top of the install script with your browser to make sure they are all still valid and connectivity to each site is fine.  I also have no control over if Google break their build, but if they do, let me know and I can patch the script accordingly.


If you have other problems, post them here, email me ( not preferred because others won’t be able to read the results ) or use the PlayN tag on and I will monitor there as well.


Happy PlayN!


6. November 2011



The Gamefromscratch PlayN installer is fairly straight forward in execution but has a few tricky points.  Also, I can’t be sure it will work 100% and you can refer to this process to see if your installation worked properly.



On occasion an environmental or Maven problem can occur during installation, or you weren’t fast enough installing the Android SDK.  If that happens, simply close the dos prompt then run the installer again.



First things first, download the GFSPlayNInstaller.  Extract this file anywhere on your computer, it will contain two files, a .CMD and at .PS1 file.  The PS1 file does all the work, but needs to be launched using the .CMD to have the proper permissions.  Do not run from within the zip, this will not work.  Throughout the install you might get a Windows firewall prompt regarding Java, this is part of the Google PlayN install process and should be granted permission.



Double click Install.cmd



A command prompt will open and you will receive a prompt to determine if your system is 32 or 64 bit; hopefully the detection is correct and you can simply click YES.






Now you will be prompted if you have a Java JDK installed ( the JRE is not enough! ).






If you do not have a JDK installed or you do not know, click No.  This will cause the JDK to be downloaded and installed automatically.  If you already have a JDK installed click Yes, and the following dialog will appear:






Simply navigate to the JDK directory and click OK.  Do NOT click cancel, I am not completely sure what will happen, but I doubt it’s good. Winking smile  If you clicked No earlier, you will not get this dialog.  If you clicked YES and the dialog didn’t appear, alt-tab around to see if it is there somewhere, it doesn’t always get focus.



Now you will be presented with this dialog:






This dialog is determining where PlayN is going to be installed.  If you simply click OK, it will be created in C:\.  Where ever you select a new folder PlayN will be created, so you do not need to create a folder just for it.  Again, don’t click Cancel…  Now the installer is going to go off and do its magic for a while….






Behind the scenes it is doing a number of things, downloading a zip program, grabbing Git and the Android SDK.  Even if you don’t want to develop for Android, you need the SDK installed for PlayN to work properly.  That is the next step and it is very important you do this part correctly as it was the only bit I could not automate!  You need to configure the Android SDK and you need to do it fairly quickly as the install will continue while the Android SDK install happens and eventually the install is going to depend on the SDK being installed.  Worst case scenario, run the installer again and simply close the Android SDK window when it opens.




As I said, this part is important, so I made a rather cryptic message box to inform you of just that!







Once you click OK, the race is on!  The Android SDK installer will be loaded and it should look like this:






It will take a minute or two to configure all of the various options… don’t be distracted by the installer going on in the background, keep your attention focused here!  First things first, once it’s done fetching info, click the “Deselect All” button to clear all selections.  Then you want to select Android 3 ( API11 )->SDK Platform, like this:







If everything was done correctly, the button will show “Install 1 package…”.  If you want more features, you can run the Android SDK Manager later… when you aren’t under type restraints! Winking smile


After you click the Install 1 package… button, you will see:





Simply click Install.



Alright, stressful bits are over, now just a matter of sitting back and letting the installer do it’s thing..







That was a screenshot of the installer doing it’s thing.  Frankly it isnt very exciting and yes, it’s a rather long process.  While that process is happening, the Android SDK Manager is chugging along and will eventually say:





Say whatever you want, it doesn’t really matter so you might as well go with Yes.  Eventually assuming success with the Maven process ( actually it runs even if there is a failure… if you see a whole bunch of failures, try running the installer again ), you will get the following prompt:







This is just another simple GFS provide script that builds your new game Maven script for you.  If you want to create a game of your own, click Yes.  If you click Yes…





The new game wizard will appear!  Simply fill in the values you want to make your game, like I have above and click Make Game!  Once you click “Make Game” a MakeGame.bat file will be created then run.  This process creates an actual game within your PlayN folder.  Unfortunately I couldn’t completely automated it and it will prompt you to continue.  When prompted ( in the dos prompt ) type Y then [Enter].  Voila, your new game is created!  If you chose C:\ for your PlayN folder, your game will be located at [C:\PlayN\PlayN\YourGame]



Finally, you will get one last prompt:





I hear there are all kinds of interesting things at that website, you should click Yes and check it out! Winking smile  If you click Yes, it will open your webbrowser ( or a new tab if already open ) and send you to




Voila, all done!  Enjoy PlayN!



If you want to create a new game at a later date, the New Game Wizard can be run again, it is located at Playn\Playn\NewGame.cmd.



If you encounter any problems, please let me know and I will do what I can.  Either use comments here, send me an email ( not preferred, because other people having the sample problem will not benefit from the results ) or I will piggyback the PlayN teams support process and request you post to StackOverflow with the PlayN tag and I will keep an eye on posts there.


2. November 2011




If you have left a comment recently and it appears to be gone, or if you get notification of a comment that when you check it doesn’t appear to exist, don’t worry you are not alone!   Something screwy is going on and sadly it is outside of my control as comments are handled offsite by disqus.  For some reason it isn’t consistently showing new comments, although old comments appear to be working fine.  Hopefully it will be resolved soon.


In the meanwhile, rest assured I can see all of the comments are in fact intact on, so hopefully this is just a brief interruption.  If you want to contact me and comments remain down, you can email mike [@] gamefromscratch [dot] com.   Can you tell I’m sick of spambots? Winking smile


Hopefully this is a very short blip.


EDIT:  They appear to be back…. for now.


EDIT2: 11/6/2011, it's happening again.  Pay no attention to the comment totals at the top of a post, click into the post to see if there are comments.  IF you made a comment and it disappeared, do not worry, it's still there... somewhere.  I think I have erased two comments total since starting GFS, one was a racist diatribe and the other was a spam bot, so don't worry, I didn't erase it.

Totally Off Topic

Month List

Popular Comments