Geertjan Wielenga, a Sun employee, shows how a pair of wizards in the upcoming NetBeans 5.5 can generate a basic web-application from a database, similar to the initial stages of programming a Rails application in Ruby. The story is in two parts, a quick overview and then a second post with sample code and a screenshot of the wizard.
I like Eclipse a lot. It’s powerful, looks great, it’s very extendable, and enjoys a huge mindshare.
However, it has a huge initial learning curve, and can be frustrating using the plug-ins necessary for J2EE/Web development.
Meanwhile, the other big open source Java IDE, NetBeans, keeps making improvement by leaps and bounds. My first real foray into Netbeans was with version 4.1, and I was amazed with that, especially when I compared my sometimes frustrating experience with Eclipse. Then 5.0 was even better. Now with the Entity bean/database/autogeneration tool, a la Rails type functionality, added onto 5.5, NetBeans seriously rocks.
Frankly, with this type of functionality, NetBeans almost makes Eclipse, and most certainly makes Rails, irrelevant, from a technological and productivity viewpoint.
I gotta hand it to Sun. They may not know how to be profitable, but they sure can put out some really nice products, and NetBeans is a shining example.
I don’t understand your claim that Rails is irrelevant now. Rails is very nice to get things done quickly, it’s based on a very nice language and most importantly everything is free as in freedome (as opposed to say Java the language). And from my own experience it’s quite adaptable as well.
I think it’s a lot easier to get into as well but that might just be personal bias because the last time I checked the whole J2EE specification was one scary monster.
Right tool for the job is a lot more apropriate than the “oh yeah, we pawned you. gg-no-re” attitude that a lot of people seem to have. And personally I think a startup that would say look for Ruby/Rails programmers would get a lot more applications from very good programmers that yet-another-java-shop. but that’s bias again
And guess what there’s even more tools to choose from (Python/Zope etc.)
Java EE 5 is a whole lot easier than J2EE 1.4: they’ve ditched most of the deployment descriptors in favour of annotations, and entity beans are now ordinary Java objects instead of some enormous RMI-ed monster.
I would always trust Java shops: while all the bureaucracy and red-tape in the language can make it unwieldy, it also makes it difficult to write truly bad code in it. For example, while looking for a CMS a while back, I tried about six from opensourcecms.org, all of them written in PHP, and all of them (in the admin pane at least) would crash if invalid input was given. None of them implemented any decent way to display an error message.
Of course, Ruby and Python are more robust languages than PHP, but I wouldn’t entirely discount Java.
It awesome to see the whole Java movement lately. It’s really mind-bogging to see how nice things change.
Though the 1.5 = 5 step is kinda weird.
Anyhow. Eclipse source editor is, IMHO, far superiour to netbeans. What would be damn cool would be if I could take netbeans apart ala gimp and plug in my favorite editor. That would be TextMate. And have the rest of the IDE still work.
But fun-times are ahead with JEE 5.
kindest regards,
M. Angerman
I am using Netbeans 5.0 at work and I am very satisfied with it. Java development has never beem easier in my opinion.
NB 5.5 (due to be released this summer) looks really really good and I am confident that it will boost our development efforts even more with excellent support for Java EE. Stories like this really make me to look forward to the next release. Sure, NB 5.5 will bring many other improvements.
One thing I still lack is a bit better editor. However, the word is (actually, it is official confirmed) that Netbeans 6 (together with Java 6.0) will address this including additional speed improvements.
Also, check out nbextras.org for many nice plugins, and don’t forget that the Struts Console works fine with NB.
Good job, Sun.
Rails aint about the wizards, it’s about the language. That makes a huge difference and the sooner we realize that, the better we come out from this game.
Beside that while Eclipse is still my first choice for an all-around IDE, NetBeans beats it anytime for both J2ME, Swing (with Matisse) and certain kind of J2EE developments.
Rails aint about the wizards, it’s about the language. That makes a huge difference and the sooner we realize that, the better we come out from this game.
This is true, but the rise of C# has really spurred innovation in the Java sphere, and the things that are possible now with annotations are really impressive. C# 3.0 will have support for lambda expressions and closures (similar to blocks in Ruby). I would hope that Java 7 will see something similar, though it will be a major change in the way Java apps are developed, as it involves as a first step ditching the concept of a Listener class.
Beside that while Eclipse is still my first choice for an all-around IDE, NetBeans beats it anytime for both J2ME, Swing (with Matisse) and certain kind of J2EE developments.
LOL! So NetBeans beats Eclipse at pretty much everything!
I keep the faith.
I’ve been doing an on and off project on weekends past few weeks, and I was doing classic 2.0 CMP with NB 5, wizards and all.
With the wizards, the 2.0 CMP seemed to work just fine. But as soon as I started trying to add tables manually, rename columns, etc., NB was corrupting the XML, not updating all of the classes, etc. If was borderline unusable.
I finally punted on the CMP layer and simply rewrote my DAO’s (which I already had accessing the CMP layer) in pure SQL.
Some of this was my fault, some NB’s fault, some SJAS fault (not horrible helpful exceptions at times).
But I still have faith. I logged several bugs, got good responses from the mailing lists etc. I’m sticking with it overal (NB and SJAS).
I would love for something like this 5.5 stuff to work out.
But here’s the deal. The only code we’ve seen is, essentially, an EJB 5 POJO Entity bean.
We haven’t seen any of the code for the pages. We haven’t seen any potential glue code that might be generated. And there’s no discussion on what hoops you have to jump through to, say, add a column to a table.
It may well be a slick uber Wizard that generates a boatload of code.
But if it’s an uber Wizard that simply passes a few parameters to some “uber” objects where all of the “real work” is done and, perhaps, not actually exposed and available for (easy) modification and enhancement, then this is no more that a nice demo and not at all applicable for the Real World.
Certainly willing to give it a go and take a look, but I’m not holding my breath.
It’s my understanding that the Rails code is reasonably extensible to support development beyond simply the bulk boilerplate generation stage.
“But here’s the deal. The only code we’ve seen is, essentially, an EJB 5 POJO Entity bean.”
WHO are you speaking for?
I can speak for myself in that I’ve now written applications w/ EJB3 and I can tell you that *this* is *the* standard for writing server-side enterprise applications.
Rails is the only thing you’ve mentioned that hasn’t cut it in the real world (yet) and you’ve got it quite backwards again when you say that applications beyond the trivial are too complicated in Java EE. Rails is where this situation arises…where things are quite simple for cookie-cutter functionality…Rails gets awkward when your application grows beyond the trivial.
Altering your data model w/ EJB3, if you’re using CMP and EJB3 persistence vs. BMP (don’t know why you’d find many occasions to do this?) – is easier than ever. My apps were build on JBoss EJB3 and I changed my domain model/data-model regularly during development and simple re-generated my tables….and went on coding features. There is no SQL to break and if you’ve coded your application properly, you shouldn’t have to change much of anything beyond that.
In any application you run a tremendous risk by changing your model. This is something that typically will be rare if the proper planning and thought went into your app.
You’re comparing two entirely different technologies here. On one hand you have a mature, stable, time-tested, enterprise-tested platform with an extremely rich, mature set of APIs for building *any* kind of application. On the other hand you’ve got a scripting language w/ a relatively new, immature framework that has not weathered the enterprise.
Everyone likes their new whizz-bang languages & solutions. That’s great for your personal work, when it comes time to get down to business…you’ve got a different situation on your hands.
WHO are you speaking for?
Um…I guess I’m speaking for all of the folks that might consider this Wizard that the story is talking about to be a replacement for Rails.
I have no qualms about JEE 5, or its role, and my comments weren’t even remotely directed there.
My comments were directed to the NetBeans tool, and this new “instant application” wizard being touted in NetBeans 5.5.
Having an all powerful one shot code generator turns out, in practice to be of limited usefulness after the first time the code generator is run.
I have not used this new wizard, it would be nice if this wizard is some how iterative in nature and will work with a project that is expanded and being redefined.
However, in my experience, most wizards fail at this task completely.
The demo mentioned in the linked articles talked about how they could create an application without even typing, just clicking the mouse. All well and good, makes great demos but typically once you’re past the last “Next” button of the wizard, the tool abandons you completely.
The typical example is when you, for example, add a column to the database. Can I rerun the wizard on the single table that was changed and have it update in all the correct areas for me such as the Entity Bean, any interfaces necessary, any relationships it may be involved with, and any screens it may be displaying on?
If not, then all of that falls back on the programmer and the tool is out the door past the first day.
Great demo, lousy practice.
So, we wait and see what this tool can really do. I can dream of a iterative, regenerative tool but I expect I’m just getting a template based code generator of limited utility.
You’re probably right in that respect, I doubt the wizard will help you add the column again, nor does Java support the kind of runtime code-generation that Ruby on Rails does.
On the other hand, adding the extra code for an extra column is not that hard. Using the example from the second part of the article, say you added a column called “discount_type” to your database table. You’d make the following change in your code to incorporate it:
@column (NAME = “discount_type”)
private int discountType;
[/i]
You’d then select the second line, right-click, select the Refactor sub-menu, and select “Encapsulate Fields” to have NetBeans automatically generate the Getter and Setter methods. And that would be it: change made with only two lines of typing.
This stuff is very, very impressive. I’m really looking forward to the combination of NetBeans 5.5 and Java EE 5.
Edited 2006-05-07 13:53
Cool that J2EE development now may become as comfortable as WebObjects (NeXT / Apple) is since 10 years ago.
If Sun would now manage to make entity beans fast (there are amazingly many projects out there that only use session beans) and build a distribution layer (like that WebObjects) to speed up fat (Swing) clients…
Perhaps you haven’t tried EJB 3.0, Entity Beans are now simple pojos with very simple annotations…you must be speaking of EJB 2.x or earlier releases.
J2EE is a thing of the past and Java EE is the new standard and the spec is now complete. I realize that there are many applications out there built around J2EE but once developers realize the amazing advantages JEE 5 offers, I think you’ll see an explosion of new applications built on this platform.
I’m already written a couple of applications with EJB3 on JBoss and the productivity gains are exceptional. Building enterprise applications w/ Java EE 5 is painless.
Boy, I can’t believe how far ahead WebObjects still is. I couldn’t believe the ease and power of creating Direct to Java Client projects. In addition to your two requested additions, how about something like EOModeler so you can visually create your Entity Beans. God, Sun should have just purchased WebObjects from Apple.
The problem with Java on the server side is not about development tools.
It’s about ease of deployment of J2EE applicatons in multi account environments, or rather the lack of it.
To deploy an application most application servers requires administrator rights on all parts of the server. Compare that to php where a .htacces file on the users account is enought.
This makes java web serving much more expensive than its competitors. If this was fixed, Java would be much more competitive to languages such as PHP, Ruby, Perl.
am using either struts or spring, how would Java EE 5 affect me?
It would simplify the generation of your business logic: basically a bit like Hibernate on steroids. You no longer need to write any code or deployment descriptors to access your database, you just create a normal class and annotate it or, better yet, let NetBeans do all that for you.
Struts is for the presentation logic (i.e. creating web-pages), it makes it somewhat easier to handle validation and error handling in your JSP pages. It’s not really related to Java EE 5, though just as Hibernate inspired EJB 3.0, Struts has inspired Sun to develop Java Server Faces.
I don’t have much experience with Spring, so I can’t comment on that.