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.

Tuesday, May 18, 2010

Laptop battery preservation tips

I've made some research regarding laptop Lithium-Ion batteries, because I was concerned, that if I don't use it properly, I might damage the battery of my brand new laptop

I've find a few nice resources with plenty of explanation in the Internet but nobody said his/her suggestion was the true thing. So I decided to try a few strategies myself out.

Here's my story and make your own conclusions out of it:

----
I bought a Dell Inspiron 1520 back in 2008 September. It has a 9-cell battery Lithium-Ion.

It was said to be possible to work for 3 hours with normal usage on "power management settings" and I have tried it and it proved to be true. And I wanted to keep it this way for as long as possible.

I mainly use my laptop as a "desktop laptop" and it's constantly plugged to the AC adapter.
  • The idea was to discharge the battery to 30-50% and put it in a cold place (refrigerator) - this way it is supposed to be best preserved for a long time.
I decided to remove the battery and stick with purely AC power, but after a few accidental power cable plug-out ... I decided it's not such a good idea. The UPS feature is essential! 


The next idea proved to be more successful. I've put reminders every 2 weeks to use my laptop on battery only and drop it just under 50% of charge. This is somewhat of an exercise for the battery and it doesn't "forget" how to charge/decharge.
  • I put 2 week reminders in Google Calendar to use laptop on battery only till 50% battery capacity.

CONCLUSION:
I have used this technique for the last 24 months. I'm using these days the laptop more on battery only and it survives more than 2:30 hours. That is with slightly dimmed screen and power settings ON, Windows 7 and wireless put on. I'm using it as if it's on AC power.

So I think this little technique has helped me.
Comparison with a friend of mine using a Sony laptop only on AC power and now he says it manages to keep it on battery for about an hour. What a difference!


