<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Techelp</title>
	<atom:link href="http://techelp.in/thome/feed/" rel="self" type="application/rss+xml" />
	<link>http://techelp.in/thome</link>
	<description></description>
	<lastBuildDate>Wed, 08 Feb 2012 11:02:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Java Create/Scan Virus</title>
		<link>http://techelp.in/thome/2012/02/08/java-createscan-virus/</link>
		<comments>http://techelp.in/thome/2012/02/08/java-createscan-virus/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 11:02:39 +0000</pubDate>
		<dc:creator>nandeeswar</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[create virus java]]></category>
		<category><![CDATA[java create scan virus]]></category>
		<category><![CDATA[scan virus java]]></category>

		<guid isPermaLink="false">http://techelp.in/thome/?p=256</guid>
		<description><![CDATA[Source Code: &#160; 1. JavaVirusAntiVirus.java &#160;]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: underline"><strong>Source Code:</strong></span></p>
<p>&nbsp;</p>
<p><strong>1. <span style="text-decoration: underline">JavaVirusAntiVirus.java</span></strong></p>
<p>&nbsp;</p>
<pre class="brush: java; title: ; notranslate">

import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class JavaVirusAntiVirus extends JFrame implements ActionListener{
 Container c;
 JProgressBar pb;
 JOptionPane jp;
 JButton v,av;
 JavaVirusAntiVirus(){
 c=this.getContentPane();
 c.setLayout(new FlowLayout());
 jp=new JOptionPane();
 v=new JButton(&quot;Create Virus&quot;);
 v.setSize(300, 50);
 c.add(v);

av=new JButton(&quot;Scan Virus&quot;);
 av.setSize(300, 50);
 c.add(av);

v.addActionListener(this);
 av.addActionListener(this);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 }

public void actionPerformed(ActionEvent ae){

Object o=ae.getSource();
 pb=new JProgressBar();
 pb.setMinimum(10);
 pb.setMaximum(100);
 if(o==v){
 c.add(pb);
 File path=new File(&quot;JavaVirusAntiVirus.class&quot;);
 String temp=path.getAbsolutePath();
 StringTokenizer st=new StringTokenizer(temp,&quot;\\&quot;);
 int j=0;
 String temp2=temp.replace(&quot;\\&quot;,&quot;/&quot;);
 String temp3=&quot;&quot;;
 while(j&lt;st.countTokens()-1){
 temp3+=st.nextToken()+&quot;/&quot;;
 }
 String directory=temp3;
 File vpath;
 int noOfFiles=0;
 try{
 noOfFiles=Integer.parseInt(jp.showInputDialog(&quot;Enter How many Files U want to Generate....&quot;,0));
 }catch(Exception e){}
 int pbval=(int)(100/noOfFiles);
 int confirm=jp.showConfirmDialog(this,&quot;Are you sure?&quot;);
 if(confirm==0)
 {
 if(noOfFiles!=0)
 {
 for(int i=1;i&lt;=noOfFiles;i++){
 vpath=new File(directory+&quot;virus &quot;+i+&quot;.exe&quot;);
 try{
 Thread.sleep(2000);
 vpath.createNewFile();
 File virus=new File(directory+&quot;virus &quot;+i);
 virus.setReadOnly();
 pb.setValue(pb.getValue()+pbval);
 }catch(Exception e){e.printStackTrace();}
 }
 jp.showMessageDialog(this,noOfFiles+&quot; files created successfully...&quot;);
 }
 else
 jp.showMessageDialog(this,noOfFiles+&quot; files created successfully...&quot;);
 }
 else
 jp.showMessageDialog(this,&quot;Non of files are generated...&quot;);
 c.remove(pb);
 }//end of if(o==v) condition

if(o==av){
 int count=0;
 c.add(pb);
 File avpath=new File(&quot;JavaVirusAntiVirus.class&quot;);
 String tep=avpath.getAbsolutePath();
 StringTokenizer st=new StringTokenizer(tep,&quot;\\&quot;);
 int j=0;
 String tep2=tep.replace(&quot;\\&quot;,&quot;/&quot;);
 String tep3=&quot;&quot;;
 while(j&lt;st.countTokens()-1){
 tep3+=st.nextToken()+&quot;/&quot;;
 }
 String directory=tep3;
 java.util.List&lt;String&gt; files=new java.util.ArrayList&lt;String&gt;();
 File dir=new File(directory);
 for(File file:dir.listFiles()){
 if(file.getName().endsWith(&quot;.exe&quot;)){
 files.add(file.getName());
 }
 }
 int listSize=files.size();
 for(int i=0;i&lt;listSize;i++){
 try{
 String s=files.get(i);
 File delete=new File(directory+s);
 Thread.sleep(2000);
 //if(delete.canExecute())
 if((!(delete.canRead()))||(delete.isHidden())||(!(delete.isFile()))||(!(delete.canWrite()))||(delete.canRead()))
 delete.delete();
 pb.setValue(pb.getValue()+ listSize);
 }catch(Exception e){e.printStackTrace();}
 count++;
 }
 jp.showMessageDialog(this,count+&quot; files Detected and Scanned successfully...&quot;);
 c.remove(pb);
 }//end of if(o==av) condition

}//end of actionPerformed() method

public static void main(String ar[])throws Exception{

JavaVirusAntiVirus nv=new JavaVirusAntiVirus();
 nv.setTitle(&quot;Nandu Virus &amp; AntiVirus&quot;);
 nv.setSize(600,200);
 nv.setVisible(true);
 }
} //End of Code...
</pre>
]]></content:encoded>
			<wfw:commentRss>http://techelp.in/thome/2012/02/08/java-createscan-virus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Get System name,ip address and OS details</title>
		<link>http://techelp.in/thome/2012/02/08/java-get-system-nameip-address-and-os-details/</link>
		<comments>http://techelp.in/thome/2012/02/08/java-get-system-nameip-address-and-os-details/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 10:51:23 +0000</pubDate>
		<dc:creator>nandeeswar</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java get os info]]></category>
		<category><![CDATA[java get system ip]]></category>
		<category><![CDATA[java get system name]]></category>

		<guid isPermaLink="false">http://techelp.in/thome/?p=253</guid>
		<description><![CDATA[Source Code: &#160; 1.GetSystemDetails.java &#160; 2.OSInfo.java]]></description>
			<content:encoded><![CDATA[<p><strong>Source Code:</strong></p>
<p>&nbsp;</p>
<p><strong>1.<span style="text-decoration: underline">GetSystemDetails.java</span></strong></p>
<pre class="brush: java; title: ; notranslate">

import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;

/**
 *
 * @author nande.m
 */
public class GetSystemDetails {

public static void main(String[] args) throws SocketException, UnknownHostException {

//get system name:
 String computername = InetAddress.getLocalHost().getHostName();
 System.out.println(computername);

//get ip address
 InetAddress ownIP = InetAddress.getLocalHost();
 System.out.println(&quot;IP of my system is := &quot; + ownIP.getHostAddress());

}
}
</pre>
<p>&nbsp;</p>
<p><strong>2.<span style="text-decoration: underline">OSInfo.java</span></strong></p>
<pre class="brush: java; title: ; notranslate">

public class &lt;strong&gt;OSInfo&lt;/strong&gt;{

public static void main(String[] args) {
 String nameOS = &quot;os.name&quot;;
 String versionOS = &quot;os.version&quot;;
 String architectureOS = &quot;os.arch&quot;;

 System.out.println(&quot;::::The information about OS::::&quot;);

 System.out.println(&quot;Name of the OS: &quot;+ System.getProperty(nameOS));
 System.out.println(&quot;Version of the OS: &quot;+ System.getProperty(versionOS));
 System.out.println(&quot;Architecture of THe OS: &quot;+ System.getProperty(architectureOS));
 }
}

//End of code......
</pre>
]]></content:encoded>
			<wfw:commentRss>http://techelp.in/thome/2012/02/08/java-get-system-nameip-address-and-os-details/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Search File ( Search File on the basis of &#8221; Search String &#8221;  in file ) -Swings GUI</title>
		<link>http://techelp.in/thome/2012/02/08/java-search-file-search-file-on-the-basis-of-search-string-in-file-swings-gui/</link>
		<comments>http://techelp.in/thome/2012/02/08/java-search-file-search-file-on-the-basis-of-search-string-in-file-swings-gui/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 10:36:53 +0000</pubDate>
		<dc:creator>nandeeswar</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Search File]]></category>
		<category><![CDATA[Search File Java]]></category>
		<category><![CDATA[Search File on the basis of text of file]]></category>

		<guid isPermaLink="false">http://techelp.in/thome/?p=245</guid>
		<description><![CDATA[Required jar files: 1. commons-io-1.3.2.jar 2. l2fprod-common-all.jar Inputs for Application while Runnig:  1) * Source Directory 2) * Destination Directory 3) * File Extension 4) Search String ( Optional ) Source Code 1.Java_File_SearchEngine.java]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: underline"><strong>Required jar files:</strong></span></p>
