08 April 2008

Studying for certification ? Netbeans is the answer...

For me this is the best IDE so far to help me in my studies in Java Certification.
It helped me a lot with SCJP and SCWCD and still helps me a lot with the SCBCD.

Why ? Because I just download one package of the IDE, install and start coding the examples in the book and studying them...

With some other IDE you need to configure a heck lot of stuff... It drives you away from the fact that you NEED to study the technology and not be configuring it to suit your best needs. Let's face it... If you are studying already a certification is because you have little knowledge about a specific subject and you want to make it better.

07 April 2008

X-Fi on Ubuntu 7.10

"[Alsa-user] Sound Card SB X-Fi Extreme Audio finally working

mario dupuis
Sun, 13 Jan 2008 11:15:14 -0800

For those who may have encountered problems with no sound coming from this card
under ubuntu Gutsy-Gibbon 7.10 (kernel 2.6.22-14-generic), here's the solution
that worked for me (could work with other distros as well, but i can't test them

Download the latest version here:

After that, do the following in a terminal:
to make sure all will operate correctly, do the following, before any install
$ sudo apt-get install build-essential
and after that you do that:

$ cd
$$ tar xvzf alsa-driver-1.0.15.tar.bz2
$$ cd alsa-driver-1.0.15
$$ sudo ./configure
$$ make
$$ sudo make install

reboot, and it should work

Another thing, you must deactivate in the volume panel EC958, if it is
activated, and use only analog settings (front/center/side/rear, depending on
your speaker setup, chose only analog front for 2.0 speaker system). You may
have to go into edit-->preferences (into the volume panel) to have the volume
sliders enabled for analog. You may use (although not tested) the digital
settings, if you connect your card to a digital sound system through the digital
output of your soundcard.

That's the way it worked for me. So don't throw your soundcard over the window,
there is a possible solution.

Sadly the sound isn't that awesome as you expect it to be...
The problem is exactly with creative who should let it go of this struggle to keep the drivers from being open sourced... I also have logitech z-10 speakers which make it even more confusing for the system...

NetBeans6.1+EJB3+Struts [PART 4]

You will have something like this (note that the code is folded)

Now Right click the BookCRUDAction and select Enterprise Resources->Call Enterprise Bean.

Click on MyApp-ejb, select BookFacade and click OK.

The following method will be implemented for you:

private BookFacadeLocal lookupBookFacade()

This way you will be able to access your bean from MyApp-war.

Now, open struts-config.xml from Configuration Files directory and insert these lines:

*(somehow i couldnt post these lines in blogger, dunno why...)*

These lines will tie the methods from the Action to struts-config mappings.

NetBeans6.1+EJB3+Struts [PART 3]

Now right click on MyApp-war, choose Properties->Frameworks->Add->Struts and press Ok and then Ok one more time.

If you right click MyApp-war, choose Properties and click on Frameworks you are going to notice that Struts Framework was added to the list of Used Frameworks.

Now in MyApp-war, Right Click->New->Other... and choose Struts in the Categories list.
And in
File Types list choose Struts Action.

Click Next > and enter the following information:
Class Name: BookForm
package: action

Click Finish and the FormBean will be created and the information will be written in the struts-config.xml

One more time in MyApp-war, Right Click->New->Other... and choose Struts in the Categories list.
And in
File Types list choose Struts Action.

Click Next > and enter the following information:

Class Name: BookCRUDAction
Package: action
Superclass: select in the dropdown MappingDispatchAction
Action Path
: /book.do
Next >

In the second part of the Action Wizard type the following information:

Scope: Request
ActionFormBean Name: BookForm
Parameter: create

And hit the Finish button.

The BookCRUDAction is then opened in your editor window. The mapping for the newly created Action is also added in struts-config.xml.

Now change the signature of the method from:

public ActionForward customMethod(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception


public ActionForward create(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception

This is done to be aligned with the information that was typed in the Parameter box while creating the Action class.

Copy and paste the entire method THREE more times so you will have the read, update and delete methods.

02 April 2008

NetBeans6.1+EJB3+Struts [PART 2]

Click Next and in packages you type entities and hit the Finish button.

This will generate the Java POJO's for you directly from the Database with all of the Annotations required.

Now navigate to Source Packages and open your Java Class. Take a look at how much code the IDE has already created. Also methods like hashCode, equals and even a @NameQueries annotation was added.

Now add @GeneratedValue(strategy = GenerationType.AUTO) to the top of your id field.

After adding the Annotation your code will look like this:

@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;

This will tell the Entity Manager to take care of the ID sequence.

Right click again on MyApp-ejb, New->Other->Persistence->Session Beans for Entity Classes.
Click on Next
select the entity class available
click Add >
And click Finish.

This will create the the Session Bean interface and the implementation.
Two classes will open in your editor.
Click on the Facade one and check it out all of the methods that the IDE generated one more time for you. You have a CRUD just with few clicks. ;)

Creating all of those classes through the IDE diminishes the eventuality of error-prone code of the many, many Session Beans you might be creating by hand. And also removes the tedious/slow work of editing xml's and the necessity of redundant code writing. ;)

NetBeans6.1+EJB3+Struts [PART 1]

Hi all, I just decided to start a blog and with the new blog comes already a review about the new NetBeans 6.1, still in beta phase but incredibly stable and FAST.

In this tutorial we will use NetBeans 6.1 Web & Java EE version.
This is the list of software one might need:

  • JDK 1.5
  • GlassFish V2 UR1
  • some database (I will use for this tutorial java db but mysql is also a good option)

NetBeans 6.1 Web & Java EE comes already bundled with GlassFish and Tomcat. In just 105 mb!!!. It's awesome to download just one package and a small one.

With NB6.1 you will see how fast it can be to configure/create/code with it.
I will assume that you have already a table in one database of your preference.

After downloading, installing and running NetBeans you will need to create a new project.

Click in File->New Project...choose Enterprise and then Enterprise Application.

Inside the Enterprise Application NetBeans will automatically create for you an EJB Module and Web Application Module.

Type MyApp in the Project Name and leave all of the other settings as it is.

Click in Next and Finish.

Notice that in on the left side in the Projects tab 3 modules were added: MyApp, MyApp-ejb and MyApp-war.

Right click on MyApp-ejb and select New->Other->Persistence->Persistence Unit.

Click in the dropdown box in Data Source and select your DB connection. Then in Table Generation Strategy select create. And leave Use Java Transaction APIs selected.

Once Finish is clicked a persistence.xml tab will open.

The persistence unit will tell your container how the entities will be persisted and managed in the application.

Now right click again in MyApp-ejb and select New->Entity Classes from Database.

In Data Source select the JNDI name that you have configured and the tables will appear in the right side of the panel, select the table you want to create the Java Classes and click in Add>