NetBeans 6.7 finally released

Since today the final version of NetBeans 6.7 can be downloaded here. And do not forget to look here for a feature overview.

If you tried the release candidates of 6.7 you will welcome all the new features! Great work! Where can we donate?

The first impressions of this release for me as a NetBeans user are:

  • seems to use less memory
  • imported the settings of 6.5 with no problems
  • you can now simply install plugins of a previous installation. this is especially useful if the plugin is not available from the update center.
  • maven is now integrated (no need to install it as plugin)
  • you can view maven dependencies graphically (like eclipse already had). See below. And: there is a new button “Build with dependencies” in the right-click-on-project-menu.
  • interrupting maven execution is now possible
  • now test cases execute a lot faster for mavenized projects
  • executing one test via CTRL+F6 instead SHIFT+F6, so that you can execute the corresponding test even if only the java class file is open. (CTRL+SHIFT+F6 for debug test file)
  • all tests (java, ruby, …) happen in the same tab and several search tabs are possible now
  • if you open a resource with ALT+SHIFT+O a case insensitive string now works a friend told me that this was already the case for him earlier than 6.7 … hhmhh …
  • Synchronize Editor With Views -> “The project explorer will then snap to the file currently being edited” (taken from here)
  • some small issues remains:
    • cannot open the source file if you click on the failed test output (and only if you execute the tests of one project)
    • if you miss a static import e.g. import static org.junit.Assert.*; the auto fixing does not add this.

Unit tests

nb6.7-unit-tests

Maven dependencies

nb6.7-mvn-dependency-graph

But the cool thing here is that clicking e.g. on spring core shows you all the possible paths to it and grays out all the unimportant

nb6.7-mvn-dependency-graph2

see some comments on JavaLobby

hibernate.cfg.xml settings for derby, oracle and h2

GraphHopper – A Java routing engine

karussell ads

It took me some time to collect the hibernate.cfg.xml data which is necessary for derby, oracle and h2. So here are the default settings for those databases:

  1. Apache Derby (network)
    You start the network server and specify the following options in the script:Linux: DERBY_OPTS=”-Dij.driver=org.apache.derby.jdbc.ClientDriver -Dij.protocol=jdbc:derby://localhost:1527/ -Dij.user=admin -Dij.password=admin”
    Windows: set DERBY_OPTS=”-Dij.driver=org.apache.derby.jdbc.ClientDriver -Dij.protocol=jdbc:derby://localhost:1527/ -Dij.user=admin -Dij.password=admin”

    <property name=”hibernate.connection.driver_class”>org.apache.derby.jdbc.ClientDriver</property>
    <property name=”hibernate.connection.url”>jdbc:derby://localhost:1527/databaseName;create=true</property>
    <property name=”hibernate.connection.username”>admin</property>
    <property name=”hibernate.connection.password”>admin</property>
    <!– no schema necessary –>
    <property name=”hibernate.dialect”>org.hibernate.dialect.DerbyDialect</property>

  2. Oracle (thin)
    <property name=”hibernate.connection.driver_class”>oracle.jdbc.driver.OracleDriver</property>
    <property name=”hibernate.connection.url”>jdbc:oracle:thin:@host:1521:databaseName</property>
    <property name=”hibernate.connection.username”>YOURSCHEMA</property>
    <property name=”hibernate.connection.password”>YOURPASSWORD</property>
    <property name=”hibernate.default_schema”>YOURSCHEMA</property>
    <property name=”hibernate.dialect”>org.hibernate.dialect.OracleDialect</property>
  3. H2
    <property name=”hibernate.connection.driver_class”>org.h2.Driver</property>
    <property name=”hibernate.connection.url”>jdbc:h2:path\databaseName</property>
    <property name=”hibernate.connection.username”>sa</property>
    <property name=”hibernate.connection.password”></property>
    <property name=”hibernate.default_schema”>PUBLIC</property>
    <property name=”hibernate.dialect”>org.hibernate.dialect.H2Dialect</property>

To make it complete here are the maven settings for the databases:

  1. Apache Derby (network)
    <dependency>
    <groupId>org.apache.derby</groupId>
    <artifactId>derbyclient</artifactId>
    <version>10.4.2.0</version>
    </dependency>
  2. Oracle (thin) no public version is available but you could install the jar file into your local repository or into an archiva repository via:
    mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.1.0.7.0 -Dpackaging=jar -Dfile=/path/to/file<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc6</artifactId>
    <version>11.1.0.7.0</version>
    </dependency>
  3. H2
    <dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    <version>1.1.102</version>
    </dependency>

Thank You for Your Interests!

Thanks for your attention and comments the last months! Hope you will enjoy the next months …

I started my blog in November 2007.  Now, May 2009 was the first month with more than 5 000 users (and even over 6000 -> 6080).

The monthly statistics looks a bit like the physical phenomena called ‘Maker-fringes’:

Stats:

stats-2009

Maker-fringes:

maker-fringes-gemessen

In my diploma thesis 2 years ago I studied this phenomena in detail.
BTW: this fancy 😉 picture I got with my performant Java genvlin plotter.

