Středa XI 07, 2007

How to access update center / plugin manager over web

Sometimes it is impossible to access the update center (for 5.x) or plugin manager (for 6.0) right from the IDE, for instance because of strict firewall rules. I discovered today that there's another way how to obtain the nbms and browse the contents of the update center - you can do it using your web browser!

The (no longer) secret URL to browse the plug-in repository is here: http://www.netbeans.info/uc/show_uc_content.html

Enjoy!


Středa IX 05, 2007

NetBeans Quick Tip #33 - Show Error Using Keyboard

One of my issues with previous releases of NetBeans IDE was that there was no way how to easily see an error in the editor. The code would get underlined by a red line if there was an error but to discover the error message I always had to move away from the keyboard and use my mouse to hover on the error mark. Then I could see the error and I would switch back to the keyboard to go fix it. Maybe there was a better way to do this but I didn't find it.

Today I realized that in NetBeans 6.0 there is a way how to achieve this - hurray, I don't have to switch to the mouse! So here's the trick - you need to move to the row with the error (with the underline) and press Alt-Enter - yes the same shortcut you use to invoke a hint (aka quick fix aka lightbulb). After pressing Alt-Enter on the row with an error you can see the cause of it:


I thought this was really useful, because switching to the mouse takes some of my time and I may lose concentration. 

Pátek III 23, 2007

NetBeans Quick Tip #32 - Faster and More Stable Ruby Support



Here's a quick tip for those who use Ruby support in NetBeans. By default NetBeans uses bundled JRuby. It currently comes in version 0.9.8 and there can be some issues when running more complex applications because JRuby is not 100% compatible with native Ruby yet. Also when you use Rails, new JVM is started each time you use a generate command with JRuby, which is pretty slow. Tor promised this be fixed in the future, however there is a solution now available.

If you want better performance and stability you can switch from default JRuby to native Ruby. Just install Ruby (which you probably have anyway) and set the Ruby binaries inside NetBeans to the Ruby ones instead of JRuby.


The drawback of course is that you're using Ruby so you can't take advantages of some of the features of JRuby (calling Java code from Ruby and vice versa). But if you don't need that, Ruby can be a better option for you - at least at this very moment when JRuby is not in final version yet.

Čtvrtek I 25, 2007

NetBeans Quick Tip #31 - Changing the Look and Feel



I am running NetBeans on Solaris and to be honest I don't like the default look and feel, mainly because of the sick-looking blue color. But it's very easy to change the look and feel. My favorite look and feel is JGoodies Looks. To use a custom look and feel simply run NetBeans with the following parameters (for Looks):

./netbeans --cp:p /export/home/roumen/looks-2.1.2.jar --laf com.jgoodies.looks.plastic.PlasticXPLookAndFeel 

If you want to change the look and feel pernamently, you can add it into etc/netbeans.conf. There is a parameter called netbeans_default_options. Add to this parameter string "--laf [LAF]", where [LAF] is the class representing the look and feel. Note that GTK LaF has improved a lot in JDK 6, so I also recommend trying GTK LaF if you run Linux or Solaris.

Here are screenshots to compare the default Solaris look & feel and JGoodies Looks:


NetBeans with default LaF on Solaris


NetBeans with JGoodies Looks LaF on Solaris

Sobota VIII 19, 2006

NetBeans Quick Tip #30 - When GroupLayout Fails



Usually you'll do pretty well for most of the GUIs with GroupLayout (the default layout manager used in Matisse). But there are some GUIs for which it's not really suitable. I learned that today after several hours of fighting with Matisse. An example of a GUI you don't want to create with GroupLayout is the one I created today.

The problem is that with GroupLayout components group together and if you want to position them really freely, they snap even if you don't want them to snap. And then if you add one more component, it just moves all the other ones and you're screwed.

So, a solution which I found for this type of complex GUIs with background and exact 1-pixel position requirements is to use AbsoluteLayout:


