Internationalization issues: How to set UTF-8 with MimeMessage for email in Java

Writing by on Tuesday, 31 of January , 2012 at 9:50 pm

Content and subject for Chinese, Japanese, Korean (CJK) and other language characters showing up garbled or with question marks ????

Gosh! I know – What a pain! But, there’s a solution! Simply set the encoding to UTF-8 and not ISO8859_1 or any other encoding format.

Found a good post from Isocra Consulting that solves this issue.

Properties props = new Properties();
// put in your SMTP host in here
props.put("mail.smtp.host", "localhost");
Session s = Session.getInstance(props, null);

MimeMessage message = new MimeMessage(s);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setHeader("Content-Type", "text/plain; charset=UTF-8");
message.setSubject(subject, "UTF-8"); //IMPORTANT

// Either use setText() or setContent()
message.setText(body, "UTF-8"); //IMPORTANT 
// message.setContent(body, "text/plain; charset=UTF-8"); // ALTERNATIVELY USE THIS

Transport.send(message);

Leave a comment

Category: Java

iPhone 4s Review and comparing iOS with Android

Writing by on Monday, 30 of January , 2012 at 10:56 pm

Yes. I switched to the iPhone 4s.

Three years back, I had the Blackberry Storm and last year I switched to Motorola Droid 2 Global (Android) and what a pleasure it was. This year, going to the iPhone 4s it’s even more pleasurable. I really have to give it to Apple for making it so intuitive, simple and clean (hardware and software aesthetics). Android still feels a little too geeky. So with HP/Palm and the Web-OS story I think there are only two choices at this point. The iPhone 4s or Samsung/HTC Android phones (Sorry, I will probably not go with the Motorola for a while now). So here’s my review and a comparison in general between the iPhone and Android phones.

In terms of Apps, you pretty much have a similar spread on both. However, I do miss Google Listen (the best Podcast app for Android). Until I find a good workaround, I will live with iTunes.

Primary Requirements whether an iPhone or an Android based phone

  • The Phone aspect (for making/receiving calls) must work and be accessible easily and fast
  • When in the gym or running on the trail, I need my music and be able to skip !!! (Motorola Failed BIG time on this)
  • Podcast Apps
  • Text/E-Mail support
  • Good Fast Browser
  • Needs to be a world phone

In my opinion, the iPhone wins in all departments (except Podcasts), only because eventually after time Android phones just seem to get slower!
OK – now here are my observations.

Why you would get an iPhone (4s running iOS 5.0.1)

Positives

  • Simple, easy and intuitive with beautiful fonts and overall appearance
  • You want a phone that just works every time and any time and is fast and spiffy
    (My Motorola Droid 2 fell short on this – gradually took too long to get to the phone to make calls etc.)
  • You have an iPad as well and you’re part of the Apple ecosystem
  • You want a smaller phone that you can hold easily in your hand
  • You want a phone that integrates with your car, with your receiver at home and has a plethora of accessories
  • You need a World Phone (Note iPhone 4s supports GSM/CDMA, while the Samsung Galaxy Nexus is only CDMA)
  • Voice mail is awesome (I would never listen to Voicemail on my Android)
  • Battery Life – You can tweak certain things to increase the life (also a negative, because it needs the tweaks)

Negatives

  • You don’t drop your phone and you’re not clumsy with it (The iPhone fared pretty bad on the drop test – Gorilla Glass – Yeah Right!)
  • You don’t care about Adobe Flash (Note: YouTube, NetFlix etc. run great)
  • You don’t care about the Free Google Navigation (Google Maps works just fine)
  • You don’t care about Google Listen
  • You don’t care about Siri
  • As a developer, you don’t mind writing Objective-C and be stuck to a Mac
  • You don’t mind not having Chrome to Phone
  • Battery Life – You can tweak certain things to increase the life (also a positive because its better than Android, for me)

Why you would get an Android Phone (Samsung/HTC – I can’t say great things about Motorola until I forget the pain I went through)

Positives

  • You need 4G LTEL – Samsung Galaxy Nexus supports this
  • You’re a podcast enthusiast – Google Listen is the best
  • You can’t stand iTunes
  • You can see the file system with your USB cable connected and easily transfer music
  • You want a bigger screen
  • You love Google and how seamlessly it integrates with Android
  • As a Java developer, you want the choice of what OS you want to develop code on and developing Apps is relatively easy
  • Pretty damn sturdy (My Motorola fell several times and didn’t even get a scratch)
  • NFC support (which not too many places accept at this point)

Negatives

  • A fraction slower navigating the phone (Not the browser or downloads etc. just the OS itself)
  • Just too geeky and not a very simple user experience (compared to the one button iPhone)
  • After about a year, the phone just doesn’t perform like it did when it was new
  • Battery Life – Gosh my Motorola Droid 2 would be completely drained before I got in my car at the end of the day
  • Really easy to build apps that are malicious. You could accidentally download them. There’s source code out there that teaches you how.

