Random NetBeans Stuff

Thursday Oct 31, 2013

Great news for Eclipse refugees everywhere. Benno Markiewicz forked the Eclipse formatter plugin that I blogged about sometime ago (here and here)... and he fixed many bugs, while also adding new features. It's a handy plugin when you're (a) switching from Eclipse to NetBeans and want to continue using your old formatting rules and (b) working in a polyglot IDE team, i.e., now the formatting rules defined in Eclipse can be imported into NetBeans IDE and everyone will happily be able to conform to the same set of formatting standards.

And now you can get it directly from Tools | Plugins in NetBeans IDE 7.4:

However, good news! The two worlds are not divided in NetBeans IDE 7.4. Changes you make in Chrome Developer Tools (CDT) are automatically persisted to the related files in NetBeans IDE, as you can see in a new YouTube clip I made today.

Tuesday Oct 29, 2013

At JavaOne 2013, there was a lot of buzz around the TomEE server, e.g., many Tweets, nice party, and a new TomEE consulting company. For those tracking TomEE developments, it's interesting to note that recently the NetBeans IDE development builds have had added to them... TomEE support.

Note: The TomEE support described here is not in NetBeans IDE 7.4, but in development builds for the next release of NetBeans IDE.

For example, with NetBeans IDE development builds you're able to:

register TomEE as a server in the Services window (TomEE has several distributions, e.g., one can use the "with JAX-RS" one, for example)

the IDE lets you create a new data source for TomEE and deploy it to the server

the IDE figures out the components that are already packaged in TomEE, and the fact that (unlike with regular Tomcat), it does not need to package any components such as JSF implementation, persistence provider, or JAX-RS runtime, so that the resulting WAR file is very small

the IDE can also do "deploy on save" with TomEE, so that your development cycle is very fast

Adam Bien blogged about how he set up TomEE sometime ago, here. The official support in NetBeans IDE will be much more tightly integrated, simplifying the steps Adam describes. For example, the IDE does step 2 from Adam's blog for you, i.e., it sets up TomEE deployment roles. Moreover, it knows about all the technologies included in TomEE so that it can optimize the packaging; it knows about TomEE's persistence setup; it can work with TomEE data sources, etc.

Below you see a Maven-based Java EE 6 PrimeFaces application (all entities and JSF pages generated from a database) deployed to TomEE in NetBeans IDE:

And here's the management console for configuring and finetuning TomEE in NetBeans IDE:

When I tried out the NetBeans IDE development build and TomEE, to see how everything fits together, I was surprised at how fast TomEE started up. Not sure what they did to it, but seems like a server on steroids. And setting it up in NetBeans IDE was trivial. Add the simple set up of TomEE in NetBeans IDE to the many benefits that the widely praised out of the box NetBeans Maven tools make possible, together with the fact that not one single plugin had to be installed to get everything you see described here up and running... and you have a really powerful combination of dev tools, all for free.

Monday Oct 28, 2013

Do you have ActionListeners and JPanels lying around? What about integrating them into NetBeans IDE? Extending NetBeans IDE is not rocket science. Watch this screencast to get started integrating your own technology into NetBeans IDE:

Great. I'm working on more screencasts like that, from different angles. For example, one will methodically explain each and every window in NetBeans IDE; another will step through the creation of an application from conception to deployment; while another will focus on the NetBeans IDE extension points and how easily they can be used to add new features to NetBeans IDE.

The screencast approach has, I think, a lot of advantages. They take less time to make and they seem to be more effective, in several ways, than tutorials. Hearing someone talk through a scenario seems to also put things in a clearer perspective than when you have everything written out in a document, where small details get lost and diversions are more difficult to make. Anyway, onwards to more screencasts.

Friday Oct 25, 2013

I took my first tentative steps into the world of Ext JS charts today, in NetBeans IDE 7.4. Click to enlarge the image.

I will make a screencast soon showing how charts such as the above can be created with NetBeans IDE and Ext JS. Setting up Ext JS is easy in NetBeans IDE because there's a JavaScript library browser, by means of which I can browse for the Ext JS libraries that I need and then NetBeans IDE sets up the project for me.

Thursday Oct 24, 2013

Continue where you left off at the end of part 1 in learning the coolest tips and tricks for HTML5 development, with HTML, JavaScript, and CSS in NetBeans IDE. You'll learn about a bunch of things from SASS to Cordova and from JavaScript debugging to Chrome integration!

Feedback and/or ideas for other similar screencasts? Let me know in the comments to this blog entry.

Wednesday Oct 23, 2013

HTML, JavaScript, and CSS development in NetBeans IDE is fairly new, especially the integrated features of all the editors with the browser. In this screencast, newbies (and even those who have used NetBeans for many years) get a series of tips and insights into using NetBeans IDE in the context of HTML5 development. For example, useful keyboard shortcuts, plugins such as Emmet, and much much more is covered:

Part 2 of this series, which is also the final part, is set to be published tomorrow.

Note: The outline of the screencast is found in yesterday's blog entry!

Monday Oct 21, 2013