With AbsoluteLayout you can place things quite precisely. The GUI won't resize properly, but that doesn't matter in my case. Now comes the Big HackTM: when you are ready with the form you can convert the GUI from AbsoluteLayout to GroupLayout (actually it's called Free Design in the menu). Then you don't need the AbsoluteLayout library, because the GUI is back in GroupLayout. Now you can fine tune things (move them by 1px etc.) And if you're lucky, you can even add a component without breaking the rest of the form :)

I also realized that it's possible to design multi-layered GUIs with Matisse by using jLayeredPane. The trick when designing each of the panels is to choose "Design this container" and then you can move the components easily in the panel (without disturbing the rest of the form or the background). So by dividing your form into many layers with jPanels you can actually create very complex and very good looking GUIs. It would be great to have better support for such design though, e.g. moving components by arrow keys would be really awsome!

Úterý VIII 08, 2006

NetBeans Quick Tip #29 - Monitoring HTTP Communication



Did you know that you can use NetBeans to monitor all communication of your web application - between the web browser and the web server? Indeed, you can see all the requests, read the headers, see the request parameters, etc. But not only that, you can actually save these requests and replay them.

This becomes very handy when testing your web application. For example you want to open a page with different parameters so you replay the request with modified (or even new) parameters.


HTTP Monitor in NetBeans

HTTP monitor becomes really handy when working with AJAX. You can see every individual request and response, even though the form wasn't submitted - so you can actually monitor how javascript code requests new XML documents as the user goes through the page. It is quite amazing how much communication there can be between the webpage and server in some AJAX apps. So HTTP monitor can also help you see if you are not doing too many requests to the server.

HTTP monitor is accessible via Window | HTTP monitor. In case of Tomcat the monitor is enabled by default, but in case of Sun appserver it needs to be activated in Server Manager. I do not know about the other servers... please add a comment if you know how you can monitor requests to other appservers.

Neděle V 07, 2006

NetBeans Quick Tip #28 - Configuring Derby Database in NetBeans 5.0



If you want to use the integrated Derby database in NetBeans 5.0, you have the following options:

1. Download and install NetBeans with the Sun Appserver bundle. Then you don't need to do download and install Derby, because Sun Appserver installation contains the Derby database.

2. If you don't install the Appserver bundle bundle, you will need to download and unzip Derby to a directory in your disc. That's all you need to do, you can skip the rest of the installation process because the NetBeans integration takes care of everything - it knows how to start the server, etc.

As the next step you need to tell NetBeans where to find the Derby database. Go to Tools | Options and jump to Advanced Options | IDE Configuration | Server and External Tool Settings | Derby Database. Here set the directory where you unzipped Derby (e.g. c:/derby) and the location of your database (e.g. c:/derby/database) - this directory will be created for you if it doesn't exist. Now you can go to Tools | Derby Database and start the Derby server or create a database (this submenu was not available before):


If you're using NetBeans 5.5 daily build, just go to the update center and install Derby from the update server - that's the easiest way to set Derby up, but unfortunately not available for 5.0.

What can you do once the database is set up? You can connect to the database in the Runtime tab by either the embedded driver or the client server driver. If the database server is not running it gets started automatically. You can execute queries with the built-in SQL editor, browse the data, create new tables or alter existing tables. You can also create new database and set the privileges to it. Basicly you can do anything you need to work with a database from the IDE. For more information see this tutorial from Brian.

<rant>Did you notice I don't call Derby database the "Java Database"? Well, I still can't get used to calling Derby a Java Database and I hope that Sun will stop for once this renaming maddness :( Sun, please don't rename technologies all the time, it just makes everybody confused. Thank you.</rant>

Sobota V 06, 2006

NetBeans Quick Tip #27 - Implementing Abstract Methods



This is my favorite hint... it saves me writing of code when I need to implement abstract methods in a class which extends some other class.


You can also use Alt-Enter to invoke the hint by keyboard instead of clicking by mouse.

Čtvrtek IV 27, 2006

NetBeans Quick Tip #25 - Case Insensitive Code Completion



One thing I change everytime I have a new userdir for NetBeans is the code completion sensitivity. I think it's just much more productive to use the case insensitive code completion - typing the case correctly is another thing I need to think of when writing code. This is especially useful when I write classes like StringTokenizer, BufferedReader, etc. You can turn off the sensitivity here:


I wonder if there is anyone who actually needs the case sensitivity. As far as I know in NetBeans 6.0 we plan to switch this option to insensitive by default.

Sobota III 25, 2006

NetBeans Quick Tip #24 - Correct Javadoc



Discover a well hidden NetBeans feature called Correct Javadoc in my latest winklet:



Sobota III 04, 2006

NetBeans Quick Tip #23 - Changing Code in Blue Guarded Blocks



I noticed that some folks had a hard time finding out how to modify the blue, guarded code generated by Matisse. You can change this code from the Code tab in the component's properties. This winklet shows how to do it for constructors with parameters:

Středa II 08, 2006

NetBeans Quick Tip #22 - Using Matisse's Connection Manager



Today's quick tip shows how to use Matisse's connection manager for creating connections between components and generating events. The mysterious icon from Matisse's toolbar is revealed :)

NetBeans Quick Tip #22 - Using Matisse's Connection Manager



Today's quick tip shows how to use Matisse's connection manager for creating connections between components and generating events. The mysterious icon from Matisse's toolbar is revealed :)

NetBeans Quick Tip #22 - Using Matisse's Connection Manager



Today's quick tip shows how to use Matisse's connection manager for creating connections between components and generating events. The mysterious icon from Matisse's toolbar is revealed :)

NetBeans Quick Tip #22 - Using Matisse's Connection Manager



Today's winklet shows how to use Matisse's connection manager for creating connections between components and generating events. The mysterious icon from Matisse's toolbar is revealed :)


Winklet: Using the connection manager in Matisse

Úterý I 17, 2006

NetBeans Quick Tip #21 - Achieving Same Size



My next Matisse tip is about setting the same size of multiple components. It's useful for instance if you want all buttons to have the same size, but they are layed out horizontally, so no guideline helps you like in the vertical case.

I tried to record it as a small flash Wink video so let me know if this is a good way how to show such Matisse tips. I could also do it as an animated gif, but then the replay capability would be lost.

So here's my first Winklet :)

Hold the Shift key to select multiple components.

Pondělí I 16, 2006

NetBeans Quick Tip #20 - Killing Processes



I guess this tip is known by a lot of developers but three people asked me how to do it, so killing processes seems a bit harder to discover for newbies.

Question: I started my program in NetBeans and now I want to kill it. How do I do that?

Answer: Go to Runtime tab (or press Ctrl-5 to invoke it), choose Processes, right-click on the process you want to stop and choose terminate process. Rest in pieces.


Death to all processes

I wish some things in life were as easy as killing processes in NetBeans :)

Pátek I 06, 2006

NetBeans Quick Tip #19 - Positioning without Guidelines in Matisse



There's a small trick how to position your components freely in a Matisse form, without snapping to the guidelines. Just grab the component and hold the Alt key when placing it. This way you can put components close together, which would not be normally possible, because they would snap to the guidelines:

Středa I 04, 2006

NetBeans Quick Tip #18: What to Do when Things Go Wrong?



It can happen that things go wrong. For instance, you install that very cool plug-in somebody has developed and oops, the IDE starts to do strange things. Or your hardrive capacity goes to zero because you're downloading latest DVD image of your favorite Linux distribution and oops, NetBeans has nowhere to write. Or you open many versions of JDK sources and your userdir starts to grow due to the cache.

What to do now? A typical reaction of a Windows user is to reinstall the application. Well, you can reinstall NetBeans for 1000 times but it won't help, simply because the corrupted or overgrown data is in your userdir. The userdir contains both your configuration, installed extra modules, caches and other application specific data, similarly as applications like Firefox do it.

Instead of reinstalling NetBeans shutdown the IDE, delete the userdir and re-run NetBeans. It will recreate the userdir. You need to choose the correct userdir according to your version (e.g. 4.1, 5.0 or dev for development version). Note that you may lose your configuration, so it pays of to backup the userdir just in case, but except for installed modules I can't think of other important data, other than it may take a while to reconfigure the IDE. If you want to delete just the cache (because parsing went crazy or became slower), delete only /var/cache.

Some people might think that sharing this kind of information is not good - basicly I'm admiting that things can go wrong. Well, this happens, no hardware or software is perfect, so my take is that if we can help our users recover from the issues, let's help them. Majority of them won't have to deal with this anyway, but it can help those who will have to.

Úterý XI 08, 2005

NetBeans Quick Tip #17 - Faster Building of Projects with Dependencies



Last time I wrote about using dependent projects. I mentioned one drawback of using them: slower compilation time. There's a way to avoid it, you can choose in the main project's properties that the other projects do not get built automatically. Then you need to rebuild them manually when you do changes, but your compile time is again short.

To achieve this, just uncheck the Build projects on Classpath checkbox in Libraries section of project properties:

Neděle XI 06, 2005

NetBeans Quick Tip #16 - Using Dependent Projects



One NetBeans user asked me recently by e-mail when will NetBeans support dependent projects. So I replied how to define dependencies and asked if he wanted more from this features... and the reply was no, he just didn't know that the feature exists! So here's a tip for people who didn't find it yet, hopefully easily accessible via Google (which puts texts from blogs on top of search results).

Why would you want to use dependent projects? If your project gets big enough it is a good idea to divide it into smaller projects. By dividing them this way your code can be better structured by separating logical parts into individual projects. However if you do this, you need to define in first project how to access classes from the second project.

For Java SE projects this is quite straightforward, go to properties of the main project (right-click on the project and choose properties). Go to the Libraries section and choose Add Project. Now you need to find the project folder on your disk and by selecting it, the project's jar is added to the compile classpath:


If you compile the main project then all dependent projects are checked if they are up-to-date and any updated classes they contain are compiled as well.

There are other advantages of having dependent projects, especially if you work in a team, it's handy to have the projects divided than to work on one big project, because people can work on each of them separately. The only drawback I know of is that speed of compilation is slower if you divide your projects too much and define too many dependencies, then compiling the main project takes longer because NetBeans has to check status of all dependent projects.

Note that for NetBeans plug-in projects the dependence mechanism is quite different - either you depend on one of the NetBeans modules or you define dependence on an external library.

Pátek X 07, 2005

NetBeans Quick Tip #15 - Adding Multiple Components with Matisse



During my Matisse demo in Javalobby expert presentation I used one trick I'd like to share with you. Thanks to William Beebe for pointing out this is harder to discover.


You can use the Shift key to place multiple components into the form. This way you can insert many components of the same kind without having to go to the palette and back. It's a small tip, but may save some mouse movements. We are all lazy to some extent, aren't we? ;-)

