Opening a demo or sample code from GIT is relatively easy if you are an experienced Codename One developer but for a lot of newer developers for whom samples are often more crucial this can be challenging. One of our solutions was placing the demos in the Codename One new project menu but that’s probably not enough.
First before we begin with the step by step guide let’s explain what is happening…
Why Doesn’t a Project "Just Work"?
There are two major reasons:
Both of these are easy to fix, but with this post I’d like to show you a trivial trick to do this that will work in NetBeans/Eclipse & IntelliJ/IDEA. The trick is to create a new project and copy the sources on top of it for everything to work…
I’ll explain this thru an example by opening and running AlphabetScroll in the 3 IDE’s using these steps.
Get the Main Class & Package Name
Create a new Project in the IDE
You can leave everything in the default settings, the only two exceptions are the package name and main class name that must match the main class & package you found in the
Figure 1. Create a new project for Alphabet in NetBeans
Figure 2. Create a new project for Alphabet in Eclipse
Figure 3. Create a new project for Alphabet in IntelliJ/IDEA
Copy the Files
Open the project folder outside of the IDE, replace the
src directory with the one from GIT and replace the
codenameone_settings.properties you have with the one from GIT.
If the git project has a
native directory copy it on top of yours.
If the lib directory within the git project has any cn1lib files copy them into your lib directory & use Refresh Libs in the right click menu under the Codename One menu.
You can now run a project from GIT regardless of the IDE you are using, notice that if your plugin is old you might need one additional step. Right click the project and select Codename One → Codname One Settings.
Under the Basics menu click the Update Project Libs button (bottom left). This will update the jars to the latest allowing the project to run.