Author Archive for Jarosław Dobrzański

Java: main method declaration

It’s good to remember that there are a few ways of defining the main() method in Java 5:


public static void main(String[] args) {}

or


public static void main(String args[]) {}

or


public static void main(String... args) {}

Sometimes, we don’t care and remeber of basic stuff, which can result in worse score on the exam :)

Useful links on SCJP

I’ve found a couple of links that may be useful while preparing to SCJP. Take a look at them, if you wish:

Should you have some other useful links, don’t hesitate to show me them (by replying to this post).

Java: overriding and overloading

Overriding and overloading are common concepts of Java and occur often on SCJP exam. Although I know the rules that apply for them, I happen to think twice (or more) on questions dealing with them. Thus, it’s a good idea to keep the following rules in mind…

Overriding

  • applies ONLY to inherited methods
  • is related to polymorphism
  • object type (NOT reference variable type) determines which overriden method will be used at runtime
  • overriding method MUST have the same argument list (if not, it might be a case of overloading)
  • overriding method MUST have the same return type; the exception is covariant return (used as of Java 5) which returns a type that is a subclass of what is returned by the overriden method
  • overriding method MUST NOT have more restrictive access modifier, but MAY have less restrictive one
  • overriding method MUST NOT throw new or broader checked exceptions, but MAY throw fewer or narrower checked exceptions or any unchecked exceptions
  • abstract methods MUST be overridden
  • final methods CANNOT be overridden
  • static methods CANNOT be overridden
  • constructors CANNOT be overridden

Overloading

  • overloading can take place in the same class or in the subclass
  • overloaded methods MUST have a different argument list
  • overloaded methods MAY change the return type (in case argument list is different)
  • overloaded methods MAY change the access modifier
  • overloaded methods MAY throw new or broader checked excpetions
  • reference type determines which overloaded method will be used at compile time
  • constructors MAY be overloaded
  • methods adjustment in connection with overloaded method’s arguments:
    • you cannot widen and then box (int -> Long)
    • you can box and then widen (int -> Object, via Integer)
    • you can combine var args with either widening (byte -> int) or boxing (int -> Integer):
      • widening is over boxing
      • widening is over var args
      • boxing is over var args

Finally, a few notes on polymorphism:

  • a refenrence variable is of an unchangeable type, but can refer to a subtype object
  • a single object can be referred to by reference variable of many differnet types (however, they MUST be the of same type or supertype of the object)
  • reference type determines which method will be called

Also, keep that in mind:
Reference type determines which overloaded method is used at compile time.
Object type determines which overriden method is used at runtime.

Sun Certified Java Programmer

Okay, I’ve been working with Java for a few years now, starting from academia and ending with business solutions. So yeah, I think I can say I know Java and some of those technologies like J2SE, J2EE or J2ME, with their own standards and solutions. Therefore, I’ve decided I’d take Sun Certified Java Programmer (SCJP) in a few months.

If you know nothing about SCJP, read about it on the official SCJP website by Sun; there’s a lot of usefult information. By and large, it revises your knowledge of J2SE, currently on ver. 5.

So a couple of months ago I started readnig this book: SCJP Sun Certified Programmer for Java 5 Study Guide (Exam 310-055) by Kathy Sierra and Bert Bates. I think it’s great though it takes much time to read it - with analysis and testing of all those examples presented there, not mentioning about things I’ve never come across during my ‘Java developer’ part of life ;) Anyway, I recommend that book if you want to prepare for that exam.

While reading the book I made a lot of notes which now are not easy to search and read… So, I’ve decided I’d publish my notes, examples and thoughts regarding SCJP stuff so I have them in once place and they’re also accessible for others. So prepare for upcoming posts ;)

expressivo

I wonder if you’ever heard of expressivo? If you haven’t, have a look; if you’ve seen that, play with it again :)

By and large, expressivo is an online service that provided text-to-speech reader (and not only). It produces speech in English, Polish and Romanian. To generate speech it uses IVONA TTS.

I don’t know Romanian but English and Polish TTSs sound decent enough. Both TTS engine and the online service is a Polish product; the company is placed in Gdynia (one of the cities in Tricity).

Listen to English and Polish TTSs.

LastGraph - visualize your music profile

Recently, I’ve told you about my excitement about last.fm.
Slightly later I’ve discovered an interesting service related to last.fm: LastGraph. What it really does? Its auhor, Andrew Godwin says:

LastGraph is a web application that makes graphs of your musical listening history from your Last.fm profile.