Čtvrtek X 06, 2005

NetBeans Quick Tip #14 - Accessing Files Outside Projects



Note: this is rather a tip for beginners, so people who know Favorites view can skip it.

From time to time it is useful to have access to files which are not a part of a project. I for instance use NetBeans to update the HTML pages on the netbeans.org website. Obviously, these files are not a part of a project, so how to open them? Simply use the Favorites view.


Favorites View

Favorites view is useful when you want to quickly open a file and take a look at it contents or for editing of files which do not need building, such as HTML. It can give you access to files which are not a part of your project. Although you can use multiple source roots in the projects view, it may not make sense for all types of files so favorites view can be used to add, view, modify or delete any kind of file anywhere on the disk.

Favorites view is not visible by default in the explorer, you can open it from the Window menu or by pressing Ctrl-3. Root of a new favorite directory is added by right-clicking in the favorites view. These roots are remembered accross sessions so you need to add them only once (unless you change the userdir).

Čtvrtek IX 15, 2005

NetBeans Quick Tip #13 - Define a Shortcut for Ant Target



Did you know that it's possible in NetBeans to define easily a keyboard shortcut for an ant target? Just add your custom ant target to build.xml (through Files view). When this file is opened you can see the list of all targets in navigator. You can right-click on any of these targets to define a shorcut:


