You are here:Home»KB»Programming»My Netbeans Notes
Sunday, 04 May 2025 07:19

My Netbeans Notes

Written by

Add a custom file extension to Netbeans

I am trying to figure out how to add a custom file type to be recognised by Netbeans.

I am editing .tpl files and I would like them to be recognised as PHP/HTML files.

Solution

  1. Open preferences.
  2. Select Miscellaneous tab.
  3. Select Files sub-tab thing.
  4. Click on New file extension and enter tpl.
  5. Select the mime type.
  6. Click ok. Done!

Coloured background in tpl cannot be turned off

  1. go to Tools -> Options -> Fonts&Colors
  2. choose language 'Smarty Templates'
  3. choose Category 'Background'
  4. you can change colour to your one or choose 'Inherited'

This option will use default editor colour, so no colouring any more.

Cannot find java.exe in specified jdkhome

If you upgrade your Java SDK, the NetBeans IDE may give you the following error message (Invalid jdkhome specified) at startup:

Cannot find java.exe in specified jdkhome.
Neither C:\Program Files\Java\jdk1.6.0_10\jre\bin\java.exe 
    nor C:\Program Files\Java\jdk1.6.0_10\bin\java.exe exists.
Do you want to try to use default version?

This can be corrected by manually editing the netbeans.conf file found under:

%PROGRAMFILES%\NetBeans 6.5\etc

Replace the line netbeans_jdkhome with the correct path information. Alternatively, you can comment out the line entirely with # and NetBeans will use your default JDK, through JAVA_HOME.

Netbeans - doesn't match expected UUID

In Netbeans using SVN Subversion you get the following error when you try and sync/checkout files.

svn: Repository UUID '1a063a9b-81f0-0310-xxxxx etc' doesn't match expected UUID '7be80a69-xxxxxx etc'
(I've xxxxx'd out some of the UUID numbers in case they were sensitive in nature)

Notes

  • You can't switch from one repository to another. You will have to check out WordPress 3.0 and overwrite your SVN.
  • that you have to backup the custom directories (themes, plugins etc) and then do a new install. So deleting all the existing files/directories and doing a new CO with the WP 3.0 code.
  • The --relocate flag is used to relocate a SVN to a new URL, but it must be the same SVN repo. A SVN has a GUID and the GUID has to be the same at the new location as the GUID at the old location.
  • Files in a local repository have a reference stored in their .svn file, the GUID. These GUID must match those stored in the remote repository. Sometimes they can become mismatched causing this error.

Solution

  • Backup files in your local repository
  • delete all the files including hidden ones from your local repository
  • checkout files again using SVN Subversion.
  • swapped any files that had not been updated and they will then be reflected in the remote repository and a checkout is run again.

My Preferred Netbeans Settings

This will be a collection of preferred settings for netbeans. This will prevent me hunting to change that one setting for that annoying feature.

Disable mysql auto closing

When you press return/enter to split SQL statements, Netbeans automaticlly closes the statement and then re-opens it. This makes the code evern messier.

options --> editor --> code completion --> PHP language --> disable 'Use String Auto-Concatenation after Typed Break'

Netbeans Search

Search is not working

  • make sure there is nothing in the 'File Name Patterns' box
  • mark text can cauyse some issues so go to options->editor->marked occurances, then off/on
  • reboot netbeans
  • make sure you have the correct scope selected

Regex search

These are some examples of searches in netbeans using a Regex pattern

So i want to change some <input> tags.

<input .....>
to
<input ..... />

 The following will search for all <input strings that do not terminate in />

Search String:
<input(.*)([^\/])>

Replacement String:
<input$1$2 />

However this does not take into account of whether there is a space at the end so I need to do another search for:

<input(.*)({space}){2}\/>  - needs finishing

Notes

  • ^ is a 'not' character when within []
    [^\/]

Netbeans, Subversion and Windows 7 64-bit…

A minor issue is that the built in Netbeans Subversion integration doesn’t work in a 64-bit install. It helpfully provides a link to the Subversion client software at CollaNet, however the most recent version for Windows is v1.5.5 which isn’t a lot of help if you are using Subversion 1.6.x.

All is not lost though, slik subversion provide a free command line Subversion package in both 32-bit and 64-bit versions. This installed without any problems and all that is required is to set the ‘Path to the SVN executable File:’ in Netbeans to C:\Program Files\SilkSvn\bin .

 netbeans-settings

GitHub

Here I will give the basic instructions on how to use GitHub with Netbeans. I can be confusing at the beginning but does get easier.

  • If you checkout a project first in Netbeans it will ask you if you want to create a project
  • If you split metadata and files it keeps prompting/prefilling with meta location
  • If I use meta data in same folder, what happens 1 folder I can exclude (Netbeans automatically excludes the Netbeans meta folder via the gitexclude.git file)
  • Once a project is checked out the extra functions are available (via menu) for uploading changed etc..
  • If you leave metadata in the same folder as your project it adds a [.gitignore] file and a nbproject folder which I think gets ignored.
  • Keeping the meta data in the project folder is better for allowing you to move and managed projects easier.

Clone rep

  • Clone the repository to the required location
    • (Team/Clone) i.e. to your local webserver root directory
    • Git repository URL is from github and easy to find
  • Select MASTER only
  • Clone
    • You have the option of netbeans checking to see if there is a project for this repository and if not gives you the option to create one.

Create project

Keep files in the project folder

Other

  • A Netbeans tab adds 4x spaces into the code, not a tab character, but interprets 4 spaces as a tab (this is the professional way to do it and maintains code layout between software)
  • In MyITCRM, the smarty stuff is tabbed in using the tab character causing it to look funny
  • Notepad++ can swap tab button behaviour to spaces in preferences/tab settings = Replace by space, leave as 4
  • Professionals say use spaces and not tab character because of formatting issues
Read 59 times Last modified on Sunday, 04 May 2025 07:26