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

Thursday, October 07, 2010

Java2Days Sofia Day 1 (part1)

11Here I'm going to blog my thoughts about the sessions:

9:30 - 0. Introduction

The introduction was translated live in both English and French by two girl-students. :) They were kind of shy and inexperienced but it was funny to watch them.

Unscheduled introduction by a dude from Oracle forced the Vitosha schedule to be 30 minutes behind the other xxx2Days presentations... Great organization ...


10:00 - 1. Java EE 6 - why and how J2EE became popular again

Regarding JEE6 the new Oracle employee Alexis Pouchkine said that NetBeans is the best for JEE6 development today. Eclipse is still behind. Go go, NetBeans!

Expect more annotations in JEE6.

Ruby developers don't create applications much faster than Java developers anymore. Just 5-10% faster.

JEE6 compliant application servers are : Glassfish, Oracle's WebLogic, and a few more.

He's making a comparison between JEE5 and JEE6. JEE5 was all about making the development faster and easier, but JEE6 includes a lot of new features.

Detailed explanations for
- JAX-RS
- Bean validation
     - something like assertions with annotations for fields of beans - @Valid annotation makes validation recursive
     - you can create your own validation annotations
 - Web Profile
 - CDI - very interesting annotations for defining exact implementations and validations etc... Interesting code samples

Expect JEE7 with cloud features. If I can suppose right, I expect Java7 features as well :) That means we won't see it for another 2-3 years.

(next-page)

Sunday, July 11, 2010

Idea: JUnit and Code coverage connection

I'm going to share my first thoughts regarding unit testing, JUnit and TDD (test-driven development). I'm sure that this won't be the last post on this subject because there is a lot that can be said and I've had a few interesting discussions with a colleagues of mine regarding the benefit of TDD and whether it is a good or a bad principle.

---

Here I'm going to share a thought which seems logic to me, but unfortunately have not seen it implemented yet.
I've been writing some unit tests recently and  it occurred to me that it would be nice if the JUnit was combined with code coverage and after runs of the test suites, there is a statistic that shows which test (test method), which lines of code did they cover!

Imagine if it was possible to see that - when an old test fails, it shows you which particular code it validates, so if a change in that code occurred, you can catch it immediately!

Of course there is the scenario when a change occurred in the context of the process that is tested and not the process itself and the code that could break a certain test, but nevertheless this information won't lie to you and trick you and slow you down in rooting down the real problem.

Also some monitoring of the submits to the project repository and analyzing which code fixes what test , would be the same as which test validates which lines of code.

There could be done something about that!


----
Some basic tips:

For NetBeans users check this link:
http://netbeans.org/kb/docs/java/junit-intro.html

Check official xUnit site or Junit
http://www.junit.org/

L.K. 

Sunday, June 20, 2010

NetBeans plugin Code Coverage "interesting" behaviour

I decided to test the plugin for code coverage for NetBeans. Created an empty test method, activated the plugin, ran the tests and when I ask for coverage statistics it said I had not ran my tests...

I lost an hour looking for the cause of this problem but at the end all was pretty innocent...

Once I implemented some actual methods and not juts an EMPTY test method , and at least 1 line of code was invoked the statistics appeared and everything was fancy and flashy and showing some numbers...

So remember - it's not the problem in your plugin! It works... (except for single test files ) but when you run all tests, it works as nice as a baby soft skin :)

L.K.

NetBeans 6.8 ME removal leads to unusable NetBeans

I had installed NetBeans 6.8 the version where all possible java technologies are bundled together.

I had no problems, but I decided to deactivate and uninstall the ME plugins... huge mistake.. The whole NetBeans became an empty shell... with just a few menus to the top and a simple editor... I was greatly surprised.

The good thing is that I installed NetBeans 6.9 and it sniffed my NetBeans 6.8 and imported all projects, copied the configurations and even the plugins... And in just 5 minutes a could continue with my work having all my configurations, no need to configure all my custom changes all over again.

So in just 30 minutes I was surprised twice by the NetBeans - the good thing is that in the end everything is working how it is supposed to be working. :)

I suppose this is something that Еclipse lacks...

//later edit:
- different Eclipse installations can share configuration with the Workspaces

Monday, May 24, 2010

JDK 1.6 installation problems

Today's topic is Java Developers' Kit.

I've had a peculiar problem with JDKs.  I wanted to install the latest version of JDK 1.6 update 18 at the time, but I also wanted to have JDK 1.5 so that I test my application with different compilers and runtime environments.

However there was some sort of problem with it (the source of it, I am unaware till this day) that caused my Windows  unable to detect my successful installation. I checked that on this special site java.com

I could also check it with an applet in a page - it said that I need to install java...