When you invoke the shortcut, the corresponding ant target is executed. So you can take advantage of ant's power by pressing a single key combination. Similarly you can add a menu item or a toolbar button for the ant target:


Tight integration of NetBeans with ant is a great thing, notice how many things are possible - Geertjan has in his blog a huge collection of tips how to (mis)use ant integration.

Ah, I just noticed that Geertjan already blogged about defining shortcuts for ant targets. I'm not original this time.

Čtvrtek IX 01, 2005

Netbeans Quick Tip #12 - Fast Navigation to Methods and Fields



Well this tip is not from my head (thanks Gregg ;-)... You can navigate very fast to a method in source editor by following these steps:

1. Press Ctrl-7 to get focus to navigator.
2. Type in first letters of the method, e.g. "ma" for main.
3. Press enter -> now you are moved to the beginning of the method.

A nice small time saver - you don't need to use the mouse to scroll down or search for the method or field.

Středa VIII 31, 2005

NetBeans Quick Tip #11 - How to Save As...



There is no Save As... action in NetBeans. But there are (at least) two ways how to perform this action:

1. Copy and paste in projects view: Choose the file you want to save as something else and press Ctrl-C. Then go to the package right above this class and press Ctrl-V. Voila, a new file appears and you can rename it through Refactor->Rename. Not very elegant but works like Save As...

2. Second way is to download experimental refactorings from development update center. Then you can execute Refactor->Copy Class from context menu, choose new name and a new class is born. This way is definitely more elegant.

Both ways use refactoring, thus the new class remains compilable which I think is an added value over the usual Save As... action.

Čtvrtek VII 14, 2005

NetBeans Quick Tip #10 - Diffing Two Files



