Showing posts with label netbeans. Show all posts
Showing posts with label netbeans. Show all posts

27 April 2016

NetBeans hints (edit)

Your first NetBeans project
  1. On the start page click the Learn & Discover tab
  2. Under Demo's and Tutorials select Java SE applications
  3. Start the Java Quick Start Tutorial 
NetBeans 7.4 Developer Guide
If you're searching how to do someting in netbeans just type it in the ... search box, it will not only search in your project,  but also in the online help.
Keyboard shortcuts
  • view, search & change shortcuts: tools => options => keymap
    • You can set the keymap to a profile from another IDE (Eclipse, IntelliJ...) here as well.
  • help => keyboard shortcuts card. The pdf that is shown, lives in
    netbeansInstallDir
    /nb/shortcuts.pdf. 
  • Some additional useful shortcuts:
    • Go to
      • to definition: CTRL click
        • to implementation: CTRL ALT click
    • Edit
      • Code completion
        • autocomplete popup (+ javadoc): CTRL SPACE
        • javadoc inline popup: CTRL SHIFT SPACE
          • ALT F1 to see in browse
          • Netbeans bundles plenty of javadoc you can browse supplied javadoc for your project libraries from help>Javadoc references
        • complete to recently typed word: CTRL k
      • Add semicolon at end of line:  CTRL ;
      • Add new line below + go there: SHIFT ENTER
    • View
      • fold/unfold code: CTRL –/+
      • members/herarchy of current selection: CTRL/ALT SHIFT F12
      • zoom: ALT + mousewheel up/down 
      • editor only: CTRL SHIFT ENTER (>= 7.4)
Running code
  • After you ran a program, and corrected some errors Rerun using the >> buttons.

  • The lighter double arrows below allow you to rerun with different parameters. You can change the arguments you run with in the Ant properties window.
 
  • Similar options are available for (individual) tests.
    • You can also launch an individual test by  positioning the cursor in the method and selecting "Run focused test" from the right click menu. 


Samples
Netbeans comes with plenty of sample projects for you to explore

HTTP Monitor

The server side monitor is enabled by default for Tomcat and can be enabled in the properties of GlassFish. You may have to undeploy/redeploy your webapp for the monitor to show up.
When the server receives an HTTP request, NetBeans will show a window with all request details. It extracts all parameters and stuff for you, but does not show the raw bodies of POST requests. It does not show responses either.
There is also a client monitor. If you use the internal browser (or the NetBeans Chrome plugin) you can use Window > Web > Network Monitor (NetBeans >= 7.4). It does not show all client side traffic but is targeted at in-page initiated traffic (AJAX, websockets) and failed requests.

27 February 2014

Removing an unresolved library reference from a netbeans project

When netbeans (v7) opens a project containing a library that is not in its libraries collection,
it proposes you to resolve the issue by creating this library.
Sometimes you do not need the library that is missing (e.g. because you have another library that you'd like to use instead).
You'd like to remove it, but that option is not proposed.
We'll need to play with netbeans project file to achieve this.

  1. Close the project.
  2. Navigate to the nbproject subdirectory of your project directory.
  3. Make a backup copy of  project.properties, just in case.
  4. Open project.properties and remove references to the library. For example to remove the "hibernate-persistence" library, you'll need to change
    javac.classpath=\
        ${libs.hibernate-persistence.classpath}
    to
    javac.classpath=

10 February 2014

Start Java DB: access denied ("java.net.SocketPermission" "localhost:1527" "listen,resolve")

Since Java 7u51 default network permissions have been restricted, hence Java can not connect to local network sockets by default.
To solve add to $JAVA_HOME/jre/lib/security/java.policy

grant codeBase "file:${java.home}}/../db/lib/*" {
   permission java
.net.SocketPermission "localhost:1527", "listen,resolve";
};
If Java DB (Apache Derby) is installed at another localtion, change the file:/... path accordingly.

Adding the permission line to the global permission section would allow access for all java applications
grant {
 // EXISTING line        // allows anyone to listen on un-privileged ports
 permission java.net.SocketPermission "localhost:0", "listen";
        // new line added
        permission java.net.SocketPermission "localhost:1527", "listen,resolve";
};
 You can also specify port ranges. To allow access to all anonymous ports use
grant {
    permission java.net.SocketPermission "localhost:1024-", "listen,resolve";
};
java.net.SocketPermission JavaDoc

2 February 2014

Netbeans 7.4 and Java 8 preview (update)

The Netbeans 7.4 release candidate is out (update: full release is out now). Here's an overview of interesting new Java features (there's also PHP, C, C++ support) .

  • JDK8 preview support
    • debugger support for lambda expressions
  • Easy browser/mobile switcher

  • client network monitor
    •  In addition to the server side HTTP monitor for some application servers, NetBeans now has a client side network monitor for the internal browser and NetBeans Chrome plugin
  • Pure Editor Mode: View > Show Only Editor lets the editor take the entire NetBeans window, giving you the light feel of a basic editor like notepad++
  • Code completion
    • second CTRL-SPACE completes code one level down the members chain

    • Substring completion (in addition to exisiting starts with string completion)
  • folding
    • code folding shows number of hidden lines
    • folding support in output window (e.g. exceptions in stack traces)
  • JSON navigator and code folding
  • Debugger: go to source code of variable type
  • Lock contention profiling
  • diff between version control branches
  • tooltips of search results show surrounding lines
Here's the complete list

16 January 2014

NetBeans: copylibs doesn't support the "excludeFromCopy" attribute

If you build a NeBbeans 7.4 project in an earlier version of NetBeans you can get this error (Bug 231468)

 copylibs doesn't support the "excludeFromCopy" attribute
To solve this, in your project remove the nbproject/build-impl.xml file.
Next time you open the project in the earlier NetBeans version, the file will be recreated without the new option.

13 March 2013

Netbeans 7.3 comes with JPQL runner

A welcome addition to the new Netbeans release, issued last month:


18 March 2012

NetBeans 7 new features (edit)

NetBeans 7 is approved for release now. Here's a list of new features
  • Remote glassfish interaction
  • Java 7 support
    • Maven 3 support
    • HTML 5 support
    • JSON formatter
    • Git natively integrated
    • JUnit is now an unbundled plugin (Oracle legal had problems with the old CPL license)
    • easy JPA 2 metamodel generation
    The netbeans 7/Java 7/Glassfish 3.1 combination is still a bit flaky though.

        15 July 2011

        NetBeans, Hibernate and JPA2

        When you create a new persistence unit in a standalone NetBeans project, it only proposes Hibernate with JPA1.
        This is because NetBeans bundles an old Hibernate release.
        To work with Hibernate/JPA2, download a recent Hibernate (>= 3.5) and SLF4J (same version as the one used in your hibernate download).
        Add a new persistence library with these jars from the hibernate installation directory:

        • hibernate3.jar
        • jars from lib/jpa folder
        • jars from lib/required folder
        • an SLF4J implementation library from the SLF4J download, e.g. slf4j-jdk14-1.6.1.jar
          • if you are using ehcache there is no need to download SLF4J separately. It bundles  slf4j-jdk14-1.6.1.jar.
        NetBeans (>= 6.9) will recognize the library as a Hibernate/JPA2 provider.

        21 November 2008

        Netbeans 6.5 is out

        Highlights:

        • PHP support
        • better javascript/AJAXsupport
        • better SQL support
        • Groovy support
        • automatic compile on save
        • CamelCase code completion!
        • Support for Windows UNC paths (shared network folders)!
        • slow startup!
        The UML module is still unbundled (and rightly so)