1. First idea - reinstall
I thought that my register was messed-up and ran CCleaner to clean it. That didn't help.

I decided to reinstall it and here's my first surprise:
After the successful uninstall and running CCleaner again (just to be sure), and decided to reinstall the JDK
I've got a very "funny" error message (something like this - I don't remember the correct caption):

"Installer has detected that you have JDK installed. Do you want to repair/reinstall it?"
If you click NO - the installer shuts down.
If you click YES - the following message appears:

"You don't have JDK installed on your machine!"

Holly shit ! Isn't that just a bit contradicting...

Obviously, the algorithm at the beginning isn't the same as the one at the end...

2. Second idea - install older version
OK. I cannot override this incorrect installation. So let's try to downgrade it a bit.
I decided to try JDK 1.6 update 17. When I run it it said:

"You have already installed a higher version of JDK" - installation finished!

Thank you very much, smart installer!

3. Third idea - ask Google
"OK stop trying to be a smart ass. There has to be somebody with the same problem that has a solution!" 
 was my thought.
Yeah, right... After many hours of searching and "smart solutions", none of them helped me.
I intend not to list them here... just too many and very customized...

One of them seemed promising to me.
Google helped me find a tool and step-by-step solution.

4. Forth idea - clean up registry 
I absolutely had no other choice than to try and clean my registry.

Including backing up my registry and using a free tool called "JavaRA"  that could help me maintain my system and Java versions and updates very well... well I tried it and it didn't help... I was very disappointed but maybe my expectations were just too great.


5. No idea - desperation
I was quite desperate that my JDK ws not correctly installed. My applets weren't working. Eclipse stopped working at a certain moment. NetBeans - too. I even had to use system restore... a total disaster.

And I just migrated to Windows 7 Pro 64bit version... which seemed nice for user but apparently not for JAVA users... Using Win XP I didn't have such problems (although I think I had a similar problem a few years ago).
...
but I had a workaround!!

6. The workaround  - JDK 1.7 unofficial!
Well, I was lucky I accidentally installed JDK1.7 which is still unofficial and doesn't overwrite the latest JDK 1.6. So when I installed and played around with PATH and JAVA_HOME variables and Eclipse and NetBeans configurations, I was able to continue with my Java project development.
But I was still unsatisfied, because this is just a workaround !

A developer must never be satisfied with a mere workaround!

Wednesday, May 19, 2010

NetBeans 6.8 bugs

Today I'll comment my favourite IDE for Java development - NetBeans.

Some may say that I'm a newbie and like less complicated IDE or that "true Java developers" use Eclipse - OK so be it, but I'm working on Eclipse at work and at home I'm using whatever I feel like using and NetBeans is what I like using!

So I've recently found a few bugs while developing a small application.

1. Swing forms editor bug

NetBeans is popular with its very well-made Swing UI editor and I agree with common understandings. UI forms are easy to use, can be configured in lots of ways (some of which I haven't tried yet), but satisfies my needs completely. It generates some code and locks it , so that future UI replacement/movements are still consistent with the rest of the class you are managing. Easy event handling methods and so on...

But I've had a few places I wanted to manipulate and configure the initialization of the components. NetBeans automatically creates a constructor with "init();" method call in it , but my case required to modify this init() method.

So you can click on the JComponent and click "Customize code" , which lets you modify the constructor called but not the declaration! I found this very restrictive and tried to trick NetBeans.

I had to change the place of a class from package "a" to package "b", but if I cannot change the declaration, I'm stuck. So I decided to use REFACTOR rename on the package of the problematic class. And it worked! ...
at first...

I refactored the name of the package and no problem in the UI created code.
But if you try to move 1 pixel of the UI form , it regenerates again the locked code and refreshes the metainf. xml in the netbeans project and my IDE shows an error of non-existing class/package...

I'm going to report this and get it fixed in NetBeans 6.9.

2. Main class in built .jar is missing

The next major bug I've found is already reported. I even reached the helpful guys in www.stackoverflow.com
You can find my question here ->  Main class in NetBeans bug

I'll rewrite the short description here:

You create a Java project in NetBeans 6.8 or 6.9 and build it to create a .jar file.
Even if you have set in the project settings which class contains the main() method to be executed, the build omits this configuration in the meta-inf/manifest file  after build and so the .jar is not executable.

This is easily fixed by :
- creating a metainf.mf file in root of your project
- the file contains something like

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 16.3-b01 (Sun Microsystems Inc.)
Main-Class: com.example.MainClass
Class-Path: lib/lib1.jar lib/lib2.jar


- editing the nbproject/project.properties  file
- add manifest.file=manifest.mf
- save and rebuild

This solved my problem and thanks a lot to the NetBeans and stackoverflow society so quickly.

L.K.