Java Decompiler and a surprising bug in JDK1.8

Currently at video 54, am well on my way to complete the course by this weekend.. While I was learning the class on “HashMap”, Eclipse prompted me to import the class once I declared an object in my main method.  As soon as I wrote the import, it started showing me this weird error – “Type hashmap is not visible” ( do not record the error, cannot exactly remember).  Nothing I did changed the program’s fate. Finally, with the help of my friend at work – I figured out that rt.jar in JDK1.8 is creating the problem. ArrayList and LinkedList works fine, but all Map and it’s related sub classes are not recognized.  Realizing my mistake of downloading the latest JDK version, I promptly downloaded the stable version of JDK1.7 and set JAVA_PATH and Eclipse JRE Path correctly. Viola, the error just disappeared!!

Rather strange, isn’t it?

Java Decompiler and why do we need it?

In this entire process, I learnt about Java Decompiler. It’s a plugin available for free on the Internet. Get yours here :  

http://5thcross.wordpress.com/2009/05/20/installing-jadclipse-in-eclipse/

and follow the instructions mentioned. The main reason to install this plugin is to obtain the source code of any class in question. Ctrl+ click will reveal the Java code behind the imported class.  I heard from the same friend that, sometimes we only have the jar files with imported classes and do not have the source code. And your project demands you to change something in that class. JAD ( Java Decompiler) will come to rescue –  find the source code of the class in question, copy the code, change it and re-generate the jar 😀

Hope you learnt a thing or two by reading so far. Have a good day and keep rocking!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s