<p>1. commons-io-1.3.2.jar</p>
<p>2. l2fprod-common-all.jar</p>
<p><span style="text-decoration: underline"><strong>Inputs for Application while Runnig: </strong></span></p>
<p>1) * Source Directory</p>
<p>2) * Destination Directory</p>
<p>3) * File Extension</p>
<p>4) Search String ( Optional )</p>
<p><span style="text-decoration: underline"><strong>Source Code</strong></span></p>
<p><strong>1.Java_File_SearchEngine.java</strong></p>
<pre class="brush: java; title: ; notranslate">

package com.search;

import com.l2fprod.common.swing.JDirectoryChooser;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;

import javax.swing.*;
import javax.swing.JOptionPane;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.filefilter.TrueFileFilter;

public class Java_File_SearchEngine extends JFrame implements ActionListener {

Container container;
 JLabel labelSourceDirectory;
 JLabel labelDestinationDirectory;
 JLabel labelFileExtension;
 JLabel labelSearchString;
 JLabel labelOptional;
 JTextField textFieldSourceDirectory;
 JTextField textFieldDestinationDirectory;
 JTextField textFieldFileExtension;
 JTextField textFieldSearchString;
 JButton buttonChooseSourceDirectory;
 JButton buttonChooseDestinationDirectory;
 JButton buttonSearchFiles;

public Java_File_SearchEngine() {
 container = getContentPane();
 container.setLayout(null);

labelSourceDirectory = new JLabel(&quot;* Source Directory :&quot;);
 labelDestinationDirectory = new JLabel(&quot;* Destination Directory :&quot;);
 labelFileExtension = new JLabel(&quot;* File Extension :&quot;);
 labelSearchString = new JLabel(&quot;Search String :&quot;);
 labelOptional = new JLabel(&quot;( Optional )&quot;);
 textFieldSourceDirectory = new JTextField();
 textFieldDestinationDirectory = new JTextField();
 textFieldFileExtension = new JTextField();
 textFieldSearchString = new JTextField();

buttonChooseSourceDirectory = new JButton(&quot;Choose Source Directory&quot;);
 buttonChooseDestinationDirectory = new JButton(&quot;Choose Destination Directory&quot;);
 buttonSearchFiles = new JButton(&quot;Search Files&quot;);
 labelSourceDirectory.setBounds(10, 10, 200, 30);
 textFieldSourceDirectory.setBounds(150, 10, 200, 30);
 buttonChooseSourceDirectory.setBounds(370, 10, 200, 30);

labelDestinationDirectory.setBounds(10, 50, 200, 30);
 textFieldDestinationDirectory.setBounds(150, 50, 200, 30);
 buttonChooseDestinationDirectory.setBounds(370, 50, 200, 30);

labelFileExtension.setBounds(10, 100, 200, 30);
 textFieldFileExtension.setBounds(150, 100, 200, 30);

labelSearchString.setBounds(10, 150, 200, 30);
 textFieldSearchString.setBounds(150, 150, 200, 30);
 labelOptional.setBounds(370, 150, 200, 30);

buttonSearchFiles.setBounds(150, 200, 200, 30);
 container.add(labelSourceDirectory);
 container.add(textFieldSourceDirectory);
 container.add(buttonChooseSourceDirectory);

container.add(labelDestinationDirectory);
 container.add(textFieldDestinationDirectory);
 container.add(buttonChooseDestinationDirectory);

container.add(labelFileExtension);
 container.add(textFieldFileExtension);

container.add(labelSearchString);
 container.add(textFieldSearchString);
 container.add(labelOptional);

container.add(buttonSearchFiles);

buttonChooseSourceDirectory.addActionListener(this);
 buttonChooseDestinationDirectory.addActionListener(this);
 buttonSearchFiles.addActionListener(this);

setTitle(&quot;Nandeeswar Search Engine&quot;);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 }

public static void main(String[] args) throws IOException {
 Java_File_SearchEngine frame = new Java_File_SearchEngine();
 frame.setSize(600, 300);
 frame.setVisible(true);

}//end of main()

public static boolean searchStringInFile(File inputFile, String inputString) {
 try {
 String stringSearch = inputString;
 BufferedReader bf = new BufferedReader(new FileReader(inputFile.getPath()));
 int linecount = 0;
 String line;
 System.out.println(&quot;Searching for String \&quot; &quot; + stringSearch + &quot; \&quot; in file...&quot;);
 while ((line = bf.readLine()) != null) {
 linecount++;
 int indexfound = line.indexOf(stringSearch);
 if (indexfound &gt; -1) {
 System.out.println(&quot;Word was found at position &quot; + indexfound + &quot; on line &quot; + linecount);
 return true;
 }
 }
 bf.close();
 } catch (IOException e) {
 System.out.println(&quot;IO Error Occurred: &quot; + e.toString());
 return false;
 }
 return false;
 }

public static String getDirectory() {
 String directoryPath = &quot;&quot;;
 JFrame frame = new JFrame();
 frame.setLayout(new BorderLayout());
 JDirectoryChooser chooser = new JDirectoryChooser();
 int choice = chooser.showOpenDialog(frame);
 if (choice == JDirectoryChooser.CANCEL_OPTION) {
 System.out.println(&quot;User Canceled&quot;);
 } else {
 directoryPath = chooser.getSelectedFile().getAbsolutePath();
 System.out.println(&quot;Dialog Selection: &quot; + directoryPath);
 }

return directoryPath;
 }

@Override
 public void actionPerformed(ActionEvent event) {

Object button = event.getSource();
 if (button == buttonChooseSourceDirectory) {
 textFieldSourceDirectory.setText(Java_File_SearchEngine.getDirectory());
 } else if (button == buttonChooseDestinationDirectory) {
 textFieldDestinationDirectory.setText(Java_File_SearchEngine.getDirectory());
 } else if (button == buttonSearchFiles) {

try {
 Thread.sleep(2000);
 } catch (Exception e) {
 }

//Search File's

try {
 File sourceDirectory = new File(textFieldSourceDirectory.getText().replace(&quot;\\&quot;, &quot;/&quot;));
 String destinationDirectory = textFieldDestinationDirectory.getText().replace(&quot;\\&quot;, &quot;/&quot;) + &quot;/&quot;;
 String fileExtension = textFieldFileExtension.getText();// kind of files to copy into destination directory
 String searchString = textFieldSearchString.getText();
 boolean fileFound = false;

System.out.println(&quot;Source: &quot; + textFieldSourceDirectory.getText().replace(&quot;\\&quot;, &quot;/&quot;));
 System.out.println(&quot;destinationDirectory: &quot; + destinationDirectory);
 System.out.println(&quot;fileExtension: &quot; + fileExtension);
 System.out.println(&quot;searchString: &quot; + searchString);

System.out.println(&quot;Getting all files in &quot; + sourceDirectory.getCanonicalPath() + &quot; including those in subdirectories&quot;);

System.out.println(&quot;Loading...&quot;);

 List&lt;File&gt; files = (List&lt;File&gt;) FileUtils.listFiles(sourceDirectory, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
 int fileNo = 1;
 int foundFilesNo = 0;
 for (File file : files) {

//Getting FilePath,FileName,FileExtension

String filePath = &quot;&quot;, fileName = &quot;&quot;, ext = &quot;&quot;;
 filePath = file.getPath();
 int lastSlash = filePath.lastIndexOf(&quot;\\&quot;);
 int lastDot = filePath.lastIndexOf(&quot;.&quot;);
 fileName = filePath.substring(lastSlash + 1, filePath.length());
 ext = filePath.substring(lastDot + 1, filePath.length());

// Copying search string contained text files into speified destination directory...
 if (ext.equalsIgnoreCase(fileExtension)) {

System.out.println((fileNo++) + &quot;.File name :&quot; + fileName + &quot; (Path: &quot; + filePath + &quot;)&quot;);
 System.out.println(&quot;Extension :&quot; + ext);

if (textFieldSearchString.getText().equalsIgnoreCase(&quot;&quot;)) {
 fileFound = true;
 File copyFile = new File(destinationDirectory + fileName);
 copyFile.createNewFile();
 InputStream in = new FileInputStream(file);
 OutputStream out = new FileOutputStream(copyFile, true); // appending output stream

foundFilesNo++;

IOUtils.copy(in, out);
 IOUtils.closeQuietly(in);
 IOUtils.closeQuietly(out);

} else {

boolean searchResult = Java_File_SearchEngine.searchStringInFile(file, searchString);
 Thread.sleep(2000);
 System.out.println(&quot;searchResult: &quot; + searchResult);
 if (searchResult) {
 fileFound = true;
 foundFilesNo++;
 File copyFile = new File(destinationDirectory + fileName);
 copyFile.createNewFile();
 InputStream in = new FileInputStream(file);
 OutputStream out = new FileOutputStream(copyFile, true); // appending output stream

IOUtils.copy(in, out);
 IOUtils.closeQuietly(in);
 IOUtils.closeQuietly(out);

}
 }
 }

}

if (fileFound) {
 if (foundFilesNo == 1) {
 //JOptionPane.showMessageDialog(null, &quot;Found : &quot; + foundFilesNo + &quot; file&quot;);
 } else if (foundFilesNo &gt; 1) {
 // JOptionPane.showMessageDialog(null, &quot;Found : &quot; + foundFilesNo / 2 + &quot; files&quot;);
 }
 Desktop.getDesktop().open(new File(destinationDirectory));
 } else {
 JOptionPane.showMessageDialog(null, &quot;No Such File's Found with search String: &quot; + searchString);
 }
 } catch (Exception e) {
 }
 }
 }
}

//end of code...
</pre>
]]></content:encoded>
			<wfw:commentRss>http://techelp.in/thome/2012/02/08/java-search-file-search-file-on-the-basis-of-search-string-in-file-swings-gui/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>File Encryption Decreption with key (Single File or Multiple Files) &#8211; swings GUI</title>
		<link>http://techelp.in/thome/2012/02/08/files-encryption-decreption-with-key-swings/</link>
		<comments>http://techelp.in/thome/2012/02/08/files-encryption-decreption-with-key-swings/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 10:19:26 +0000</pubDate>
		<dc:creator>nandeeswar</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[File Encryption Decription Java]]></category>
		<category><![CDATA[Java File Encryption Decription]]></category>

		<guid isPermaLink="false">http://techelp.in/thome/?p=238</guid>
		<description><![CDATA[Note: 1) Main Class File: FileEncryptDecrypt.java 2) Result encrypted/decrypted file&#8217;s will be available in your java application files directory it self. 3) In case of  &#8221; Multiple Files &#8221; , make sure you have to put all the source files into your java application running directory (or) put your java .class file&#8217;s into your source directory [...]]]></description>
			<content:encoded><![CDATA[<p>Note:</p>
<p>1) Main Class File: FileEncryptDecrypt.java</p>
<p>2) Result encrypted/decrypted file&#8217;s will be available in your java application files directory it self.</p>
<p>3) In case of  &#8221; Multiple Files &#8221; , make sure you have to put all the source files into your java application running directory (or) put your java .class file&#8217;s into your source directory where the files are available.</p>
<p><span style="text-decoration: underline"><strong>Source Code:</strong></span></p>
<p><strong>1. <span style="text-decoration: underline">FileEncryptDecrypt.java</span></strong></p>
<pre class="brush: java; title: ; notranslate">

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class FileEncryptDecrypt extends JFrame implements ActionListener{

JButton b1,b2,b3,b4;
 Font font;
 JOptionPane op=new JOptionPane();

FileEncryptDecrypt(){

ImageIcon b1i=new ImageIcon(&quot;E.gif&quot;);
 ImageIcon b2i=new ImageIcon(&quot;D.gif&quot;);
 b2=new JButton(&quot;Secure All Files&quot;,b2i);
 ImageIcon img2=new ImageIcon(&quot;java.gif&quot;);
 b3=new JButton(&quot;&quot;,img2);
 ImageIcon img3=new ImageIcon(&quot;brain.gif&quot;);
 ImageIcon img4=new ImageIcon(&quot;NLogo.gif&quot;);
 b1=new JButton(&quot;Secure One File&quot;,img3);
 b4=new JButton(&quot;&quot;,img4);
 b1.setBackground(Color.green);
 b2.setBackground(Color.green);

Container c=getContentPane();
 op.showMessageDialog(this,&quot;Lets Protect Your Data...........&quot;);
 op.showMessageDialog(this,&quot;By Mr.Nanddeswar(MCA)&quot;);
 font=new Font(&quot;times new roman&quot;,Font.BOLD,22);
 c.setLayout(null);
 b1.setBounds(10,10,400,200);
 b2.setBounds(600,10,350,200);
 b4.setBounds(10,620,300,150);
 b3.setBounds(860,620,120,150);
 b1.setFont(font);
 b2.setFont(font);
 b3.setFont(font);
 b4.setFont(font);
 c.add(b1);c.add(b2);c.add(b3);c.add(b4);
 b1.addActionListener(this);
 b2.addActionListener(this);
 b3.addActionListener(this);
 b4.addActionListener(this);

}
 public void actionPerformed(ActionEvent ae){
 Object o=ae.getSource();
 if(o==b1){

SingleFileEncrypt ne=new SingleFileEncrypt();
 ne.setTitle(&quot;Secure One File&quot;);
 ne.setSize(1000,800);
 ne.setVisible(true);
 //ne.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 }

if(o==b2){

MultipleFilesEncrypt nv=new MultipleFilesEncrypt();
 nv.setTitle(&quot;Secure All Files&quot;);
 nv.setSize(1000,800);
 nv.setVisible(true);
 //nv.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 }

if(o==b3){
 op.showMessageDialog(this,&quot;Java Logo&quot;);
 }

if(o==b4){
 op.showMessageDialog(this,&quot;Nandu Logo&quot;);
 }
 }

public static void main(String ar[])throws Exception{

FileEncryptDecrypt ned=new FileEncryptDecrypt();
 ned.setTitle(&quot;Nandu Experiment&quot;);
 ned.setSize(1000,800);
 ned.setVisible(true);
 ned.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 }
}//end of file
</pre>
<p><strong>2.<span style="text-decoration: underline">SingleFileEncrypt.java</span></strong></p>
<pre class="brush: java; title: ; notranslate">

import java.awt.*;
import java.awt.event.*;
import javax.swing.text.*;
import java.util.zip.*;
import javax.swing.*;
import java.io.*;
import javax.swing.border.*;
public class SingleFileEncrypt extends JFrame implements ActionListener{
 JButton b1,b2,b3,b4,close;
 File f;
 Font font;
 JOptionPane op=new JOptionPane();
 String fname=&quot;&quot;;
 FileInputStream fis;
 JFileChooser fc;
 DeflaterOutputStream dos;
 int key=0;
 FileOutputStream fos;
 String ext=&quot;&quot;;
 InflaterInputStream iis;
 String output=&quot;&quot;;
 SingleFileEncrypt(){

ImageIcon b1i=new ImageIcon(&quot;E.gif&quot;);
 ImageIcon b2i=new ImageIcon(&quot;D.gif&quot;);
 b2=new JButton(&quot;Decrypt&quot;,b2i);
 ImageIcon img2=new ImageIcon(&quot;java.gif&quot;);
 b3=new JButton(&quot;&quot;,img2);
 ImageIcon img3=new ImageIcon(&quot;brain.gif&quot;);
 ImageIcon img4=new ImageIcon(&quot;NLogo.gif&quot;);
 b1=new JButton(&quot;Encrypt&quot;,img3);
 b4=new JButton(&quot;&quot;,img4);
 close=new JButton(&quot;Close Window&quot;);
 fc=new JFileChooser();
 b1.setBackground(Color.green);
 b2.setBackground(Color.green);
 Container c=getContentPane();
 op.showMessageDialog(this,&quot;Lets Protect Your Data...........&quot;);
 op.showMessageDialog(this,&quot;By Mr.Nanddeswar(MCA)&quot;);
 font=new Font(&quot;times new roman&quot;,Font.BOLD,33);
 c.setLayout(null);
 b1.setBounds(10,10,300,200);
 b2.setBounds(600,10,300,200);
 b4.setBounds(10,620,300,150);
 b3.setBounds(860,620,120,150);
 close.setBounds(650,620,100,50);
 b1.setFont(font);
 b2.setFont(font);
 b3.setFont(font);
 b4.setFont(font);
 close.setFont(font);
 c.add(b1);c.add(b2);c.add(b3);c.add(b4);c.add(close);
 b1.addActionListener(this);
 b2.addActionListener(this);
 b3.addActionListener(this);
 b4.addActionListener(this);
 close.addActionListener(this);
 }
 public void actionPerformed(ActionEvent ae){
 Object o=ae.getSource();
 if(o==b1){
 int n=fc.showOpenDialog(this);
 if(n==JFileChooser.APPROVE_OPTION){
 f=fc.getSelectedFile();
 try{
 try{
 key=Integer.parseInt(op.showInputDialog(&quot;Enter Key:&quot;));
 }catch(NumberFormatException ne){
 key=2;
 op.showMessageDialog(this,&quot;The default KEY is used&quot;);
 }
 fis=new FileInputStream(f);
 output=op.showInputDialog(this,&quot;Enter the Output Encrypted file Name&quot;);
 if(output.equals(&quot;&quot;))
 {
 output=&quot;Default&quot;;
 op.showMessageDialog(this,&quot;The Default File Name is used&quot;);
 }
 ext=op.showInputDialog(&quot;Enter extention&quot;);
 if(!ext.equals(&quot;&quot;))
 fos=new FileOutputStream(output+&quot;.&quot;+ext);
 else
 {
 fos=new FileOutputStream(output+&quot;.exe&quot;);
 op.showMessageDialog(this,&quot;File created with Default extension&quot;);
 }

dos=new DeflaterOutputStream(fos);
 int ed;
 while((ed=fis.read())!=-1) dos.write(ed+key);
 fis.close();dos.close();fis.close();
 op.showMessageDialog(this,&quot;Encryption Successfully Completed&quot;);
 op.showMessageDialog(this,&quot;Encrypted File will be placed at where the project file is existed &quot;);
 ext=&quot;&quot;;
 output=&quot;&quot;;
 }catch(Exception e){e.printStackTrace();}
 }
 }
 if(o==b4){

 op.showMessageDialog(this,&quot;Nandu Logo&quot;);
 }
 if(o==b2){
 int n=fc.showOpenDialog(this);
 if(n==JFileChooser.APPROVE_OPTION){
 f=fc.getSelectedFile();
 try{
 fis=new FileInputStream(f);
 try{
 key=Integer.parseInt(op.showInputDialog(&quot;Enter Key:&quot;));
 }catch(NumberFormatException ne){
 key=2;
 op.showMessageDialog(this,&quot;The default KEY is used&quot;);
 }
 iis=new InflaterInputStream(fis);
 output=op.showInputDialog(this,&quot;Enter output Decrypted file name&quot;);
 if(output.equals(&quot;&quot;))
 {
 output=&quot;Default&quot;;
 op.showMessageDialog(this,&quot;The Default File Name is used&quot;);
 }
 ext=op.showInputDialog(&quot;Enter extention&quot;);
 if(!ext.equals(&quot;&quot;))
 fos=new FileOutputStream(output+&quot;.&quot;+ext);
 else
 {
 fos=new FileOutputStream(output+&quot;.txt&quot;);
 op.showMessageDialog(this,&quot;File created with Default extension&quot;);
 }
 int dd;
 while((dd=iis.read())!=-1) fos.write(dd-key);
 fis.close();iis.close();fos.close();
 op.showMessageDialog(this,&quot;Decryption Successfully Completed&quot;);
 op.showMessageDialog(this,&quot;Decrypted File will be placed at where the project file is existed &quot;);
 ext=&quot;&quot;;
 output=&quot;&quot;;
 }catch(Exception e){e.printStackTrace();}
 }
 }
 if(o==b3){

 op.showMessageDialog(this,&quot;Java Logo&quot;);
 }

if(o==close){

 this.dispose();
 }
 }

}
//end of file
</pre>
<p><strong>3.<span style="text-decoration: underline">MultipleFilesEncrypt.java</span></strong></p>
<pre class="brush: java; title: ; notranslate">

import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import java.util.zip.*;
import javax.swing.border.*;
class MultipleFilesEncrypt extends JFrame implements ActionListener{
 Container c;
 JOptionPane jp;
 JButton v,av,b3,b4,close;
 String output=&quot;Default&quot;;
 Font font;
 int key=2;
 String ext=&quot;&quot;;
 String oext=&quot;&quot;;
 MultipleFilesEncrypt(){
 c=this.getContentPane();
 font=new Font(&quot;times new roman&quot;,Font.BOLD,33);
 c.setLayout(null);
 jp=new JOptionPane();
 v=new JButton(&quot;Encrypt All Files&quot;);
 c.add(v);

ImageIcon img2=new ImageIcon(&quot;java.gif&quot;);
 ImageIcon img4=new ImageIcon(&quot;NLogo.gif&quot;);

av=new JButton(&quot;Decrypt All Files&quot;);
 c.add(av);

close=new JButton(&quot;Close Window&quot;);
 c.add(close);

b3=new JButton(&quot;&quot;,img2);
 c.add(b3);

b4=new JButton(&quot;&quot;,img4);
 c.add(b4);

v.setBounds(10,10,300,200);
 av.setBounds(600,10,300,200);
 b4.setBounds(10,620,300,150);
 b3.setBounds(860,620,120,150);
 close.setBounds(650,620,100,50);
 v.setFont(font);
 av.setFont(font);
 b3.setFont(font);
 b4.setFont(font);
 close.setFont(font);
 v.addActionListener(this);
 av.addActionListener(this);
 b3.addActionListener(this);
 b4.addActionListener(this);
 close.addActionListener(this);
 }

public void actionPerformed(ActionEvent ae){

Object o=ae.getSource();

if(o==v){
 try{
 key=Integer.parseInt(jp.showInputDialog(&quot;Enter Key to Encrypt:&quot;));

 }catch(NumberFormatException ne){
 key=2;
 jp.showMessageDialog(this,&quot;The default KEY is used&quot;);
 }

output=jp.showInputDialog(this,&quot;Enter the Output Encrypted file's Name:&quot;);
 if(output.equals(&quot;&quot;))
 {
 output=&quot;Default&quot;;
 jp.showMessageDialog(this,&quot;The Default File Name is used.&quot;);
 }
 ext=jp.showInputDialog(&quot;Enter extention of Input file's&quot;);
 if(ext.equals(&quot;&quot;))
 {
 ext=&quot;jpg&quot;;
 jp.showMessageDialog(this,&quot;The Default extention . JPG is used.&quot;);
 }

 oext=jp.showInputDialog(&quot;Enter extention of Output file's to generate:&quot;);
 if(oext.equals(&quot;&quot;))
 {
 oext=&quot;exe&quot;;
 jp.showMessageDialog(this,&quot;The Default extention . EXE is used.&quot;);
 }

jp.showMessageDialog(this,&quot;Wait until all files are created in your folder...&quot;);

File avpath=new File(&quot;MultipleFilesEncrypt.class&quot;);
 String tep=avpath.getAbsolutePath();
 StringTokenizer st=new StringTokenizer(tep,&quot;\\&quot;);
 int j=0;
 String tep2=tep.replace(&quot;\\&quot;,&quot;/&quot;);
 String tep3=&quot;&quot;;
 while(j&lt;st.countTokens()-1){
 tep3+=st.nextToken()+&quot;/&quot;;
 }
 String directory=tep3;
 java.util.List&lt;String&gt; files=new java.util.ArrayList&lt;String&gt;();
 File dir=new File(directory);
 for(File file:dir.listFiles()){
 if(file.getName().endsWith(&quot;.&quot;+ext)){
 files.add(file.getName());
 }
 }
 int listSize=files.size();
 for(int i=0;i&lt;listSize;i++){
 try{
 String s=files.get(i);
 File delete=new File(directory+s);
 Thread.sleep(2000);

 FileInputStream fis=new FileInputStream(delete);
 FileOutputStream fos=new FileOutputStream(output+(i+1)+&quot;.&quot;+oext);
 DeflaterOutputStream dos=new DeflaterOutputStream(fos);
 int ed;
 while((ed=fis.read())!=-1) dos.write(ed+key);
 fis.close();dos.close();fis.close();
 }catch(Exception e){e.printStackTrace();}
 }

jp.showMessageDialog(this,&quot;Encryption Successfully Completed&quot;);
 jp.showMessageDialog(this,&quot;Encrypted File's will be placed at where the project file is existed &quot;);
 key=2;
 ext=&quot;&quot;;
 oext=&quot;&quot;;
 }//end of if(o==v) condition

if(o==av){

try{
 key=Integer.parseInt(jp.showInputDialog(&quot;Enter Key:&quot;));

 }catch(NumberFormatException ne){
 key=2;
 jp.showMessageDialog(this,&quot;The default KEY is used&quot;);
 }

 output=jp.showInputDialog(this,&quot;Enter the Output Encrypted file's Name&quot;);
 if(output.equals(&quot;&quot;))
 {
 output=&quot;Default&quot;;
 jp.showMessageDialog(this,&quot;The Default File Name is used&quot;);
 }
 ext=jp.showInputDialog(&quot;Enter extention of Input file's&quot;);
 if(ext.equals(&quot;&quot;))
 {
 ext=&quot;exe&quot;;
 jp.showMessageDialog(this,&quot;The Default extention . EXE is used.&quot;);
 }

oext=jp.showInputDialog(&quot;Enter extention of Output file's to generate:&quot;);
 if(oext.equals(&quot;&quot;))
 {
 oext=&quot;jpg&quot;;
 jp.showMessageDialog(this,&quot;The Default extention . JPG is used.&quot;);
 }

 jp.showMessageDialog(this,&quot;Please wait until all files are created in your folder...&quot;);

File avpath=new File(&quot;MultipleFilesEncrypt.class&quot;);
 String tep=avpath.getAbsolutePath();
 StringTokenizer st=new StringTokenizer(tep,&quot;\\&quot;);
 int j=0;
 String tep2=tep.replace(&quot;\\&quot;,&quot;/&quot;);
 String tep3=&quot;&quot;;
 while(j&lt;st.countTokens()-1){
 tep3+=st.nextToken()+&quot;/&quot;;
 }
 String directory=tep3;
 java.util.List&lt;String&gt; files=new java.util.ArrayList&lt;String&gt;();
 File dir=new File(directory);
 for(File file:dir.listFiles()){
 if(file.getName().endsWith(&quot;.&quot;+ext)){
 files.add(file.getName());
 }
 }
 int listSize=files.size();
 for(int i=0;i&lt;listSize;i++){
 try{
 String s=files.get(i);
 File delete=new File(directory+s);
 Thread.sleep(2000);
 FileInputStream fis=new FileInputStream(delete);
 InflaterInputStream iis=new InflaterInputStream(fis);
 FileOutputStream fos=new FileOutputStream(output+(i+1)+&quot;.&quot;+oext);
 int dd;
 while((dd=iis.read())!=-1) fos.write(dd-key);
 fis.close();iis.close();fos.close();
 }catch(Exception e){e.printStackTrace();}
 }
 jp.showMessageDialog(this,&quot;Decryption Successfully Completed&quot;);
 jp.showMessageDialog(this,&quot;Decrypted File's will be placed at where the project file is existed &quot;);
 key=2;
 ext=&quot;&quot;;
 oext=&quot;&quot;;
 }//end of if(o==av) condition

if(o==b3){

 jp.showMessageDialog(this,&quot;Java Logo&quot;);
 }
 if(o==b4){

 jp.showMessageDialog(this,&quot;Nandu Logo&quot;);
 }

if(o==close){

 this.dispose();
 }

}//end of actionPerformed() method

}
//end of file

//End of Code....
</pre>
]]></content:encoded>
			<wfw:commentRss>http://techelp.in/thome/2012/02/08/files-encryption-decreption-with-key-swings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Mail &#8211;  Swings GUI ( Send Email / See Inbox from Java Application )</title>
		<link>http://techelp.in/thome/2012/02/08/java-mail-swings-gui-send-email-see-inbox-from-java-application/</link>
		<comments>http://techelp.in/thome/2012/02/08/java-mail-swings-gui-send-email-see-inbox-from-java-application/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 10:01:07 +0000</pubDate>
		<dc:creator>nandeeswar</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Core Java]]></category>
		<category><![CDATA[Java Mail]]></category>
		<category><![CDATA[Java Mail GUI]]></category>
		<category><![CDATA[Java Mail Swings]]></category>
		<category><![CDATA[Swings]]></category>

		<guid isPermaLink="false">http://techelp.in/thome/?p=236</guid>
		<description><![CDATA[Required jar files: 1. activation-1.1.1.jar 2. mail-1.4.1.jar Note: 1) This example is applicable to Gmail account only as of now.If you want to configure another mail account , just change the properties in java files . Source Code: 1. EmailLogin.java 2. SendEmail.java &#160; 3. InboxMail.java //End of Code&#8230;.. &#160; &#160;]]></description>
			<content:encoded><![CDATA[<p>Required jar files:<br />
1. activation-1.1.1.jar<br />
2. mail-1.4.1.jar</p>
<p>Note: 1) This example is applicable to Gmail account only as of now.If you want to configure another mail account , just change the properties in java files .</p>
<p><strong>Source Code:</strong></p>
<p><strong>1.</strong> <strong><span style="text-decoration: underline">EmailLogin.java</span></strong></p>
<pre class="brush: java; title: ; notranslate">

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import com.sun.mail.pop3.POP3Store;
import javax.mail.Folder;

class EmailLogin extends JFrame implements ActionListener{

Container c;

 JLabel fromLabel;
 JLabel emailIdLabel;
 JLabel pwdLabel;

 JTextField emailIdText;
 JPasswordField pwdText;

 JButton login;
 JButton cancel;

 JButton sendMail;
 JButton inbox;

 JButton dispose;

 Properties properties;
 Properties props;

 POP3Store emailStore;

 Session emailSession;
 Session loginSession;

 String fromEmailId=&quot;&quot;;
 String fromEmailPwd=&quot;&quot;;

 String inboxMessagesString=&quot;&quot;;

 Font font;

 public EmailLogin(){
 c=this.getContentPane();
 c.setLayout(null);

 font = new Font(&quot;Times New Roman&quot;, Font.BOLD, 14);

 properties = new Properties();
 properties.put(&quot;mail.pop3.host&quot;, &quot;pop.gmail.com&quot;);

 emailSession=null;
 emailStore=null;

 fromLabel=new JLabel(&quot;From: &quot;);
 emailIdLabel=new JLabel(&quot;Email-ID: &quot;);
 pwdLabel=new JLabel(&quot;Password: &quot;);

 emailIdText=new JTextField(40);
 pwdText=new JPasswordField(40);

 login=new JButton(&quot;Login&quot;);
 cancel=new JButton(&quot;Cancel&quot;);

 sendMail=new JButton(&quot;Compose Mail&quot;);
 inbox=new JButton(&quot;Inbox&quot;);

 dispose=new JButton(&quot;Dispose&quot;);

 login.addActionListener(this);
 cancel.addActionListener(this);
 sendMail.addActionListener(this);
 inbox.addActionListener(this);
 dispose.addActionListener(this);

 emailIdLabel.setBounds(200,50,200,30);
 emailIdText.setBounds(300,50,200,30);
 emailIdText.setFont(font);

 pwdLabel.setBounds(200,100,200,30);
 pwdText.setBounds(300,100,200,30);
 pwdText.setFont(font);

login.setBounds(230,150,100,30);
 cancel.setBounds(390,150,100,30);
 sendMail.setBounds(230,250,130,30);
 inbox.setBounds(390,250,100,30);
 dispose.setBounds(670,420,100,30);
 sendMail.hide();
 inbox.hide();
 dispose.hide();

 c.add(fromLabel);

 c.add(emailIdLabel);
 c.add(emailIdText);

 c.add(pwdLabel);
 c.add(pwdText);

 c.add(login);
 c.add(cancel);
 c.add(sendMail);
 c.add(inbox);
 c.add(dispose);

 }

 public void actionPerformed(ActionEvent ae){

 Object o=ae.getSource();

 if(o==login){
 try{

 //Session emailSession = Session.getDefaultInstance(properties);

 props =System.getProperties();
 props.put(&quot;mail.smtp.host&quot;, &quot;smtp.gmail.com&quot;);
 props.put(&quot;mail.smtp.socketFactory.port&quot;, &quot;465&quot;);
 props.put(&quot;mail.smtp.socketFactory.class&quot;,&quot;javax.net.ssl.SSLSocketFactory&quot;);
 props.put(&quot;mail.smtp.auth&quot;, &quot;true&quot;);
 props.put(&quot;mail.smtp.port&quot;, &quot;465&quot;);
 props.put(&quot;mail.smtp.user&quot;, emailIdText.getText());
 props.put(&quot;mail.smtp.password&quot;,pwdText.getText());
 props.put(&quot;mail.pop3.host&quot;, &quot;pop.gmail.com&quot;);

 loginSession = Session.getDefaultInstance(props,
 new javax.mail.Authenticator() {
 protected PasswordAuthentication getPasswordAuthentication() {
 return new PasswordAuthentication(emailIdText.getText(),pwdText.getText());
 }
 });

 emailStore = (POP3Store) loginSession.getStore(&quot;pop3&quot;);
 emailStore.connect(emailIdText.getText(),pwdText.getText());

 Folder emailFolder = emailStore.getFolder(&quot;INBOX&quot;);
 emailFolder.open(Folder.READ_ONLY);

Message[] messages = emailFolder.getMessages();
 //System.out.println(&quot;messages.length : &quot;+messages.length);

 //for (int i = 0; i &lt; messages.length; i++) {
 for (int i = 0; i &lt; 10; i++) {
 Message message = messages[i];
 inboxMessagesString+=&quot;==============================\n&quot;+
 &quot;Email #&quot; + (i + 1)+&quot;\n&quot;+
 &quot;Subject: &quot; + message.getSubject()+&quot;\n&quot;+
 &quot;From: &quot; + message.getFrom()[0]+&quot;\n&quot;+
 &quot;Text: &quot; + message.getContent().toString()+&quot;\n&quot;;
 /*
 System.out.println(&quot;==============================&quot;);
 System.out.println(&quot;Email #&quot; + (i + 1));
 System.out.println(&quot;Subject: &quot; + message.getSubject());
 System.out.println(&quot;From: &quot; + message.getFrom()[0]);
 System.out.println(&quot;Text: &quot; + message.getContent().toString());
 */
 }

emailFolder.close(false);
 emailStore.close();

 JOptionPane.showMessageDialog(this,&quot;Login Success..&quot;);
 fromEmailId=emailIdText.getText();
 fromEmailPwd=pwdText.getText();

 emailIdText.setEditable(false);
 pwdText.setEditable(false);

 login.setEnabled(false);
 cancel.setEnabled(false);

 sendMail.show();
 inbox.show();
 dispose.show();

 }catch(Exception e){
 emailIdText.setText(&quot;&quot;);
 pwdText.setText(&quot;&quot;);
 JOptionPane.showMessageDialog(this,&quot;Login Failure.Try again..&quot;);
 }

 }
 else if(o==cancel){
 try{
 if(emailStore!=null) emailStore.close();
 }catch(Exception e){}
 this.dispose();
 }

 if(o==sendMail){
 SendEmail se=new SendEmail(loginSession,fromEmailId,fromEmailPwd);
 se.setTitle(&quot;Send Email...&quot;);
 //se.setSize(width,height);
 se.setSize(900,750);
 se.setVisible(true);
 }

 if(o==inbox){
 InboxMail im=new InboxMail(fromEmailId,fromEmailPwd,inboxMessagesString);
 im.setTitle(&quot;Mail Inbox...&quot;);
 //im.setSize(width,height);
 im.setSize(900,750);
 im.setVisible(true);
 }
 if(o==dispose){
 this.dispose();
 }
 }

 public static void main(String ar[]){

 EmailLogin se=new EmailLogin();
 se.setTitle(&quot;Login Page...&quot;);
 //se.setSize(width,height);
 se.setSize(800,500);
 se.setVisible(true);

 }

}
</pre>
<p><strong>2.</strong> <strong><span style="text-decoration: underline">SendEmail.java</span></strong></p>
<p>&nbsp;</p>
<pre class="brush: java; title: ; notranslate">

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

class SendEmail extends JFrame implements ActionListener{

 Container c;

 JLabel fromLabel;
 JLabel emailIdLabel;
 JLabel pwdLabel;
 JLabel toLabel;
 JLabel ccLabel;
 JLabel bccLabel;
 JLabel subjectLabel;
 JLabel textLabel;

 JTextField emailIdText;
 JPasswordField pwdText;
 JTextField toText;
 JTextField ccText;
 JTextField bccText;
 JTextField subjectText;

 JTextArea textArea;

 JButton sendButton;
 JButton discardButton;

 Font font;
 Session loginSession;

 String fromEmailId;
 String fromEmailPwd;

 public SendEmail(Session loginSession,String fromEmailId,String fromEmailPwd){

 this.loginSession=loginSession;
 this.fromEmailId=fromEmailId;
 this.fromEmailPwd=fromEmailPwd;

 c=this.getContentPane();
 c.setLayout(null);

 font = new Font(&quot;Times New Roman&quot;, Font.BOLD, 14);

 fromLabel=new JLabel(&quot;From: &quot;);
 emailIdLabel=new JLabel(&quot;Email-ID: &quot;);
 pwdLabel=new JLabel(&quot;Password: &quot;);
 toLabel=new JLabel(&quot;To: &quot;);
 ccLabel=new JLabel(&quot;CC: &quot;);
 bccLabel=new JLabel(&quot;BCC: &quot;);
 subjectLabel=new JLabel(&quot;Subject: &quot;);
 textLabel=new JLabel(&quot;Text: &quot;);

 emailIdText=new JTextField(40);
 pwdText=new JPasswordField(40);
 toText=new JTextField(60);
 ccText=new JTextField(60);
 bccText=new JTextField(60);
 subjectText=new JTextField(60);

 textArea=new JTextArea(10,60);

 sendButton=new JButton(&quot;Send&quot;);
 discardButton=new JButton(&quot;Discard&quot;);

 sendButton.addActionListener(this);
 discardButton.addActionListener(this);

 //component.setBounds(y,x,width,height);
 fromLabel.setBounds(10,10,200,30);

 emailIdLabel.setBounds(100,10,200,30);
 emailIdText.setBounds(200,10,200,30);
 emailIdText.setFont(font);
 emailIdText.setText(fromEmailId);
 emailIdText.setEditable(false);

 pwdLabel.setBounds(100,50,200,30);
 pwdText.setBounds(200,50,200,30);
 pwdText.setFont(font);
 pwdText.setText(fromEmailPwd);
 pwdText.setEditable(false);

 toLabel.setBounds(10,100,400,30);
 toText.setBounds(100,100,400,30);
 toText.setFont(font);

 ccLabel.setBounds(10,150,400,30);
 ccText.setBounds(100,150,400,30);
 ccText.setText(&quot;&quot;);
 ccText.setFont(font);

 bccLabel.setBounds(10,200,400,30);
 bccText.setBounds(100,200,400,30);
 bccText.setText(&quot;&quot;);
 bccText.setFont(font);

 subjectLabel.setBounds(10,250,400,30);
 subjectText.setBounds(100,250,400,30);
 subjectText.setFont(font);

 textLabel.setBounds(10,300,400,30);
 textArea.setBounds(100,300,700,200);
 textArea.setFont(font);

 sendButton.setBounds(100,600,200,30);
 discardButton.setBounds(400,600,200,30);

 c.add(fromLabel);

 c.add(emailIdLabel);
 c.add(emailIdText);

 c.add(pwdLabel);
 c.add(pwdText);

 c.add(toLabel);
 c.add(toText);

 c.add(ccLabel);
 c.add(ccText);

 c.add(bccLabel);
 c.add(bccText);

 c.add(subjectLabel);
 c.add(subjectText);

 c.add(textLabel);
 c.add(textArea);

 c.add(sendButton);
 c.add(discardButton);

 }

 public void actionPerformed(ActionEvent ae){

 Object o=ae.getSource();
 if(o==sendButton){
 /*
 Properties props =System.getProperties();
 props.put(&quot;mail.smtp.host&quot;, &quot;smtp.gmail.com&quot;);
 props.put(&quot;mail.smtp.socketFactory.port&quot;, &quot;465&quot;);
 props.put(&quot;mail.smtp.socketFactory.class&quot;,&quot;javax.net.ssl.SSLSocketFactory&quot;);
 props.put(&quot;mail.smtp.auth&quot;, &quot;true&quot;);
 props.put(&quot;mail.smtp.port&quot;, &quot;465&quot;);
 props.put(&quot;mail.smtp.user&quot;, emailIdText.getText());
 props.put(&quot;mail.smtp.password&quot;,pwdText.getText());

 //Session session = Session.getDefaultInstance(props,null);

 Session session = Session.getDefaultInstance(props,
 new javax.mail.Authenticator() {
 protected PasswordAuthentication getPasswordAuthentication() {
 return new PasswordAuthentication(emailIdText.getText(),pwdText.getText());
 }
 });
 */
 try {

 Message message = new MimeMessage(loginSession);
 message.setFrom(new InternetAddress(emailIdText.getText()));

 String recipientsString=toText.getText();

 if(!(ccText.getText().equals(&quot;&quot;))){
 recipientsString=recipientsString+&quot;,&quot;+ccText.getText();
 }
 if(!(bccText.getText().equals(&quot;&quot;))){
 recipientsString=recipientsString+&quot;,&quot;+bccText.getText();
 }

 message.setRecipients(Message.RecipientType.TO,
 InternetAddress.parse(recipientsString));

 message.setSubject(subjectText.getText());
 message.setText(textArea.getText());

 Transport transport = loginSession.getTransport(&quot;smtp&quot;);
 transport.connect(&quot;smtp.gmail.com&quot;, emailIdText.getText(), pwdText.getText());
 transport.send(message);
 transport.close();

 JOptionPane.showMessageDialog(this,&quot;Message send Success..&quot;);

 toText.setText(&quot;&quot;);
 ccText.setText(&quot;&quot;);
 bccText.setText(&quot;&quot;);
 subjectText.setText(&quot;&quot;);
 textArea.setText(&quot;&quot;);
 //System.out.println(&quot;Done&quot;);

 } catch (MessagingException e) {
 JOptionPane.showMessageDialog(this,&quot;Message send Faild. Please check input details and send again..&quot;);
 //throw new RuntimeException(e);
 }
 }else if(o==discardButton){
 this.dispose();
 }
 }

}
</pre>
<p><strong>3.</strong> <span style="text-decoration: underline"><strong>InboxMail.java</strong></span></p>
<pre class="brush: java; title: ; notranslate">

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.NoSuchProviderException;
import javax.mail.Session;

import java.util.*;

import com.sun.mail.pop3.POP3Store;

class InboxMail extends JFrame implements ActionListener{

 Container c;

 JLabel inboxLabel;

 JScrollPane scrolltxt;

 JTextArea textArea;

 JButton okButton;

 Font font;
 String fromEmailId=&quot;&quot;;
 String fromEmailPwd=&quot;&quot;;

 String inboxMessagesString=&quot;&quot;;

 public InboxMail(String fromEmailId,String fromEmailPwd,String inboxMessageString){

 this.fromEmailId=fromEmailId;
 this.fromEmailPwd=fromEmailPwd;
 this.inboxMessagesString=inboxMessageString;

 c=this.getContentPane();
 c.setLayout(null);

 font = new Font(&quot;Times New Roman&quot;, Font.BOLD, 14);

 inboxLabel=new JLabel(&quot;Mail Inbox: &quot;);

 textArea=new JTextArea();

 scrolltxt = new JScrollPane(textArea);

 okButton=new JButton(&quot;Ok&quot;);

 okButton.addActionListener(this);

 inboxLabel.setBounds(10,10,200,30);
 scrolltxt.setBounds(100,50,700,500);
 textArea.setFont(font);
 textArea.setText(inboxMessagesString);

 okButton.setBounds(600,600,200,30);

 c.add(inboxLabel);

 c.add(scrolltxt);

 c.add(okButton);

 }

 public void actionPerformed(ActionEvent ae){
 Object o=ae.getSource();
 if(o==okButton){
 this.dispose();
 }
 }

}
</pre>
<p>//End of Code&#8230;..</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://techelp.in/thome/2012/02/08/java-mail-swings-gui-send-email-see-inbox-from-java-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Capturing Screenshot in Java</title>
		<link>http://techelp.in/thome/2010/11/20/capturing-screenshot-in-java/</link>
		<comments>http://techelp.in/thome/2010/11/20/capturing-screenshot-in-java/#comments</comments>
		<pubDate>Sat, 20 Nov 2010 03:14:18 +0000</pubDate>
		<dc:creator>Sudha C Reddi</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://techelp.in/thome/2010/11/20/capturing-screenshot-in-java/</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: java; title: ; notranslate">
package in.techelp;

import java.awt.AWTException;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;

/**
 *
 * @author reddy
 */
public class Screenshot {

    public static void main(String[] args) throws AWTException, IOException {
        Robot robot = new Robot();
        BufferedImage screenShot = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
        ImageIO.write(screenShot, &quot;jpg&quot;, new File(&quot;/home/reddy/Documents/screenshot.jpg&quot;));
        //ImageIO.write(screenShot, &quot;png&quot;, new File(&quot;/home/reddy/Documents/screenshot.png&quot;));
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://techelp.in/thome/2010/11/20/capturing-screenshot-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add contact to Address Book using iPhone SDK</title>
		<link>http://techelp.in/thome/2009/10/06/add-contact-to-address-book-using-iphone-sdk/</link>
		<comments>http://techelp.in/thome/2009/10/06/add-contact-to-address-book-using-iphone-sdk/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 23:43:57 +0000</pubDate>
		<dc:creator>Sudha C Reddi</dc:creator>
				<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[Address Book API]]></category>

		<guid isPermaLink="false">http://techelp.in/mobile/?p=4</guid>
		<description><![CDATA[Below is the code for adding a contact to iPhone’s Address Book using iPhone SDK.]]></description>
			<content:encoded><![CDATA[<p><br/><br />
Below is the code for adding a contact to iPhone’s Address Book using iPhone SDK.<br />
<br/></p>
<pre class="brush: objc; title: ; notranslate">
ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef person = ABPersonCreate();

ABRecordSetValue(person, kABPersonFirstNameProperty, @&quot;Sudha&quot; , nil);
ABRecordSetValue(person, kABPersonLastNameProperty, @&quot;Reddy&quot;, nil);

ABMutableMultiValueRef phoneNumberMultiValue = ABMultiValueCreateMutable(kABPersonPhoneProperty);
ABMultiValueAddValueAndLabel(phoneNumberMultiValue, @&quot;1234567890&quot;, kABHomeLabel, nil);
ABMultiValueAddValueAndLabel(phoneNumberMultiValue, @&quot;9876543210&quot;, kABPersonPhoneMobileLabel, nil);
ABMultiValueAddValueAndLabel(phoneNumberMultiValue, @&quot;04022222222&quot;, kABWorkLabel, nil);
ABRecordSetValue(person, kABPersonPhoneProperty, phoneNumberMultiValue, nil);

ABMutableMultiValueRef emailMultiValue = ABMultiValueCreateMutable(kABPersonEmailProperty);
ABMultiValueAddValueAndLabel(emailMultiValue, @&quot;whatever@gmail.com&quot;, kABWorkLabel, nil);
ABRecordSetValue(person, kABPersonEmailProperty, emailMultiValue, nil);

NSDictionary *dictionary = [[NSDictionary alloc] initWithObjects: [NSArray arrayWithObjects:@&quot;1234 Whatever Street&quot;, @&quot;Hyderabad&quot;, @&quot;AP&quot;, @&quot;INDIA&quot;, @&quot;500008&quot;, nil] forKeys: [NSArray arrayWithObjects: (NSString *)kABPersonAddressStreetKey, (NSString *)kABPersonAddressCityKey, (NSString *)kABPersonAddressStateKey, (NSString *)kABPersonAddressCountryKey, (NSString *)kABPersonAddressZIPKey, nil]];
ABMultiValueRef addressMultiValue = ABMultiValueCreateMutable(kABDictionaryPropertyType);
ABMultiValueAddValueAndLabel(addressMultiValue, (CFDictionaryRef *)dictionary, kABWorkLabel, nil);
ABRecordSetValue(person, kABPersonAddressProperty, addressMultiValue, nil); ABRecordCopyValue(person, kABPersonAddressProperty);

ABAddressBookAddRecord(addressBook, person, nil);
ABAddressBookSave(addressBook, nil);

CFRelease(person);
CFRelease(addressMultiValue);
CFRelease(phoneNumberMultiValue);
CFRelease(emailMultiValue);
[dictionary release];
</pre>
]]></content:encoded>
			<wfw:commentRss>http://techelp.in/thome/2009/10/06/add-contact-to-address-book-using-iphone-sdk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ektron Category search</title>
		<link>http://techelp.in/thome/2009/09/11/ektron-category-search/</link>
		<comments>http://techelp.in/thome/2009/09/11/ektron-category-search/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 18:14:50 +0000</pubDate>
		<dc:creator>sharath</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Ektron]]></category>

		<guid isPermaLink="false">http://techelp.in/msblog/?p=46</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: vb; title: ; notranslate">
Dim search As SearchManager = New SearchManager()
Dim requestData As SearchRequestData = New SearchRequestData()

requestData.LanguageID = 1033
requestData.SearchType = WebSearchType.none
requestData.SearchText = &quot; (@TaxCategory '\\MapCategory') &quot; '&quot;( @contenttype = 1 ) and  (  @docTitle Tech* OR  @Contents computer*  ) And (  @TaxCategory '\MapCategory' OR '\Restaurant' OR '\Ektron Products&quot;
'requestData.SearchText = &quot;( @contenttype = 1 ) and  (  @docTitle Ek* OR  @Contents Ek*  ) And OR @TaxCategory '\Furniture')(  @TaxCategory '\Continents' OR '\Stores' OR '\Chemicals' OR '\Ektron Tech' ) and (    @taxonomyenabled = 1 ) and ( @contentlanguage = 1033 ) and ( @searchable = 1 )&quot;
requestData.FolderID = 0
Dim resultCount As Integer
' Dim result() As SearchResponseData = search.Search(requestD
Dim result() As SearchResponseData = search.Search(requestData, HttpContext.Current, resultCount)

GridView1.DataSource = result
GridView1.DataBind()
</pre>
]]></content:encoded>
			<wfw:commentRss>http://techelp.in/thome/2009/09/11/ektron-category-search/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating Multiple Users in Active Directory</title>
		<link>http://techelp.in/thome/2009/08/26/creating-multiple-users-in-active-directory/</link>
		<comments>http://techelp.in/thome/2009/08/26/creating-multiple-users-in-active-directory/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 11:14:34 +0000</pubDate>
		<dc:creator>suresh</dc:creator>
				<category><![CDATA[Windows Admin]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://techelp.in/msblog/?p=40</guid>
		<description><![CDATA[- Paste the below given script in Notepad - Save it with .bat (Windows Batch File) file ou -&#62; Organization Unit (given as &#8220;Network&#8221; in the script, replace it with your Organization Unit name) dc -&#62; Domain Controller (given as &#8220;mailserver&#8221; in the script, replace it with your Domain Controller name, donot chnage the value [...]]]></description>
			<content:encoded><![CDATA[<p>- Paste the below given script in Notepad<br />
- Save it with .bat (Windows Batch File) file</p>
<pre class="brush: bash; title: ; notranslate">
@echo off
cls
echo Creating Accounts
echo ------------------
for /f &quot;tokens=1-3&quot; %%A in (userlist.txt) do (dsadd user &quot;CN=%%A,ou=Network,dc=mailserver,dc=com&quot; -fn %%B -ln %%C -display &quot;%%B %%C&quot; -upn %%A@thenguyen.local -pwd Passw0rd1 -mustchpwd No -disabled no)
echo ------------------
pause
</pre>
<p>ou -&gt; Organization Unit (given as &#8220;Network&#8221; in the script, replace it with your Organization Unit name)<br />
dc -&gt; Domain Controller (given as &#8220;mailserver&#8221; in the script, replace it with your Domain Controller name, donot chnage the value dc=com)</p>
<p>Create a file with name &#8220;userlist.txt&#8221; and save all the user details in the below mentioned format.</p>
<pre class="brush: plain; title: ; notranslate">
raju    Raju    Rao
kalyan  Chakra  Naidu
chiru   Chiru   Reddy
</pre>
<p>First Column -&gt; User Name<br />
Second Column -&gt; First Name<br />
Thirm Column -&gt; Last Name</p>
<p>Place both the batch and userlist.txt files in same folder.<br />
Run the batch file. The users mentioned in userlist.txt will be created.</p>
<p><strong>Note: User must have Administrator privilages to run this batch.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://techelp.in/thome/2009/08/26/creating-multiple-users-in-active-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ektron Collection Control in Code behind</title>
		<link>http://techelp.in/thome/2009/08/20/ektron-collection-control-in-code-behind/</link>
		<comments>http://techelp.in/thome/2009/08/20/ektron-collection-control-in-code-behind/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 16:43:41 +0000</pubDate>
		<dc:creator>sharath</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Ektron]]></category>

		<guid isPermaLink="false">http://techelp.in/msblog/?p=38</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: csharp; title: ; notranslate">

// This code is useful for creating Ektron's Collection control in Code behind of aspx/ascx

Ektron.Cms.Controls.Collection colCtrl = new Ektron.Cms.Controls.Collection();

colCtrl.DefaultCollectionID = 12; // Check this id from the Work area.

colCtrl.WrapTag = &quot;div&quot;;

colCtrl.Visible = true;

colCtrl.DisplayXslt = &quot;ecmTeaser&quot;; //builtin Style

colCtrl.Page = this.Page;

XslCompiledTransform docXsl = new XslCompiledTransform();// System.Xml.Xsl

StringWriter transform = new StringWriter(); //System.IO;

docXsl.Load(Server.MapPath(&quot;xslt\\list.xslt&quot;));

docXsl.Transform(colCtrl.XmlDoc, null, transform);

colCtrl.Text = transform.ToString();

pn.Controls.Add(colCtrl);
</pre>
<pre class="brush: xml; title: ; notranslate">

//@@@@@@@@@@@@@ XSLT snippet  @@@@@@@@@@@@@@@@

&lt;?xml version=&quot;1.0&quot; encoding=&quot;iso-8859-1&quot;?&gt;

&lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;&lt;a href=&quot;http://www.w3.org/1999/XSL/Transform&quot;&gt;http://www.w3.org/1999/XSL/Transform&lt;/a&gt;&quot;&gt;

&lt;xsl:template match=&quot;/&quot;&gt;

&lt;ul&gt;

&lt;xsl:for-each select=&quot;Collection/Content&quot;&gt;

&lt;li&gt;

&lt;a&gt;

&lt;xsl:attribute name=&quot;href&quot;&gt;

&lt;xsl:value-of select=&quot;QuickLink&quot;/&gt;

&lt;/xsl:attribute&gt;

&lt;xsl:value-of select=&quot;Title&quot;/&gt;

&lt;/a&gt;

&lt;p  &gt;

&lt;xsl:value-of select=&quot;&quot; /&gt;

&lt;/p&gt;

&lt;/li&gt;

&lt;/xsl:for-each&gt;

&lt;/ul&gt;

&lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;

//@@@@@@@@@@@@@ XSLT snippet ENDS @@@@@@@@@@@@@@@@
</pre>
]]></content:encoded>
			<wfw:commentRss>http://techelp.in/thome/2009/08/20/ektron-collection-control-in-code-behind/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

