Thursday, March 29, 2007

Using stmp.gmail.com To Send Mail

Here is a snippet of code I wrote to use smtp.gmail.com to send mails.
Please use vaild email address.

import org.apache.commons.mail.DefaultAuthenticator;
import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;

/**
* @author prasad
*/

public class MailInfo {
public void send() throws EmailException {
Email email = new SimpleEmail();
String authuser = "--------@gmail.com";
String authpwd = "**********";
// Very Important, Don't use email.setAuthentication()
email.setAuthenticator(new DefaultAuthenticator(authuser, authpwd));
email.setDebug(false); // true if you want to debug
email.setHostName("smtp.gmail.com");
email.getMailSession().getProperties().put(
"mail.smtp.starttls.enable", "true");

email.setFrom("++++++++@gmail.com", "SenderName");

email.setSubject("TestMail");
email.setMsg("This is a test mail?");

email.addTo(".......@gmail.com", "ToName");
email.send();
}
}

Wednesday, March 28, 2007

JavaProxy -- HTTP Proxy In Java

I decided to write this JavaProxy as I was looking for a proxy similar to CGIProxy implemented in Java.

After checking out HTMLParser library,
I got my implementation of JavaProxy working. Here is the download link.

Just copy the JavaProxy.war file into your Tomcat/webapps folder and you should be able to use it,
using http://localhost:8080/JavaProxy/

I have released it under Apache License 2.0, so make the best use of it.
Let me know if you liked it or found some use in your application.

I have got this project on google's Subversion Repository http://java-proxy.googlecode.com/svn/

[NOTE: Steps to import your project on code.google.com
  1. To host your project on googlecode, signin for an account at http://code.google.com/hosting/

  2. Create a new project (myproject).

  3. Go to MyProfile (note down Username) and under Settings (note down Password).

  4. From your terminal type (assuming your are under project folder):
    svn import -m "Initial Import" . https://myproject.googlecode.com/svn/trunk --username Username
    You will be prompted for Username and Password, enter the one you had notedown.
  5. Now your code is in subversion repository.
]

Sunday, March 11, 2007

Eclipse Profiler Plugin

Was looking for eclipse profile plugin and got this link: http://eclipsecolorer.sourceforge.net/index_profiler.html
Download link is here.

I could not get the plugin working with eclipse-3.2 but I could see the Profiler perspective as described when I tried with eclipse-3.1.

When I tried to run the profiler I got some error like this:
Plug-in unable to load class ru.nlmk.eclipse.profiler was unable to load class
ru.nlmk.eclipse.profiler.launch.ProfilerLaunchConfigurationDelegate.


Check out more discussion on this problem here.

I tried to use the bug fixed plugin for eclipse-3.1, use this link.

After getting this patched version of plugin:
1. Unzip it to eclipse/plugin folder.
2. For windows:
Copy ProfilerDLL.dll to ${JAVA_HOME}/jre/bin folder

For Linux Box:
Get libProfilerDLL.so from native/profiler_linux.tgz and copy it to libProfilerDLL.so in native/profiler_linux.tgz to ${JAVA_HOME}/jre/lib/i386/

[NOTE] I had to recompile a new version of libProfilerDLL.so. Its simple to do. Just set the right path for your java installation in the shell script m [you get it after untaring native/profiler_linux.tgz], execute it (you will need right permission to copy the shared library)

Shell script m (used to recompile and copy libProfilerDLL.so)
#!/bin/sh
export JAVA_HOME=/usr/java/j2sdk1.4.2_06

g++ -O0 -DLINUX -shared -Wall -I. -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux ProfilerDLL.cpp -o libProfilerDLL.so
cp libProfilerDLL.so ${JAVA_HOME}/jre/lib/i386/libProfilerDLL.so

Enjoy Profiling!

Are you hit by Email-Worm?

My System got affected by Email-Worm.Win32.Brontok Virus few months back from now.
Although Anti-Virus cleaned up this worm, but I had to spend sometime to get the system configuration back to normal. Here are few links which helped me in the process.

Email-Worm.Win32.Brontok Virus:
http://activepanel.blogspot.com/2006/01/brontok-rontokbro-korbo-b-mytob-virus.html

and more about similar virus W32.Rontokbro@mm:
http://drvamsikrishna.blogspot.com/2007/02/solution-for-folder-options-missing_28.html

My system configuration has landed to proper state, I can now breathe easy, (Quite successfully avoided usual Windows RE-INSTALL!)

This page is powered by Blogger. Isn't yours?