Code Quality Tools in Java

There are several tools to measure the code quality of my free timetabling software TimeFinder. Here are the tools I tried with success:

  • FindBugs (latest version 1.3.8) – uses static analysis to look for bugs in Java code. This is a great tool, it discovered possible NullPointerExceptions and a lot more bugs in my projects. Sometimes I asked myself how this program could have discovered this ‘complicated’ bug.With the maven plugin you can do:
    mvn findbugs:findbugs

    which will use version 1.3.8 out of the box

  • PMD (latest version 4.2.5) – scans Java source code and looks for potential problems. The rules are configurable, but at the beginning you will only need the provided one (and spend a lot of time to choose your favourites ;-))In NetBeans 6.5 this tool is well integrated and works like a charme (CTRL+ALT+P).With the maven plugin you can do:
    mvn pmd:pmd

    after you specified the following in the pom.xml under<reporting> <plugins> :

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-pmd-plugin</artifactId>
      <version>2.3</version>
      <configuration>
        <targetJdk>1.5</targetJdk>
      </configuration>
     </plugin>

Other tools could be

  • JarAnalyzerIs a dependency management utility for jar files. It’s primary purpose is to traverse through a directory, parse each of the jar files in that directory, and identify the dependencies between the jar files.
  • HammurAPIa code quality governance platform

but I didn’t tried them so far.

For Findbugs  and pmd there is a NetBeans plugin (SQE … software quality environment) which looks promising, but fails with a NullPointerException after I installed it via the update center and tried it on my project. Maybe I should use one of the snapshots. (BTW: I successfully used the pmd-plugin and findbugs in the standalone version).

Sonar is another interesting approach to use several code quality tools at a time. With Sonar it is possible to see the violations or possible bugs over das or weeks  – so, you are looking at the improvements and you will not get lost in the mass of bugs at the beginning. Another “multi-tooling” project is XRadar.

A little bit offtopic, but a great tool is proguard, which shrinks, optimizes, obfuscates and preverifies Java class files. There is even a maven plugin for that.

Microbenchmarking Java – Compare Algorithms

Have a look at this presentation where this post is presented as pitfall #3 !

Lesson learned. See comments 🙂

There are a lot microbenchmark tips out in the www. The intent of them differs from author to author.

Today I want to show how you could compare e.g. different algorithms. You could simply do:

int COUNT = 1000000;
long firstMillis = System.currentTimeMillis();
for(int i = 0; i < COUNT; i++) {
  runAlgorithm();
}
System.out.println("Mean runtime of algorithm in seconds:"+(System.currentTimeMillis()-firstMillis) / 1000.0 / COUNT);

There are several problems with this approach, which results in very unpredictable results:

  1. Make sure the variable COUNT is high enough (if runAlgorithm() is unexpensive). Then make sure you run this code several times. Additionally you should measure the RMS either for each runAlgorithm call or at the end of this code snippet for a better comparison with other algorithms.
  2. You should turn off the JIT-compiler with specifying -Xint as a JVM option, otherwise your outcome could depend on the (unpredictable) JIT and not on your algorithm.
  3. You should start with enough memory, so specify e.g.-Xms64m -Xmx64m. Because JVM memory allocation could get time consuming.
  4. Quit all other applications or at least you should use
    long firstNanos = mx.getCurrentThreadCpuTime();
    ThreadMXBean mx = ManagementFactory.getThreadMXBean();

    instead of

    long firstMillis = System.currentTimeMillis();
  5. Avoid that the garbage collector runs while your measurement: -Xnoclassg
    But make sure you have enough memory!

After this I got relative stable results: The difference of maximal and minimal value for the result is less then 4% after 10 runs.

Further with Maven and WebStart (jnlp)

If you want no server side setup for webstart all your clients must have a java version greater than java6 update 10 (the naming convention gets too complicated now, mr. sun! …)

For ubuntu 8.04 see my last blog entry how to install this java version.

All you need to do in our maven set-up of this post is to add the following 2 lines to our pom.xml:

</sign>
<pack200>true</pack200>
<gzip>true</gzip>

<verbose>true</verbose>

Then do:
mvn clean install webstart:jnlp
again and add one line

<j2se version=”1.6+” initial-heap-size=”32m” max-heap-size=”128m”/>
<property name=”jnlp.packEnabled” value=”true”/>

to our jnlp template.

And as it is described here you could even use the versioning feature
<property name=”jnlp.versionEnabled” value=”true”/>
with a specific naming convention, too:
foo__V1.0.jar

But all only if the clients have java > java6 update 10 …

Start TimeFinder here to try a servlet-free-packed200 application out. With jars it was approx 9 MB. Now all pack.gz files in sum are 3.3 MB! And the download time was approx 160 seconds, where now I downloaded und unpacked it within 40 seconds with the same internet connection. You can try it for yourself via switching the java version e.g. from java6_10 to 6_7 or to java5 (in ubuntu this is relative easy with ‘sudo update-alternatives –config javaws’) But before you have to remove the application from cache: start javaws -viewer, search TimeFinder’s shamrock and remove it. Otherwise TimeFinder would start nearly instantaneous.