 |
NetBeans 6 - my first 24 hours
Posted by michael_n on December 05, 2007 at 02:14 AM | Comments (13)
My first 24 hours with NetBeans6.0 (final). I'm going to color a little outside the lines here, and soapbox a bit about "tools I use" (in NetBeans). Specifically: Spring 2.5, "vim", and Maven2.
First impressions with Netbeans 6
I had already been using & upgrading from NetBeans5.5, the 6.0 beta's, & the release candidates;
and the first thing I noticed with NB6 is the startup speed is much improved over the previous rc2.
On a (Linux) laptop, the NB rc2 was taking somewhere in the neighborhood of 10 seconds
(not sure exactly, I get distracted while waiting... short attention span) and now it's
thankfully down to a very focused 4 seconds.
First tasks with a new toy: customization.
Btw, it's really nice being able to run the same software on completely disparate
platforms. Big things like this get lost in the little details once a technology
(like Java) becomes ubiquitous.
Ok, here's my setup. I'm getting pretty good at this, since I've been doing it a lot. I've been running NB on Linux, Windows & Mac.
On Linux, just run the installer: chmod a+x, ./install, and the same GUI as on Windows & Mac
guides you through the basic steps:
- select to install GlassFish & Tomcat 6 (already installed from previous releases)
- option to import old NB 5.5 settings (I'll start over, just for practice)
- Linux (and Windows) creates a desktop shortcut:
- the Linux default launcher: /bin/sh "/opt/netbeans-6.0/bin/netbeans"
- you can customize the launcher with options (for example): /bin/sh "/opt/netbeans-6.0/bin/netbeans" --fontsize 10 --laf javax.swing.plaf.metal.MetalLookAndFeel
- (you could of course also install the substance LAF)
Time to install plugins.
People rant or rave about the number of plugins for this IDE or that, but
I've decided the perfect number of plugins per application is in fact 42. Strange, that is.
But seriously: any more than that, they simply aren't used. Less, and I feel limited, the platform isn't
extensible enough. (FireFox has been my strawman for this conclusion, but
I've had the same experience in using other IDE's, too. Or, Maven, for that matter.)
Btw, I'd love a NB plugin like FEBE + CLEO for FireFox -- a way to backup & bundle all my
NB plugins into a single re-installable installer!
But here's the essential super-short list of optional / out-of-the box plugins:
-
JUnit / testing related plugins: Now that JUnit4 is out (for quite some time actually), it's been a bit of a chore getting things to support the new features of this backward-compatible testing framework. Spring 2.5 now fully supports JUnit4, and I've had no problems with Maven2 under NetBeans with the annotation-style JUnit4 testcases. Everything pretty much "just works" (with one tiny exception: Profiling. I need to try this out again; I'm sure I'm missing something...)
- Maven related plugins. Notes:
- for an existing Maven2 project, don't "create new" projects in NB, just "open" the project. NB sees the pom, and opens the project.
- If it's a multi-module project, the sub-modules are also recognized as projects.
- "F11" compiles - actually executing a "mvn install", which also runs all your tests. (Remember: the somewhat misleading "install" goal means that the code is compiled, tested, and the artifacts (jars) are copied to your "local repository" (~/.m2) to be made available to other (local) projects dependent on them. On the other hand, the "deploy" goal pushes the artifact to your online maven repository.)
- shift-F11 does a "clean" + "install"
- you can right-click the project & run custom goals
- you can right-click a single JUnit4 testcase (no "main()" necessary, no "suite" required, no need to extend TestCase) and choose "debug" or "run"
- Other plugins: You'll definitely want to look into the other built-in (but optional) plugins. The short list: Developer collaboration, Mercurial, DTrace, Module Manager, RCP book samples, Log management, ... Ruby support, JMX, ... and the list goes on (well beyond 42)....
To install any of these 3rd party plugins, manually download the respective ".nbm" file(s), and in NetBeans go to: Tools > Plugins, "Downloaded", "Add plugins..."
And that's just the built-in plugins: see also the 3rd party plugins at the plugin portal.
My essential 3rd party plugins (for my particular needs) are:
- jVi plugin for vi essentially, all the goodness of Vim in Netbeans (download jVi at sourceforge)
- Download nbvi-FOR-NB-RC1-1.1.2.x6.zip - the newer, the better. The versioning is little ad-hoc. This is v1.1.2, x6 (x7, x8)
- Unzip, select both .nbm files: "com-raelity-jvi.nbm" "org-netbeans-modules-jvi.nbm"
- Optionally, you can install the NB patch: nb60m10-patch-for-jvi-07-07-01.zip
(...it kinda works, but with quirks). Unzip & copy the files directly into your nb
install folder, under platform7/modules/patches
- Check out the customizations under Tools > Options > Advanced Options: see the Control-Key bindings, verify that Ctrl-V *is* checked, so you can use Vim-style "Visual Mode". Then, you can't use ctrl-v
to "paste", but you can do Vertical editing (which is much cooler than pasting, imo).
For example:
and you've just commented out a block of code (five lines).
If you do lower-case "u", it'll undo just one minor edit at a time (ie, undoing one of the five comment-lines, rather than all five at once). If you install the aforementioned patch, the entire edit will be undone (just like in vim).
- Spring support plugin (v1.1, released Dec 2, 2007) (see: http://spring-netbeans.sourceforge.net/, Install plugin: spring-support-plugin-1.1.nbm )
Speaking of Spring...
Spring Framework 2.5
If I may go on a tangent: the new Spring Framework 2.5 really, really simplifies your project configuration (compared
to Spring 1.2 or even 2.0). I know this has very little to do with NetBeans per se, but it should be noted that
there is nothing preventing you from using NetBeans for a Spring project (for example, you don't need the Spring IDE for a Spring project)-- quite to the contrary.
And if you haven't browsed through the Spring 2.5 updates, you really should take a look; here's a quick launchpad:
First and foremost (test-first!), Spring2.5 supports JUnit4.4 annotation-style
testcases. (Note: the abandoned gienah-testing project is no longer necessary to support this). As for the xml-style configuration (and, remember, it IS possible to have Java-style configuration (a la Guice)), the required XML has really been simplified. And with the NetBeans Spring plugin, you can (at the very least) use auto-completion in your bean configuration. In NetBeans, your Spring XML config shows up in a "Other Sources" folder in NetBeans, if using the standard Maven layout with a folder for properties and xml config in "{mymodule}/src/main/resources".
As just an (incomplete) example, with Spring 2.5 you can configure
a JMS sender and asynchronous JMS receiver all in POJO's, configuring the JMS broker
URL & JMS 1.1 destination (topic/queue) in a easy-to-edit "properties" file (as another side-note, ActiveMQ is very Spring-friendly to configure. Very nice.) The below example shows the new 2.5 properties-configurator (it allows a java properties file to be read, substituting properties into your Spring xml config):
<!--
using the new (2.5) property-placeholder, eg, with properties
jms.url=tcp://hostname:61616 and topic jms.dest=FOO.TEST
-->
<context:property-placeholder location="classpath:jms-test.properties"/>
<!-- pojo listens for incoming jms messages (asynchronous) -->
<bean id="msgListener" class="com.company.jms.MsgListener"/>
<jms:listener-container connection-factory="myConnectionFactory">
<jms:listener destination="${jms.dest}" ref="jmsListener" method="processMessage"/>
</jms:listener-container>
<!-- a pooling based JMS provider -->
<bean id="jmsConnectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop">
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL">
<value>${jms.url}</value>
</property>
</bean>
</property>
</bean>
Compare this to the old-style (Note: the xml below is just the property configurer -- which is just the first line in the above xml snippet):
<!-- old style (but it could be shorter) -->
<bean id="myPropertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>jms-test.properties</value>
</list>
</property>
</bean>
It is pretty simple to integrate ActiveMQ into your Maven2 projects' testcases (if you're already using Spring 2.x and Maven2). Note that you'll have to add the apache repository to your pom.xml (or settings.xml).
More on plugins...
Ok: back to Netbeans... Other plugins that are of interest (to me, anyway):
- PMD plugin Java source code analyzer download / unzip / install: pmd-netbeans60-2.1-bin.zip (update: you'll probably prefer SQE , which bundles PMD and various other software quality tools -- FindBugs, CheckStyle, Dependency finder, ... )
- Mercurial: first, you have to install mercurial . And Mercurial requires Python, of course. For windows there's a simple "all-in-one" (BatteriesIncluded) installer that takes the thinking out of the installation. For Linux, installing anything is of course already straight-forward.
- For the record, here's what I did install (this is from the built-in plugins -- the post-install gives me a nice copy-able list of what I just selected... that's also new in 6.0),
- Ant 1.7.0 Documentation [2.22]
- DTrace [0.1]
- Developer Collaboration [1.2]
- Eclipse Project Importer [1.32.0.1.2.43]
- Extra Ruby Color Themes [0.50.0]
- GWT4NB [1.3.4]
- Generic Portlets [1.9.6]
- GlassFish V3 Module [0.3.16]
- JMX [3.0.0.30]
- JMeter Kit [1.0]
- Jellytools [2.3.121]
- Jemmy Module [2.2.7.10]
- JemmySupport [1.38.0.6.1]
- Jindent [4.0.9]
- Load Generator [1.7]
- Log Management [1.5]
- Maven [3.0.9]
- Mercurial [1.4.1.42.1]
- Module Manager [0.6]
- NB JUnit IDE Integration [1.27]
- NB JUnit [1.43]
- NetBeans API Documentation [2.25]
- RCP Book Samples [0.90]
- Ruby Extra Hints [0.34.1]
- Ruby RSpec Support [0.83.0]
- Task List Editor Support [1.14.0.55]
- User Tasks [1.28.3.55.16.7]
- XTest Module [1.5.75.0.6.43]
- XTest Samples [1.10.0]
Any comments on other plugins? favorites? diamonds in the rough? plugins with potential?
Open issues
One thing that I haven't tried yet with the shiny new NB6 is the Profiler.
But, on NB6.0-rc2, I couldn't get the Profiler to work with Maven2 projects as
wonderfully as with Ant-based projects. With Ant, profiling a project is a
breeze. With Maven... I couldn't really make it ... useful. I could attach to
a running process, but still, things weren't quite "Just working".
If I get it working (or if someone else has had a better experience), we can
all share & share alike.
As a workaround, I did a very Unix-only solution: you can pretty easily create
a directory of symbolic links in Unix (with NetBeans, you can't create a Ant project and a
Maven project in the same directory). For my Maven2 multi-project, I wrote a
shell script that took all my Maven multi-module "src" directories & merged them into a single src
tree in another directory; likewise, with my test source trees. Then, just have
Netbeans create a new Ant project based in this new directory. Feel free to run the Profiler, Debugger,
etc: any changes from the symbolically linked ant project are reflected
(via the symlinks) in the original Maven project. (Cough, hack, hack.)
But, I do have to note that the Profiler is really a useful tool -- another
bonus in a very solid IDE. (And although I haven't mentioned it, none of the
Netbeans 6 versions -- from the beta through to the release candidates -- ever crashed on me.
On Windows, Linux, or Mac. I'm glad to say that this is becoming the
expectation for software these days.)
In short, so far, so good.
-m
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
I've been using betas and RCs for 6 for some time, so the final release didn't really blow me away.
The things that I don't like are still glaringly obvious though
- No project libraries, making multi-module, shared projects difficult to manage
- Time to run my project at work (when everything is already up-to-date): 2 mins, with IntelliJ IDEA 6, it's practically zero. Why? NB uses ant to check that all 5 modules are up-to-date before starting the app. Surely, NB should know?
Hopefully these things will be addressed by 6.1, until then, I really can't use NB, even though I'd love to.
Posted by: goron on December 05, 2007 at 02:35 AM
-
the profiling of maven projecvts is not implemented, requires a rewrite of APIs in the profiler area. The current implementation assumes ant-based projects only.
http://www.netbeans.org/issues/show_bug.cgi?id=118322
Posted by: mkleint on December 05, 2007 at 04:38 AM
-
to goron:
Have you tried to disable "Track Java Dependencies"?
It's checkbox at .
Netbeans 6.0 has the 'feature' that it uses the ant task which takes a lot of time.
Kees.
Posted by: keeskuip on December 05, 2007 at 09:30 AM
-
to goron: Strange formatting on this blog! The line should be: It's a checkbox at [Project Properties][Build][Compiling][Track Java Dependencies].
Posted by: keeskuip on December 05, 2007 at 09:33 AM
-
re: project libraries... I personally don't like the idea of configuring the tool to use this or that library (but if you're used to it, you might miss it when it's gone). Since I regularly (too often) have to move from one computer to another, from one platform to another, from one IDE to another, I can't spend too much time configuring the tool. I prefer to configure the project -- that's why I prefer maven. Then all I need is for the tool to support Maven -- and I wish NB treated Maven projects as "natively" as it supports Ant projects. (But, we're close! ...except for profiling...)
speaking of profiling... I did see that "bug" (er, missing functionality) and configured my mvn project to run in a forked VM via the exec-maven-plugin, and passed in the -Dagentpath option to the VM. If you use the <classpath/> tag, the complete mvn classpath is passed to the program. Then, I attached the profiler to the running process. I could profile the application, but I got minimal information. I really wanted to see my call tree (and the time spent in each method). I couldn't... but I need (really, really need) profiling. (Everybody needs profiling! Trust me! You'll be surprised to see what your code is really doing...) In the meantime, I have my "tree of symbolic links" workaround. But I'm looking for better alternatives... (I forgot to mention that I also created a tree of symlinks from my local ant project's "lib" dir to my ~/.m2/repository. Yeah, not pretty, but it gets the job done. )
Posted by: michael_n on December 05, 2007 at 10:53 AM
-
to: michael_n, re: project libraries:
I think you're missing the point of libraries, and this is a fundamental problem with Netbeans.
Let me state first, I have a serious hankering to use Netbeans, and I have tested its suitability to my large team projects for each release of the Netbeans 6 alpha and beta releases. It's a preference thing, but I just prefer it way over Eclipse.
However, I can't bring my major enterprise projects into it because of the library issue. The crazy thing is that is the only reason I can't do it. Everything else is just fine. Eclipse's .classpath file is the key. It's shareable, quite flexible, and extremely useful. Sure, it's not straight from Ant or (shudder) Maven, but it works, and it's extremely easy to configure and share for all of the developers on my team. The paths are relative. Source zips are attached. It knows where to find Javadocs. In short, it works fantastic.
Netbeans doesn't even come close to this ease of use. I can't easily manage a shared compile classpath with my team that attaches source and Javadocs. Well, I can, but only with a lot of work, and I'm not gonna do that work.
The bottom line is I've heard plenty of excuses why Netbeans doesn't improve library management, but none of them matter when I have another IDE that does a perfectly fine job with very little effort. I wonder how many people get stuck on this one issue alone?
Posted by: gcom on December 05, 2007 at 02:02 PM
-
wow, I always forget that java.net blog comments don't do basic paragraph formatting without hand-holding. Heh.
Posted by: gcom on December 05, 2007 at 02:03 PM
-
Did you try SQE a number of plugin s for NetBeans concerning code quality (FindBugs, PMD, Checkstyle, Dependency Finder). This is in early alpha stage but you should try it out.
Posted by: sven on December 05, 2007 at 02:12 PM
-
NB uses ant to check that all 5 modules are up-to-date before starting the app
You can override the default ant actions for builds, etc. see Customizing the Build Process .
Posted by: andrewriley on December 06, 2007 at 01:19 AM
-
gcom: I totally agree with your concerns about the project libraries. We're also using Eclipse as our native IDE at the moment, but I have been into the NetCAT program lately, and I have asked _many_ questions about the "project library sharing between developers"-problem, but noone can come up with a good answer. I do really like Netbeans, but the only problem making it impossible to introduce to the rest of the team is the problem with project libraries and relative references to dependencies.
Posted by: viggonavarsete on December 06, 2007 at 02:32 AM
-
Thanks for the instructions on how to install jvi, I thought they hadn't released jvi for NB6 yet, but I was wrong. JVI rocks!
Posted by: vieiro on December 07, 2007 at 04:50 AM
-
sven: thanks for the SQE tip. I updated the post. I installed SQE it and it's quite nice (I immediately fixed like 20 things), and simple to install: first install the update center module, then you can install the SQE modules (and thus easily get later updates) directly within Update Center (er, I guess it's just called "Plugins" now).
vierio: I can't live without vim. Definitely a must-have for me. I even use NB for XML now (eg, with Spring config files, w/ the NB spring plugin: try ctrl+space in the xml attributes!). But there are a few bugs in jVi -- actually, just one that I keep bumping into -- but my fingers are learning how to deal with it. Install the patch for normal "undo", but still sometimes there's a clear problem when insert + backspace + "esc" or something (I can't remember)... it looks like a problem with 2byte (vs 1byte) characters. Maybe I'm typing too fast; it's hard to make it happen. But it's great to be able to edit "fast" again; it's all vim and more.
Posted by: michael_n on December 07, 2007 at 10:21 AM
-
another jVi tip in some windows, the jVi plugin will also be used as an editor, such as the expression evaluator ( menu: Run / Evaluate expression or ctrl-f9). Unfortunately, [esc] causes the window to close (which makes editing via vim pretty tough!) ... But this is no problem: just go to Netbean's advanced options, and under jVi settings, allow "Ctrl-[" to act as "esc". Then, train your fingers to not press "esc" when editing in the popup window, just use "ctrl-[". Use "return" to show the result of the expression. (Or, if you can "dock" the window, that'd work, too...?)
Posted by: michael_n on January 13, 2008 at 02:14 PM
|