In other words, LastGraph creates a special graph that shows what you listened to during the provided period of time. From that graph you can recall bands you listened to and how frequently you listened to one artist comparing to others. The only information you need to provide for this service is your last.fm login. After some time (it can take many hours if you want a graph for a long period of time, like year!) you can download the outcome in PDF or SVG file.

Why not trying it, you’ll get a proof of your music history :)

You can view my music history from last few months either in PDF (can get a very close zoom-in) or in the picture below:

jdobrzanski's music history

Listen what you really want!

I used to listen to Pandora, but that has been impossible for some time because it’s been suspended in Poland (and some other countries). Let me quote Pandora’s authors:

We are deeply, deeply sorry to say that due to licensing constraints, we can no longer allow access to Pandora for most listeners located outside of the U.S.

At the same time I listened to last.fm but for some reason (why?) I stopped. Recently I re-discovered that service and I’m really excited about it! For those who haven’t used it, it’s a social network that allows to listen music you like (what you declare and tracks with similar genre that you may like), learn your friends’ music tastes, find information about music events that take place near the place you leave, discover new artists/tracks, etc. You can listen music either via a web browser or using special player (the player is more efficient and handy). This player can also register (scrobble) what you listen on your PC from CDs or mp3 files and updates your music profile. Eventually, you can listen what you like wherever you go provided you have Internet connection.

If you’d like to see what I’ve been listening to recently, look below at my “Top albums music quilt”:

Windows 2003: problem with running exe files

Today I couldn’t install some tool on Windows 2003 SE despite being assigned to the Admisnitrators group. Whenever I tried I get the following message:

Windows cannot access the specified device, path, or file. You may not have the appropraiate permissions to access the item.

If you face such problem, first of all check what permissions you have. To do that, right click on My Computer and choose Manage; then System Tools\Local Users and Groups\Groups; double click Administrators on the right part of the window and check if you are on the list of users with that persmissions.

As I said, I was the Admisnitrator of that machine so that was really strange. So I righ clicked the exe file I needed to run and chose Properties. In the Security tab I found out I have the appropriate rights on that file. I went to General tab of that window; at the bottom, in Security section there was the infromation:

This file came from another computer and might be blocked to help protect this computer.

.
That was it! You just need to click Unblock button which is next to the above information.

FYI: The whole security section is only visible for ‘unsecure’ files. Once you enable a file’s exection and click OK, you will no longer see it.

Registering different versions of ASP.NET IIS

It’s possible to have more than one ASP.NET IIS installed and registrated on one machine (that runs Windows).
To check which version is currently registered run Command Line (Start/Run… and type ‘cmd’) and go to %SystemRoot%\Microsoft.NET\Framework\vXXX directory where %SystemRoot% is a special system-wide environment variable found on Microsoft Windows NT and its derivatives (read more on Wikipedia) and vXXX is the directory with ASP.NET IIS files.
Being in that directory, type aspnet_regiis -lv. You will be then given the list of installed/registered versions of ASP.NET IIS.

To register a new version of ASP.NET IIS, go to its direcotry in %SystemRoot%\Microsoft.NET\Framework (using Command Line) and run the following command: aspnet_regiis -i.

To unregister a new version of ASP.NET IIS, go to its direcotry in %SystemRoot%\Microsoft.NET\Framework (using Command Line) and run the following command: aspnet_regiis -u.

To learn more about ASP.NET IIS Registration Tool (Aspnet_regiis.exe) visit the description available on MSDN service.

Media convertion

Many times it happened to me that I needed to convert a file from one format to another (text documents, images, movies, etc). It can be difficult and expensive to download different pieces of software that can do that.

Media Convert service comes with helping hand. Let me cite the authors:

Media-Convert is 100% free. No software is needed, and you don’t have to register. You only need your favorite Internet browser. Your files are ready 7/7 days 24/24 hours (…).

Why use Media-Convert?

Simply because Media-Convert is the best manner of converting audio files, video, presentation, document, spreadsheet, etc.

Media-Convert advantages:

  • More secure because you do not have to install software on your computer, which can contain viruses, spywares, etc.
  • Access from everywhere in the world through Internet. You can use Media-Convert at the office, in a cybercafé, or with the PC of a friend, and then download the result quietly to your mp3 reader, cell phone or any other hardware.

So far, I must admit I’m happy with it. However, I’m not guy who converts things everyday ;)

Besided that service, I’ve encountered another, MC. I didn’t use it much, though. I tried to test it with convertion of doc files to pdf but all tries ended up with “You used an unknown file type!” message. It discouraged me from discovering what I did wrong, if I could do such at all ;)