Here is a collection of screenshots from a proof of concept tool being developed by Nickolas Sabey and Sean Phillips from a.i. solutions. Before going further, read a great new article here written on java.net by Kevin Farnham, in light of the Duke's Choice Award (DCA) recently received at JavaOne 2013 by the a.i. solutions team. Here's Sean receiving the award on behalf of the a.i. solutions team, surrounded by the DCA selection committee and other officials:

They won the DCA for helping facilitate and deploy the 2014 launch of NASA's Magnetospheric Multiscale mission, using JDK 7, the NetBeans Platform, and JavaFX to create the GEONS Ground Support System, helping reduce software development time by approximately 35%.

The prototype tool that Nicklas and Sean are now working on uses JavaFX 3D with the NetBeans Platform and is nicknamed OrbitFX. Much of the early development is being done to experiment with different patterns, so that accuracy is currently not the goal. For example, you'll notice in the screenshots that the Earth is really close to the Sun, which is obviously not correct.

The screenshots are generated using Java 8 build 111, together with NetBeans Platform 7.4. Inspired by various JavaOne demos using JavaFX 3D, Nick began development integrating them into their existing NetBeans Platform infrastructure.

The 3D scene showing the Sun and Earth objects is all JavaFX 8 3D, demonstrating the use of Phong Material support, along with multiple light and camera objects. Each JavaFX component extends a JFXPanel type, so that each can easily be added to NetBeans Platform TopComponents. Right-clicking an item in the explorer view offers a context menu that animates and centers the 3D scene on the selected celestial body.

With each JavaFX scene component wrapped in a JFXPanel, they can easily be integrated into a NetBeans Platform Visual Library scene. In this case, Nick and Sean are using an instance of their custom Slipstream PinGraphScene, which is an extension of the NetBeans Platform VMDGraphScene.

Now, via the NetBeans Platform Visual Library, the OrbitFX celestial body viewer can be used in the same space as a WorldWind viewer, which is provided by a previously developed plugin.

Sunday Oct 20, 2013

Some mild consternation on the Twittersphere yesterday. Marcus Lagergren not being able to find the ASM classes in JDK 8 in NetBeans IDE:

And there's no such problem in Eclipse (and apparently in IntelliJ IDEA). Help, does NetBeans (despite being incredibly awesome) suck, after all?

The truth of the matter is that there's something called "ct.sym" in the JDK. When javac is compiling code, it doesn't link against rt.jar. Instead, it uses a special symbol file lib/ct.sym with class stubs. Internal JDK classes are not put in that symbol file, since those are internal classes. You shouldn't want to use them, at all.

However, what if you're Marcus Lagergren who DOES need these classes? I.e., he's working on the internal JDK classes and hence needs to have access to them. Fair enough that the general Java population can't access those classes, since they're internal implementation classes that could be changed anytime and one wouldn't want all unknown clients of those classes to start breaking once changes are made to the implementation, i.e., this is the rt.jar's internal class protection mechanism.

But, again, we're now Marcus Lagergen and not the general Java population. For the solution, read Jan Lahoda, NetBeans Java Editor guru, here:

AFAIK, the ct.sym is new in JDK6. It contains stubs for all classes that existed in JDK5 (for compatibility with existing programs that would use private JDK classes), but does not contain implementation classes that were introduced in JDK6 (only API classes). This is to prevent application developers to accidentally use JDK's private classes (as such applications would be unportable and may not run on future versions of JDK). Note that this is not really a NB thing - this is the behavior of javac from the JDK. I do not know about any way to disable this except deleting ct.sym or the option mentioned above.

Regarding loading the classes: JVM uses two classpath's: classpath and bootclasspath. rt.jar is on the bootclasspath and has precedence over anything on the "custom" classpath, which is used by the application. The usual way to override classes on bootclasspath is to start the JVM with "-Xbootclasspath/p:" option, which prepends the given jars (and presumably also directories) to bootclasspath.

Hence, let's take the first option, the simpler one, and simply delete the "ct.sym" file. Again, only because we need to work with those internal classes as developers of the JDK, not because we want to hack our way around "ct.sym", which would mean you'd not have portable code at the end of the day. Go to the JDK 8 lib folder and you'll find the file:

Delete it. Start NetBeans IDE again, either on JDK 7 or JDK 8, doesn't make a difference for these purposes, create a new Java application (or use an existing one), make sure you have set the JDK above as the JDK of the application, and hey presto:

The above obviously assumes you have a build of JDK 8 that actually includes the ASM package.

And below you can see that not only are the classes found but my build succeeded, even though I'm using internal JDK classes. The yellow markings in the sidebar mean that the classes are imported but not used in the code, where normally, if I hadn't removed "ct.sym", I would have seen red error marking instead, and the code wouldn't have compiled.

Note: I've tried setting "-XDignore.symbol.file" in "netbeans.conf" and in other places, but so far haven't got that to work. Simply deleting the "ct.sym" file (or back it up somewhere and put it back when needed) is quite clearly the most straightforward solution.