Did you know that NetBeans has built in diff which you can use to see differences between two files? Most people know the diff view from versioning support. Hovewer you can diff files even if you are not using versioning. The trick is that you have to select two files in the Projects view, invoke context menu and go to Tools | Diff. The submenu appears only if you select two files, otherwise it's perfectly hidden so that only experienced users can find it :-)

Here is a screenshot of the diff view:


Graphical diff in NetBeans

Wondering about the history of diff? See the entry in wikipedia.

Pondělí VII 11, 2005

Quick Tip #9 - Better Responsivenes of Error Marks and Hints



I've seen in one of the web discussions somebody complaining that NetBeans editor is not enough responsive when errors in code are being marked. Well, there's one option which can make things work much faster:



The magical option is Tools | Options | Editing | Java Sources | Automatic Parsing Delay. It sets how long should the IDE wait before the sources get parsed. The default value is 2000 ms and to make error marks faster I've changed it to 500 ms. Why is the value higher by default? Parsing the sources takes quite a lot of CPU cycles and if it would be too small NetBeans could have performance problems on slower machines. The parsing is activated after defined time of no activity and you certainly don't want to run the parser after every keystroke. You can tweak this option depending on your hardware - if you have a really fast CPU you set a smaller delay and get better responsiveness.

This option influences the following features:
  • speed of marking of red error "X" signs in editor gutter
  • speed of error underlining of lines containing errors
  • speed of error stripe (downloadable from update center)
  • speed of editor hints aka quick fixes (downloadable from update center)
Use this option cautiously and don't complain to me that the IDE takes too much of your CPU if you set the value too low. I will be able to use a short delay because this beauty is now being installed for me.

Pondělí VII 04, 2005

NetBeans Quick Tip #8 - Using Custom Folds



I have a friend who is a vim fanatic. You recognize his code by seeing many {{{ and }}} strings all over the sources. These strings are used to define custom folds in vim. They're just everywhere, it makes the code much less readable in other editors. Well, isn't this a typical example of user lock-in? ;-) If you're not using vim, sorry, your eyes have to skip all those {{{s.

Anyway, obviously folding seems to be an important issue for some of the people. Today's NetBeans tip is for all folding deviants. Did you know that next to usual NetBeans folds you can define custom folds? Maybe you've mentioned it in J2EE classes or in Swing forms, but in case you didn't here's a short explanation.

To add your custom fold, use following piece of text:

// <editor-fold>
   Your code goes here...
// </editor-fold>

You can define default description of a collapsed fold like this:
// <editor-fold desc="This is my super secret genius code.">
   Your code goes here...
// </editor-fold>

You can set a fold to be collapsed by default this way:
// <editor-fold defaultstate="collapsed">
   Your code goes here...
// </editor-fold>

Happy folding!

Středa VI 15, 2005

Quick Tip #7 - Macros in Editor



As promised, today's tip is about macros. What are they? These are actions which are recorded according to what you do in the editor. Depending how good you are, you can create even such action such as surround with try-catch, comment a piece of code, etc.

You can record the macros by pressing the red button in editor toolbar, perform the actions and then end recording by pressing the grey square next to the button. Then you name the macro and assign a shorcut to it. To execute the macro, you just need to press the shortcut you've assigned.

Michel Graciano from Brazil has prepared some great macros and you can download them here. Similarly to abbreviations the content of the zip should be placed into the directory ~/.netbeans/4.1/config/Editors/text/x-java. Make sure to backup all XML files this may replace. The abbreviations in abbreviations.xml are necessary to execute the macros (they contain few more than last time), the keybindings.xml file sets the shortcuts. Macros.xml file contains macros recorded by Michel.

Here are the available macros:

ShortcutAction
Ctrl-J ISurround with if()
Ctrl-J TSurround with try-catch
Ctrl-J LAdd debug code
Ctrl-N PCreate property
Ctrl-J {Add a block
Ctrl-J HComment code
Ctrl-N FDefine identifier by previous class
Ctrl-N SDelete two words
Ctrl-J CTrim
Alt-U QToggle case of identifier
Ctrl-J [Format code
Ctrl-J DDebug variable
Ctrl-J FAdd editor fold


Most of these macros require to have selected a piece of code in the clipboard. You may not use all of these, but they're a good source of inspiration for creating your own macros. Actually this way you can add simple features to your IDE. How cool is that? :-)
About

Roman Strobl

Search

Archives
« duben 2014
PoÚtStČtSoNe
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today