Piece of advice:
This strategy helped me, but can be harmful for your laptop and/or battery ! Do this on your own risk!
(I'm obliged to write this... )

L.K.

Sunday, May 16, 2010

Skype timestamp bug

Hello

I will now tell you more about the Skype bug I recently discovered. It's pretty easy to reproduce it.

All you need is a Skype chat conversation that has entries let's say, for the last 15 minutes.
And now you go to your clock time/date of your Windows (haven't tried it for Linux but I guess the result will be the same) and change it 15 minutes to the past.

Now you chat some more! The strange thing you should notice is that your 'new' entries are put between your other chat entries! This happens simply because they are ordered with key the time these entries are made.

So if you are chatting with Skype and decide to play with your clock , you will notice this strange behaviour.

ADVICE:
Don't change your clock settings unless you want your chat history scrambled. The Skype folks should document this somewhere.

L.K.

Saturday, May 15, 2010

Windows 7 Pro 64bit bugs

Hi, again,

I'm sharing my findings regarding Windows 7. I'm using Win7 Pro edition 64 bit, free for the students of my university. I thought that it's very well made and bug-free - all those open beta testing must have improved the new Microsoft OS.
It is indeed very good and a perfect successor of Win XP (I skip the unsuccessful experiment Vista), but I've found a few bugs - some very hard to find, others - hard to miss!

1. Navigation with "Back button" in Control panel.

Basically the case is the following:
- you enter the new Control Panel design - one can see some groups of settings in the center and some quick shortcuts on the left side. If you move your mouse over these links, a hand-cursor appears and if you click them, you are transferred to the corresponding menu.
How to see the bug?
- just click on a clickable content in the window (center part) and you should get to another place in the control panel.
- try to move your mouse over the left section with the quick links.
- click the BACK <-   arrow and you are back to the starting point.
- if you try to point over the quick links on the left again, some of them make the cursor change shape to hand, some of them not!
- if you click on some of these that don't make the cursor transform to hand , you will experience the bug - you are just sent to another menu, which doesn't correspond to the name of what you clicked!!! Absolutely without any reason... You can click XXX menu and get sent to YYY submenu... unpredictable feature is something one must try to avoid as best as possible.
The others that make the hand appear work OK...


2. Connection timeout leads to memory leak.

If you are using LAN network to connect to the Internet and you connect to your provider via PPPoE, you can experience this problem.

If your provider is down, but you try to connect nevertheless, it tells you something like "provider is down, try reconnect in 90 seconds" and the countdown starts...
If you have clicked "Automatic reconnect" on your connection settings, than your OS will keep repeating this for as long as you have setup... and I have set up something like 1000 - how could I predict that something wrong could happen:

- After 30-60 minutes of non-stop redialing, if you check task manager and see resources , you will notice that the process, which manages the redialing is consuming almost 1.8 GB of RAM !!! And continues growing...
Later I saw that the OS became absolutely non-responsive and even the mouse couldn't move... I haven't seen a problem like this for a long time... when you close the process, you can continue with your work, but of course very disturbing... and many nerves were wasted until I found the reason behind this.

My Internet provider had such problems for 2 days straight and I experienced this three times! I am very certain this is the reason. And I have enough RAM - 3 GB is more than enough for Win 7- 1.0 GB is taken up at start up.

CONCLUSION
- I have disabled "Automatic reconnect"
- I don't use quick links on the left, because they don't work in Control Panel (could be so elsewhere too...)
- I have created two bug reports to Microsoft site - no response and I don't expect.

For everybody who wants to report a bug to Microsoft Windows, you can do so here:
http://mymfe.microsoft.com/Windows%207/Feedback.aspx?formID=195
(I've spent quite some time to find this link - use it! 30 minutes now and a few hours in the past)

http://blog.hznet.nl/2009/03/can-i-still-send-feedback-with-windows-7-rc/
try this link - I have not tried this but it could work

So report whatever you see so that Windows 7 is better.
This is valid for every other software that you use!

L.K.

Wednesday, May 12, 2010

Debugging Eclipse

Today I had the chance to debug some functionality in the Eclipse IDE, or to be more precise the SAP NetWeaver Developer Studio customized version of Eclipse.

The main thing about debugging is to setup your environment the right way.
There is configuration.ini file in the main directory of your IDE. Inserting specific parameters allows the NetWeaver DS to be started in debug mode and on specified port.
Then you need to start a debug session as a "Remote application" on 'localhost:port' and you are good to go.

 I managed to do that but I lost some time figuring this thing out :
- better make a copy of your IDE and not debug your IDE with the same one.

What I mean is that you can open 2 times the same IDE and debug one of them with the other but here's the tricky part. If you want to make update to a file in the IDE you want to debug, you will have to shut down both instances and start them up again. And lets suppose you have to change not 1 file but a few files, and not just 1 time, but a few times... and then you have wasted your time.


Personal advice - make a separate copy of your IDE and use it for DEBUG and leave your main IDE untouched.

 

Other than that, there is nothing special about it.

L.K.

Just a reminder for my future posts

I'll write about the following topics in no particular order, unless somebody says explicitly that they are interested in a topic and I'll post it ASAP.

I'd like to remind myself to document my thoughts regarding these topics:

These topics will follow:
  • JDK 7 new features
    • what I like
    • what I don't like 
  • JDK 1.6 installation problems
    • hints how to solve the problems 
  • Sony PRS-600 Touch - my brand new reader (and all the fuss regarding getting it)
    • review
    • some hints, tips and tricks 
    • problems 
    • conversion tools 
  • Windows 7
    • connecting to network
    •  control panel (Back) button navigation
  • some bugs of my Dell Inspiron Laptop
    • DVD
    • strange noise 
  • Eclipse debugging
  • NetBeans 6.8 bugs
    • swing editor bugs - needs to be reported
    • main class problem
  • Laptop battery preservation  tips
    • because what I have done so far has proven me right - thoughts from experience
  • Internet Browsers
    • Opera thoughts
    • Chrome
    • Firefox
    • IE
  • Google Chrome OS
  • Android
  • Skype time stamp bug 
  • HDD partitioning problems
    • how not to make your data inconsistent because of pure mistake or lack of knowledge
  •  Test-Driven Development

    L.K.

Hello world!

Hello world!

This blog is going to be especially for people interested in computers, programming, Java and mobile gadgets.

I've decided to start this blog as a way to express some of my thoughts which I forget otherwise.

I hope everybody who encounters this blog, finds something interesting and valuable.

Happy reading!

L.K.