Sunday, March 22, 2009

Getting Class name in a static method in Java


Finding the name of a Class in Java from within a static method

One of our regular visitors (Ranvijay) had asked it a couple of days back. Though, the code is pretty straightforward, I think it might help few others if posted as an article.

One of the many possible ways of finding the name of the class in Java from within a static method is by using a static nested class, which will have a public instance method returning the class name of the enclosing class (in our case the class where we have the particular static method).


public class GetClassNameInStaticMethod {

public static void main(String[] args) {
// Calling a Static Method
System.out.println("Current Class Name: " + getCurClassName());
}
public static String getCurClassName(){
return (new CurClassNameGetter()).getClassName();
}

//Static Nested Class doing the trick
public static class CurClassNameGetter extends SecurityManager{
public String getClassName(){
return getClassContext()[1].getName();
}
}
}


Output


Current Class Name: GetClassNameInStaticMethod


Liked the article? Subscribe to this blog for regular updates. Wanna follow it to tell the world that you enjoy GeekExplains? Please find the 'Followers' widget in the rightmost sidebar.



Share/Save/Bookmark


Monday, March 2, 2009

How to recover Shift + Deleted folders/emails in Outlook?


How to recover Shift + Deleted folders/emails in Microsoft Outlook?

Ever wondered if you can really recover something in Windows, which you have Shift + Deleted? Well, you can do that at least in few cases (if not in all) - one of them being recovering folders/emails which you accidentally Shift + Deleted in your Microsoft Outlook (running with MS Exchange Server). I managed to delete one important folder this weekend and only then I could realize the importance of this feature.


As you would certainly be aware that a plain 'Delete' moves the particular email to the 'Deleted Items' folder, from where you can easily restore them unless they get permanently deleted from that folder once one of the two situations occur - either the Deleted Items folder exceeds its quota of storage or the deleted emails become stale more than the allowed number of days (which I guess is 20/30 days) - whichever happens earlier.


But, it's interesting to know that even a Shift + Delete, does not really instantly delete all the items permanently - not at least in case of Microsoft Outlook. It's just that you probably can't see an option to recover them with your default settings. You need to add one registry entry and that's it. They will be visible to you then and you can recover the same way as you restore deleted items from the 'Deleted Items' folder. How many of these emails, folders, or emails within the folders you can recover, again depends upon the two parameters - storage quota and the age of the Shift + Deleted emails. So, you probably need to act fast whenever you manage to lose your folders/emails accidently. Find below the steps which are required for this recovery:-


Registry Entry:
if not already there (it's required to be added only once after the installation of the client application), you would be required to add the below entry in your Windows Registry. Below are the steps:-

  • Run -> regedit
  • expand HKEY_LOCAL_MACHINE
  • expand and go to SOFTWARE
  • expand and go to Microsoft
  • expand and go to Exchange
  • expand and go to Options
  • add the entry 'DumpsterAlwaysOn REG_DWORD 0x00000001 (1)'

Registry entry for recovering Shift+Deleted emails in Outlook
Microsoft Outlook -> Tools -> Recover Deleted Items...: If you want to recover a folder then simply select the corresponding mailbox and select 'Recover Deleted Items...', which will enable you select and recover the Shift + Deleted folders of that mailbox. If you want to recover emails then simply select the corresponding folder and do the same. It will show you all the emails of that folder available for you to be recovered (based on storage quota and age of the emails as discussed above). Please find below the sample screenshots for your reference:

Recover Deleted Items in Tools menu after registry entry
Recovering emails window where you can select which all to recover
Liked the article? Subscribe to this blog for regular updates. Wanna follow it to tell the world that you enjoy GeekExplains? Please find the 'Followers' widget in the rightmost sidebar.



Share/Save/Bookmark


Outlook Express v/s Outlook. Which suits you better?


Outlook Express v/s MS Outlook. How to choose one between the two?

Outlook Express v/s Microsoft Outlook


Many of you would already be aware of the main difference between the two. For those, who might not have cared to thought of it so far, here is the summary of the main difference(s) between the two messaging and collaboration clients delivered to us by Microsoft:-


Outlook Express: it has been designed mainly for Home Users to provide them a reliable and fast email and newsgroup functionality. It can use any Internet standard system, for example, SMTP, POP3, and IMAP. It has full support for you to take advantage of the technologies like LDAP, MHTML, HTML, S/MIME, and NNTP. In addition, you get to use many useful features including the ability to receive mail from multiple e-mail accounts, the ability to create Inbox rules, etc. The support for HTML enables you to personalize your custom backgrounds with graphics and colors. Outlook Express also includes stationery from Greetings Workshop and Hallmark for many occasions including birthdays or special holidays.


Microsoft Outlook: this on the other hand has been designed for Business Users who require not only reliability and ease of use, but in addition also require many more e-mail functionality and a tighter integration between e-mail and tools for information management and collaboration. This stand-alone client application which is integrated into Microsoft Office and Exchange Server, provides a complete integration of e-mail, calendaring, contact management, and a seamless integration with MS Office applications. Organizing your e-mails is quite easy by using the powerful Inbox rules. When used with Exchange Server, Outlook can be used for workgroup information sharing and workflow communications, group scheduling, public folders, forms, and an enhanced Internet connectivity. In addition to the technologies supported by Outlook Express, MS Outlook also supports even more advanced technologies like vCalendar, vCard, iCalendar, MAPI, and HTML mail.


In addition, Microsoft Outlook also offers easy migration from other e-mail clients like Microsoft Mail, Microsoft Schedule+ 1.0, Lotus Organizer, NetManage ECCO, Symantec ACT, etc. It also facilitates synchronization with leading Personal Digital Assistants (PDAs), such as the 3Com Palm Pilot.


How to choose which one of the two suits you better?


Above discussion clearly shows that the Outlook Express is mainly for Home Users, whereas Microsoft Outlook is a full-fledged, reliable, and performant messaging and collaboration application for Business Users. Here Home Users doesn't necessarily mean that Outlook Express won't suit any businesses. It should be good enough for most of the Very Small Businesses, which don't require the advanced features supported by Microsoft Outlook. MSDN lists down the parameters quite clearly on the basis which one can easily decide which one of the two, one should go for. Here is what MSDN says in this regard:-


Choose Outlook Express if:

  • You require only Internet e-mail and newsgroup functionality (for versions of Windows later than Microsoft Windows 95, versions of Windows earlier than Microsoft Windows 95, Macintosh, and UNIX platforms).
  • You use or plan to use Office 98 for Macintosh, and you want to take advantage of the integration of Outlook Express with this version of the Office suite.

Choose Outlook if:

  • You require advanced Internet standards-based e-mail and discussion group functionality.
  • You require integrated personal calendars, group scheduling, task, and contact management.
  • You require integrated e-mail and calendaring, cross-platform clients for versions of Windows later than Microsoft Windows 95, versions of Windows earlier than Microsoft Windows 95, and Macintosh platforms.
  • You use, or plan to use Office 97, Office 2000, Office XP or Exchange Server and want to take advantage of the integration of Outlook with this version of the Office suite, and the integration with Exchange Server.
  • You require robust, integrated run-time and design-time collaboration capabilities.

Read Next: How to recover Shift + Deleted folders/emails from Microsoft Outlook?


Liked the article? Subscribe to this blog for regular updates. Wanna follow the blog to manage to tell the world that you enjoy GeekExplains? Please find the 'Followers' widget in the rightmost sidebar.



Share/Save/Bookmark