Monday, May 8, 2017

Oracle JET: Hybrid android app using NetBeans

This blog is continuation of my previous blog

In that blog I showed how we can use npm, yo and grunt commands to develop a new web/mobile application in JET.
In this blog my idea is simply open the project in NetBeans and start development in NetBeans. NetBeans provide auto-completion + templates for new project etc for Oracle JET. As we have already created project using commands so we will not be creating a new project but directly open it in NetBeans and start using it.

1. Open project: To open project in NetBeans you can navigate as File > Open Project
      Good News: NetBeans automatically identifies our project created using yoman (yo) as a project.

We get various source directories (src, src-hybrid, src-web). We also have a separate web directory.

2. Make changes: Let us make some changes in source and see its
Few things to notice:

  • We can directly run index.html present in web directory.
  • Once its running Chrome browser shows a bar " NetBeans Connector" is debugging this browser. Don't cancel it. It enables browser log to appear in NetBeans console. 
  • Any changes done in web directory (Site Root) are picked immediately (without restart). 
  • Any changes done in src directories are also picked immediately (without restart). Actually these changes are pushed automatically to web directory immediately and application picks from web after that.
  • Ideally we should be changing src directory and should not code in web directory in this kind of setup. web directory is kind of classes directory and NetBeans will use it to run application. 


3. Run and Quick test: For this demo I just make changes in index.html inside src directory. I will change quickly change <h2 class="demo-profile-name">James</h2> to <h2 class="demo-profile-name">Sanjeev</h2>. I just need to save it. I find that changes are automatically pushed to web directory and even my browser is refreshed automatically to show new changes.

4. Release using Grunt from NetBeans

To run grunt commands for project, I can right click on project and select Grunt Tasks. There are few tasks already listed. To release I need to use serve:release task, which is not listed, so I can go to advance and create my own task.

Under grunt tab log you will see location of apk file.

Thats all. Now you can move and install this apk in android phone.

No comments: