Tutorial: Getting started with Netbeans and JUnit plus Cobertura and Hudson (Part 3)

26 09 2009

Following part 1 and 2 which covered the JUnit test class creation and the coverage evaluation by Cobertura, we will add in part 3 another dimension: Automation. So far we run the tests manually, but we want to achieve a continuous integration and test environment.

Part 3 (Cobertura and Hudson)

Preparation:





Tutorial: Getting started with Netbeans and JUnit plus Cobertura (Part 2)

25 09 2009

Following part 1 which covered the class and JUnit class creation and ended in a suspected successful test.

Part 1 (covering Cobertura setup and execution)

Preparation:





Tutorial: Getting started with Netbeans and JUnit plus Cobertura (Part 1)

25 09 2009

I believe strongly in testing. I saw companies and products without any automatic test frameworks and the slightest change to the codebase (often in the urgent ‘we-need-to-fix-it-now-and-give-to-the-customer-in-1hr’ mode) made parts of the product or modules prone to crashes because no one could test the changes against the complete application. In my current endevour to create a new product we embrace testing, though we dont practice TDD (test-driven-development), but at least we maximize the amount of automatic testing with tools/frameworks like Netbeans, Hudson, Cobertura and others. If you dont practice TDD, how can you judge how much of your codebase is really tested, even you assume all you business testcases are covered ?

The other day Code Coverage crossed my way (Thanks Chris!). Eager to find out how to “do it” or to “use it” I found a few tools suitable for the Netbeans environment. It actually drilled down to only one tool: Cobertura. It fits exactly into our landscape using Netbeans and Hudson and it is opensource.
To get started with Cobertura you should be familiar (a bit) with Netbeans, JUnit and Ant. The Cobertura website offers sufficient reference for all functions and introduction to get you started. But what I missed is a tutorial the start from the scratch using Netbeans and Cobertura. I found 3 references (I will add them at the end,) which are not complete or just not working for me), so let me share the most basic getting-started steps with you.
Please note: This is how I get started, it might not be complete, foolproof or even correct in all details. Please feel free to comment, correct or give other feedback !

Read the rest of this entry »





Tutorial: Glassfish running Groovy Scripts

2 06 2009

This is my very first screencast. Even I favor to read tutorials with screenshots, I believe it is easier to create screencasts than doing continuously screenshots and writing about them. In this tutorial I create a web application in Netbeans and add a very simple groovy script to it.

Ingredients:

  • Netbeans 6.5.1
  • Groovy 1.6.3
  • Glassfish V2
  • Chrome Browser

The embedded video on this blog does not support fullscreen. For fullscreen follow this link.

This video is created using Camtasia and hosted on screencast.com.

Resume: It is faster once you get used to the tools and talking to the screen ! So excuse me for the simple tutorial and wait for more sophisticated ones.





Interacting with Databases through the Java Persistence API

25 04 2009

Featured article about working with JPA in Netbeans. Reviewed and reproduced following an article by PACKT Publishing (link). Please hava a look at the end of the article with the book recommendation.

We will look into:

Java EE 5 Development with NetBeans 6
  • Creating our first JPA entity
  • Interacting with JPA entities with entity manager
  • Generating forms in JSF pages from JPA entities
  • Generating JPA entities from an existing database schema
  • JPA named queries and JPQL
  • Entity relationships
  • Generating complete JSF applications from JPA entities

Read the rest of this entry »





Tutorial: Reading from the DB with Netbeans and ZK (Part 2)

24 03 2009

In this part 2 we modify the ZK project from part 1 and add data binding and a detail view.

Before we start adding the new functions, you might want to look in some of the project settings that are default when you create a new ZK360 type web project. Both context path (under Project properties|Run), as well the Display Name in the web.xml (under project explorer|configuration files) . You better change the default to avoid confusion when starting to create the second project.

I recommend to have a look at these 2 documents: ZK Developers Guide and the ZK Reference Doc (link), giving you more insights how ZK works and how feature rich it is. I noticed the available Netbeans palette does not show all available features, so you are better of browsing the docs and look at the sourcecode of the ZK Explorer application (Live Demo).

Back to part 2.

Requirements:

  • Netbeans 6.5 with a running derby DB and the sample database (customer table)
  • Installed ZK 3.6.0 plugin
  • The project from part 1 (link)

Content

1. Open the ZKReadDB project from part 1
2. Change the controller class
3. Activate the Data Binding Manager
4. Make the listbox work witha model and refer the listitems to the fields
5. Implement the detail view
6. Add the detail view with textboxes
7. The complete index.zul and controller.java

Read the rest of this entry »





Tutorial: Reading from the DB with Netbeans and ZK

21 03 2009

After the first very basic tutorial that gets you started with the required plugins and settings (link), I will summarize in this tutorial how display data with zul using the JPA.

Requirements:

  • Netbeans 6.5 with a running derby DB and the sample database (customer table)
  • Installed ZK 3.6.0 plugin

Tutorial:

Content:
1. Start a new project
2. Create a new Entity Class from Database
3. Create a Controller
4. Create the table

Read the rest of this entry »





Getting started with ZK and Netbeans

19 03 2009

In my ongoing evaluation of various web frontend frameworks, I stumbled upon the ZK Open Source Ajax (among others like IceFaces, JMaki/Dojo/Comet, JSF Controls). Even ZK appears a bit more on the Eclipse side it can easily be used in Netbans. In order to get the ZK implanted in our favorite IDE, you need to download the plugin from Sourceforge (link). Please note the startsite on ZK (SF) highlights the current version 2.0.3 from March 2009, but clicking on the download link on the right points you to the old version, so you better select the browse packages link.

Link to ZK Website
Link to SF REM 2.0.3 Plugin

Start Netbeans and open the Tools/Plugins/Downloaded and add the downloaded plugin (with the usual agree and confirm unsigned plugin dialog.

bv2009031911350016

REM 2.0.3 NB plugin

That’s it ! Welcome to ZK in Netbeans.

Start a new web project and select the ZK 360 option.

ZK360 Project

ZK360 Project

You will find a project skeleton with an initial index.zul file

ZK Project Skeleton

ZK Project Skeleton

Start the application and it gets deployed to Glassfish (or you choice of AS). So far I have no problems running it on Glassfish V2 and V3 prelude.

I run through the evaluator tutorial with ease (link).
Stay tuned for more hands-on with Netbeans and ZK.





How to get started with Prefuse and Netbeans

30 01 2009

I was looking for a java based visualization toolkit for quite a while. Either they are very static (image rendered and delivered without any interaction) or cost too much money or badly documented or plain buggy and incomplete. I found a toolkit called prefuse (link) on sourceforge which is an amazing piece of work done by Jeffrey Heer (link) of Berkeley University Stanford. Thanks for this and to the people in the forum (link) to continue the effort to answer questions.

Though it’s last release if dating 2007.10 it is feature complete and not really need to carry the beta tag, but never mind. The project migrated to flare (link) based on Flash and AS, but unfortunately that is not always the first choice, even more powerful in terms of graphics. But I wonder what would be missing. It is open source, so with community effort things can be implemented or even added.
It is released under BSD and can be used freely for commercial and non-commercial applications.

I am a true Netbean nerd, aka NB user and spent some time to get started with prefuse.

Today I wan to share with you the steps (i did) to get a running with prefuse and Netbeans running Windows.
(Please note, it might not be the perfect or smartest approach. I dont claim its the right way or complete, but I got it to work this way. )
I am sure this is very basic information for the prefuse experts, but other beginners might need to go through the same steps.

1. Donwload the file prefuse-beta-20071021.zip (link).

2. Unzip the file to folder.

3. Check for a properly set JAVA_HOME path, like

E:\Documents and Settings\SAM>echo %JAVA_HOME%
E:\Program Files\Java\jdk1.6.0_10

4. Open the file build.bat with text editor of your choice and change the follwoing line
%JAVA_HOME%\bin\java.exe -Dant.home=…
to
java.exe -Dant.home=…
(I removed the JAVA_HOME because java already is in the system PATH)

5. Open a DOS-Box (Windows, aka run.. CMD) and navigate to the folder with the build.bat file.

6. Execute ‘build.bat all’. You should get something like this:

Build

prefuse and Netbeans: Build the jarfiles

7. Start Netbeans and create a new project (New, Choose project, Java, Java Application). Lets call it PrefuseDemo.

8. Open the project properties (right click on the project name in the project explorer) and select properties. Go to the libraries sectio and add prefuse.jar and demo.jar (required for the sample code). You find these files in the folder ‘build’ created by our build.bat.

9. Now you change the packagename (with the initial created Main.Java if selected) to prefusedemo.

10. In the build folder you also find a src folder with various sample java code. For this tutorial I took GraphView.java.

11. Create a new javaclass in the prefuse package with the name GraphView.

12. Copy the complete sourcecode from GraphView.java into it and replace the basic skeleton.

13. Fix the package name to package prefusedemo;

14. You can delete the Main.java if NB created it for you.

15. Build the project.

16. Right click onGraphView.java and select Run File. Finished ! You should see this:

t200901300014

prefuse and Netbeans: Run the demo


Remarks:
1. The other files (demos that come with the prefuse package) you can create the same way and add them into your demo application.
2. I tried to import the whole prefuse source folder into Netbeans via Import, but it didnt work.

Conclusion:
Now we got started, lets move on to understand the prefuse concept and adapt some of the samples to our own applications or create new ones from the scratch ! Stay tuned for more prefuse !





Starting with JavaFX

30 01 2009

For 2009 I decided one of the new technologies to poick up would be JavaFX. Always interested in RIA, only now I can stay in the Java family creating fancier applications than with Swing only. JavaFX is not matured yet, even it is released for production as version 1.0. I guess there is lot of stuff coming up with future releases. On of the catches currently is th elack of IDE that lets you visually creates JavaFX applications, you still need to create more or less manually the objects (buttons, textbox,..) on the screen. But I am 100% sure that some upcoming release of Netbeans or a plugin will allow this similar to place javabeans on a JSF page.

How to get started ? There are some pages with downloads and tutorials that I already listed in earlier posts (JavaFX 1.0 released, JavaFX Get Started ). Today I want to highlight 2 additional resources that are worth visiting.

  • James Weavers JavaFX Blog (link)
  • The JavaFX Online Seminar (free) by Sang Shin and James Weaver on Javapassion.com (link).
    A very different approach of training because it is rather online and not with fancy webinars or webcasts, but providing all materials allowing you work at your own pace anytime. I will try this !