# Quicktip: Search for Maven artifacts from within NetBeans IDE

Open the context menu of the Maven Repository node in the services and start your search!

# Quicktip: Maven-based NBM development and the user-dir

When you develop a NetBeans module using the Maven-approach, every time you “Clean & build” your module the userdir, which is placed in the target-directory by default, will be deleted. “Clean & Build” is necessary if you’re altering the layer.xml directly or indirectly by using annotations like @ActionReferences.  So after that you have to reconfigure your target platform again, f.e. by opening the same projects and files to restore the previous state. That is annoying, but easy to fix.

<profile>
<id>userdir</id>
<properties>
<netbeans.userdir>../userdir</netbeans.userdir>
</properties>
</profile>


After that you can choose the profile from the profile-dropdown or in the context-menu of the project node.

This way the configured userdir is used for running/debugging your NetBeans module. It won’t get deleted automatically.

Advanced tips: Of course you can also configure an absolute path or even make the profile default by applying activeByDefault

<profile>
<id>userdir</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<netbeans.userdir>/home/user/myuserdir</netbeans.userdir>
</properties>
</profile>


# Quicktip: How to display your own Java code-templates in the code completion of NetBeans IDE

After blogged about How to display your own PHP code-templates in the code completion of NetBeans IDE a NetBeans user asked me how it works for Java code.

Yes, it is possible and it is even simpler. Since NetBeans 7.4 (issue #160771) you can define the context, where code-template has to be shown. Don’t be overwhelmed by the available contexts. For completions within a block/method choose BLOCK.

# Quicktip: How to display your own PHP code-templates in the code completion of NetBeans IDE

Here a small tip for all the PHP developers, which want to see their code-templates in the code-completion list of NetBeans IDE.

1. First create your own code template in code-template options at “Tools|Options|Editor|Code Templates” and save the options.
2. Then open the code-templates file from your NetBeans user dir. For example: c:\Users\johndoe\AppData\Roaming\NetBeans\8.0.2\config\Editors\text\x-php5\CodeTemplates\org-netbeans-modules-editor-settings-CustomCodeTemplates.xml This XML file contains all your custom template settings for the given mime-type.
3. Search for your entry and add contexts="php-code" to the <codetemplate>-tag and save it.

This way the template will be displayed in the code-completion list too.

When it looks like this

 <codetemplate abbreviation="ech" contexts="php-code">
    <code><![CDATA[echo "\${cursor} it works"]]></code>
 </codetemplate>

it will work like that.

If you like to have a option for that in the UI the NetBeans IDE itself, then please file an issue at https://netbeans.org/bugzilla -> Not needed anymore. See the update below.

UPDATE:  In the next version of NetBeans IDE (>8.1) no fiddling in files is needed anymore. Thanks to junichi11, who provided a patch to solve this via issue #246664 . The context can be set in the new context tab within the code-templates options.

# NetBeans: Quicktip: Open project for open file

A very useful feature of NetBeans is to the project for an opened file.

Imagine the following scenario: You searched for content in java files using the file explorer (or other indexing tool) — instead of opening all projects and using the file search of NB. You open the file directly in NetBeans by copying its full absolute path and pasting it into the “File-> Open File” dialog.

Now you want to open the surrounding project for several reasons.

• You could open the project manually OR
• even easier invoke the action “Navigate->Select in Projects” from the menu bar (or the corresponding shortcut). Now a dialog opens (if a project can be found for the file) and asks for permission to open the project.

Very neat and useful.

# NetBeans 7.2: Hint/quicktip for resolving missing dependencies

In NetBeans 7.2 there is a cool hint within maven projects, which allows you to search for dependencies when a class dependency is unknown.

But wait. The hint can be configured too. I optionally searches in your maven repos and shows you all matching gav which may contain the requested class. Cool stuff.