Ultimately, if you want to be able to use those internal classes while still having portable code, do you know what you need to do? You need to create a JDK bug report stating that you need an internal class to be added to "ct.sym". Probably you'll get a motivation back stating WHY that internal class isn't supposed to be used externally. There must be a reason why those classes aren't available for external usage, otherwise they would have been added to "ct.sym".

So, now the only remaining question is why the Eclipse compiler doesn't hide the internal JDK classes. Apparently the Eclipse compiler ignores the "ct.sym" file. In other words, at the end of the day, far from being a bug in NetBeans... we have now found a (pretty enormous, I reckon) bug in Eclipse. The Eclipse compiler does not protect you from using internal JDK classes and the code that you create in Eclipse may not work with future releases of the JDK, since the JDK team is simply going to be changing those classes that are not found in the "ct.sym" file while assuming (correctly, thanks to the presence of "ct.sym" mechanism) that no code in the world, other than JDK code, is tied to those classes.

Friday Oct 18, 2013

Loads of new features have been added to NetBeans IDE during the NetBeans IDE 7.x release cycle, i.e., 7.0 together with all the minor releases that have come after that, up to 7.4, which was released during the last few days.

Hard to keep track of everything added over all those releases, so instead of making a "What's New in NetBeans IDE 7.4" slide deck (which would only cover the highlights of the NetBeans IDE 7.4 Release Notes), as we would normally do, we've instead produced "What's New in NetBeans IDE 7.x", which is around 50 slides presenting all the key features of the IDE, together with all the key newest features. Here it is:

If you want to present the wonderful world that is the NetBeans ecosystem to your JUG or school or university or colleagues in your company, just download the above slide deck (either PDF or the PowerPoint sources) here:

Thursday Oct 17, 2013

"Twitter Bootstrap is a free collection of tools for creating websites and web applications. It contains HTML and CSS-based design templates for typography, forms, buttons, navigation and other interface components, as well as optional JavaScript extensions.
It is the most popular project on GitHub and has been used by NASA and MSNBC among others." (Wikipedia)

Normally, when you read "getting started" instructions for Twitter Bootstrap, you're told to download various things from various sites. Then you're told to set up various folders and files, etc. What if it could be much simpler than that? Spend 7 minutes with me in this (silent) screencast and you'll see a complete development environment for developing applications with Twitter Bootstrap:

Two things that could be added to the movie are the JavaScript debugger, the support for responsive design via switching between form factors in the embedded browser and Chrome with the NetBeans plugin, as well as how to convert the application to a native Android or iOS package via in-built Cordova support.

Wednesday Oct 16, 2013

My championing of TinkerForge, more than a year ago or so, has not been in vain. It introduced Neil Smith, developer of Praxis LIVE, to TinkerForge, who then subsequently turned his app into a visual development environment for working with TinkerForge:

Tuesday Oct 15, 2013

A very interesting (silent) screencast shared in the comments to this blog yesterday by Paul Orlov from St. Petersburg State Polytechnical University, shows the visualization of data in a NetBeans Platform application for an eye-tracking study. Related to that, read this very interesting PDF document in the same domain, i.e., investigating the role of peripheral vision in visual attention in programming.

Anyway, the screencast itself is too good not to share with the world:

Of course, the charts that you see in the screencast come from JavaFX.

Sunday Oct 13, 2013

Let's imagine all you care about is development of applications using HTML, JavaScript, and CSS. For example, you only want to create Knockout or Angular JS applications. How best to set up your IDE so that exactly those features, and no more, are included? You might want this very small minimalistic IDE if you're concerned about performance, startup time, and removing the clutter of all the buttons and menu items that don't relate to what you're doing.

The simplest solution is to go to the NetBeans Downloads page and get the PHP distribution. However, let's assume you don't need PHP, all you care about is HTML, JavaScript, and CSS. So, you can uninstall the PHP plugin and you're good to go. (Or, you could install the "All" distribution and include "Features on Demand" and then have things been enabled as needed. A problem with this approach is that you still get UI that you don't actually need, i.e., not a clean UI but one that has items in the New Project window that don't relate to what you're doing.)

The slightly harder solution is to do what I did. I downloaded the "All" distribution and, when I ran the installation wizard, selected only the two pieces that I'm interested in:

After installation, I went to Tools | Plugins and then removed everything that doesn't relate to working with the files I care about. As you can see, I don't even care about working with databases:

I restarted the IDE and went back to Tools | Plugins and all I saw was this:

I could go further and remove even more, e.g., maybe I don't care about "Local History" or one of the other features. Just uninstall them too.

I went back to Tools | Plugins and installed the "Dark Look and Feel Themes", resulting in a very light IDE that looks exactly as I want it to be. Click to enlarge the image, to get a better view:

Now, if I want anything else, e.g., database support, I can just go to Tools | Plugins again and install the related plugin. But the point is that right now no assumptions have been made and I have exactly the tools I need to work on the kinds of projects I'm interested in.

Also, startup and performance in general is blazingly fast.

To prove how purified my IDE now is, take a look at the New Project wizard:

It didn't take much work to get to this point, about 10 minutes in total, including the download and installation procedure.

About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.