Overall, I wouldn’t disagree with folks who claim that Android 4.0 available on the Samsung Galaxy Nexus is probably the best out there, but it’s still a tad bit geeky. However, it’s not a World Phone which is a requirement for me. Now, Looking back at my Motorola Droid 2 – I just felt that whenever I really really needed something – Like Music or GPS – it needed a hard reset using up 5 minutes.

For simplicity and everyday use, and guaranteed to provide the same level of exceptional usability all year round – I went the iPhone! It just works!

Leave a comment

Category: Android,Apple,Reviews

Clear certain history in p4v

Writing by on Tuesday, 24 of January , 2012 at 9:34 pm

I needed to clear user list under submitted tab and found some meta-data information under ~/.p4qt/0001Clients/WoskpaceSettings.xml

$ cd ~/.p4qt/
$ grep -IR stringToRemove *
# in my case
$ vi ~/.p4qt/0001Clients/WorkspaceSettings.xml

Leave a comment

Category: Perforce,Tips and Tricks

Access the CD-ROM or USB from a Linux Terminal

Writing by on Saturday, 14 of January , 2012 at 1:40 am

Even though this is not a very common use case, you might need to do this and like just about anything with Linux, there’s a bit of a pain here as well.
The easiest way is to access the Disk Utility and see the Mount Point and just cd to that mount point. For example, cd /media/RHEL_6.1/

Otherwise, follow the steps below or read up on mount and umount (unmount)

Depending on the OS, most likely the cdrom will be at /dev/cdrom, the USB will be at /dev/usb etc. But may change.

# Login as root, then follow these steps
$ mkdir /mnt
$ mount /dev/cdrom /mnt/cdrom
$ cd /mnt/cdrom
$ ls

# To unmount, use the umount command
$ umount /mnt/cdrom
$ ls

Leave a comment

Category: Linux

Resize Unity Launcher Icons in Ubuntu 11.10

Writing by on Thursday, 12 of January , 2012 at 1:27 am

Gosh! Another reason I’m not giving Ubuntu 11.10 the Best Thing yet title. Moreover, NX won’t be able to display Unity Launcher and neither would RDP!
But assuming you’re local and not remote the CompizConfig Settings Manager lets you control it.

Alright if you’ve read my earlier post on Ubuntu 11.10 Must Have Apps and things to do after installation, you probably have already installed ccsm.

  • Otherwise just install it: $ sudo apt-get install ccsm
  • Launch ccsm $ ccsm
  • Go to Desktop -> Ubuntu Unity Plugin
  • Click on Experimental Tab
  • Use the slider Launcher icon size to resize as per your liking

Leave a comment

Category: Linux,Tips and Tricks

Ubuntu 11.10 Must Have Apps and things to do after installation

Writing by on Wednesday, 11 of January , 2012 at 9:45 pm

I can’t say Ubuntu 11.10 is the best thing just yet since things are still not simple enough, but I just love the Price for what it can do! Moreover, Ubuntu works perfectly on my 3 year old desktop while Red Hat 6 wouldn’t even recognize the display. For development, I still prefer Linux and therefore went with Ubuntu on my backup Dev Box.

So, here’s another list of must have apps and things to do after getting Ubuntu 11.10.

I hope you have already modified your /etc/hosts file.

What’s already there

Terminal, Firefox, LibreOffice

Some must-haves (for me and developers like me) that just work without the fancy Ubuntu Software Center DAK crap

Java JDK, Eclipse, Perforce, FileZilla

Get Updates and Upgrade

sudo apt-get update && sudo apt-get upgrade

Install SSH

sudo apt-get install openssh-server

Install Gnome-Shell

sudo apt-get install gnome-shell
#sudo apt-get install gnome-session-fallback ### while messing with No Machine NX

Install Shutter

sudo apt-get install shutter

Install Adobe PDF Reader

sudo apt-get install acroread

Install ccsm – CompizConfig Settings Manager

sudo apt-get install ccsm

Install VLC

sudo apt-get install vlc

Install Skype

sudo apt-get install skype

I don’t remember how I installed these, but they were not straight forward.

google-chrome, Adobe Flash Plugin

Currently, NoMachine NX will not work with Ubuntu 11.10 – it’s a known issue and several people have posted workarounds, which didn’t seem to work for me. Anyway, it’s not officially supported due to Unity 3D enhancements.

Things to enable
Open SSH (installing should start sshd)
Remote Destkop Sharing – Enable this

Leave a comment

Category: Linux,Tools

Shivdev Kalambi's Blog

Shivdev Kalambi is a Software Development Manager, previously a Principal Software Engineer at ArcSight/HP. With over 16 years' experience in software development, he's worked on several technologies and played different roles and contributed to all phases of projects. Non-tech activies include Ping-pong, Rock Climbing and Yoga at PG, Golf, Skiing, Swimming & a beer enthusiast.