Source Code

Retrieve email according to specified date time using pop3 in java
Retrieve email according to specified date time using pop3 in javapublic void downloadEmailAttachments(String host, String port,String userName, String password) {  Properties properties = new Properties();  properties.put("mail.pop3.host", host);  properties.put("mail.pop3.port", port);  properties…[ More ]
JavaMail Attachment Download
JavaMail Attachment Download I'm having troubles downloading a simple jpg attachment from a Gmail Message. It only seems to download 251 bytes and stops. I'm using the JavaMail API. Code below: public boolean downloadAttachment(File file, Message m, int partNumber) {     try {     Multipart mp = nul…[ More ]
Sending a simple text
Sending a simple text// Common variablesString host = "your_smtp_server";String from = "from_address";String to = "to_address"; // Set propertiesProperties props = new Properties();props.put("mail.smtp.host", host);props.put("mail.debug", "true"); // Get sessionSession session = Session.getInstance(…[ More ]
Java Mail For Windows users only
Java MailFor Windows users onlyPre-Requisites:•jdk1.6.0_11 ( works with previous versions of JDK)  Installed location:•jdk1.6.0_11 ->  C:\Program Files\Java\jdk1.6.0_11\•mail.jar ->  D:\apache-tomcat-6.0.18\lib\mail-1.3.3.jarEnvironment Variables:Enter Variable name and Variable value which is…[ More ]
How to create an e-mail client in Java
This Java tips shows how to create an email client in Java. You will need JavaMail API to compile this example. You can download it from here. The example contains the following files/classes:EmailClient: The main class for the e-mail client application ConnectDialog: This class displays a dialog fo…[ More ]
How to create a virtual desktop in your application
How to create a virtual desktop in your application This Java Swing tip illustrates a method of using the background of your application as a virtual desktop. This code uses JDesktopPane which is a container (usually for JInternalFrames) that simulates a desktop. Typically, the user will create JInt…[ More ]
How to create a Toolbar
How to create a Toolbar A toolbar is a container that groups several components into a row or column. These components are most often buttons. Toolbars are created using JToolBar class available in Java Swing.The example code below shows how to use toolbars in Swing applications:import java.awt.*;im…[ More ]
How to create a simple browser in Swing
This example shows how to create a simple browser in Swing. The course code of the simple browser is written below:import java.awt.*;import java.awt.event.*;import java.net.*;import java.util.*;import javax.swing.*;import javax.swing.event.*;import javax.swing.text.html.*;// The Simple Web Browser.p…[ More ]
How to create a Search Crawler in Java
How to create a Search Crawler in Java With Search Crawler shown in this tip, you can enter search criteria and then search the Web in real time, URL by URL, looking for matches to the criteria.The content of the SearchCrawler.java file is written below:import java.awt.*;import java.awt.event.*;impo…[ More ]
How to create a Editable combobox that include both text and icons
How to create a Editable combobox that include both text and icons This Java Swing tip illustrates a method of creating a Editable combobox that include both text and icons. The tip demonstrates a fancy example of JComboBox with a custom renderer and editor. The custom renderer and editor are used t…[ More ]
Java Mail Code To Send EMAIL
E-Mailing Through Java Mail* You use the JavaMail API where as JavaMail implementation providers implement the JavaMail API to give you a JavaMail client (Java JAR file). Sun gives you mail.jar which has Sun's SMTP, POP3 and IMAP client implementations along with the JavaMail API. This is sufficient…[ More ]
Java code sending Mail with Attachment using Java Mail API
Java code sending Mail with Attachment using Java Mail APIIntroductionIn a day-to-day life the emails are occupied our life.If we can send our mails by using our java code without help of browser how we feel? This article do this.By using the JavaMail API send our mail with attachment without help o…[ More ]
Java: Reading Email using Javamail API
 Java: Reading Email using Javamail API    The previous tutorial explains to send email using Javamail API. Now lets see how to read/retreive email in your inbox using Javamail API. Its very simple, this tutorial explains this step by step. If you have not configured Javamail API in your IDE,…[ More ]
Upload, list and download files with Dropbox Java API
Upload, list and download files with Dropbox Java API import com.dropbox.core.DbxAppInfo;import com.dropbox.core.DbxAuthFinish;import com.dropbox.core.DbxClient;import com.dropbox.core.DbxEntry;import com.dropbox.core.DbxException;import com.dropbox.core.DbxRequestConfig;import com.dropbox.core.Db…[ More ]
Stuck at File Upload Download App in DropBox using java
Stuck at File Upload Download App in DropBox using javaI am working on Dropbox api using java. first app is to upload and download file in dropbox account. I got a token to authenticate with dropbox but when i try to uploading file in account i get bad request error like:Exception in thread "main"…[ More ]
To Upload and Download a File in Dropbox using Java
To Upload and Download a File in Dropbox using Java 1.Download and install  Java JDK 7(Oracle one or the OpenJDK)2.Download and Install IDE like Eclipse or Netbeans(Preferred)3.Create a Dropbox Developer Account(Skip this step is you already have it)4.Create an App at https://www.dropbox.com/develop…[ More ]
upload file to dropbox programatically
 to upload a file to dropbox programatically. Basically file can be uploaded through dropbox api. But the question is how could i upload it by java rest based web service. The program to get the file is:@Path("/file") public class UploadFile {@POST@Path("/upload")@Consumes(MediaType.MULTIPART_FORM_D…[ More ]
Using the Core API in Java
Using the Core API in JavaThe Core API is based on HTTP and OAuth and provides low-level calls to access and manipulate a user's Dropbox account.If you want to follow along, first register a new app on the App Console. You'll need the app key to access the Core API. Then install the Java SDK and you…[ More ]
Draw a line in a JPanel with button click in Java
Draw a line in a JPanel with button click in JavaI find many examples but the problem is the how to use it.In many exmples, always they draw in a JFrame that extends from a JPanel.I want to add the Panel to the Frame and add some buttons to draw lines in many directions and use the X button in cente…[ More ]
Java Examples - Display line using GUI
How to draw a line using GUI?Solution:Following example demonstrates how to draw a line using draw() method of Graphics2D class with Line2D object as an argument.import java.awt.*;import java.awt.event.*;import java.awt.geom.Line2D;import javax.swing.JApplet;import javax.swing.JFrame;public class Ma…[ More ]