Skip to main content

Posts

Showing posts from 2014

HOW TO SEND EMAIL WITH ATTACHMENT IN JAVA APPLICATION

Simple application to send an email using java application Example : import javax.activation.DataHandler; import javax.activation.FileDataSource; import javax.mail.*; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMultipart; import java.util.Date; import java.util.Properties;   public class EmailAttachmentDemo {        public static void main(String[] args) {          EmailAttachmentDemo demo = new EmailAttachmentDemo();          demo.sendEmail();      }        public void sendEmail() {          String from = "email@example.com";          String to = "email@example.com";          String subject = "Important Message";          String bodyText = "T...

HOW TO SEND AND EMAIL USING JAVA APPLICATION

Simple example to send an email (without attachment ) using java application Syntax : Example : import javax.mail.Session; import javax.mail.Message; import javax.mail.Transport; import javax.mail.MessagingException; import javax.mail.internet.MimeMessage; import javax.mail.internet.InternetAddress; import java.util.Properties;   public class Main {   public static void main(String[] args) {     String from = "user@some-domain.com";     String to = "user@some-domain.com";     String subject = "Hi There...";     String text = "How are you?";       Properties properties = new Properties();     properties.put("mail.smtp.host", "smtp.some-domain.com");     properties.put("mail.smtp.port", "25");     Session session = Session.getDefaultInstance(properties, null);       Message message = new MimeMessage(s...

JAVA BASICS - HOW TO USE A STRING IN SWITCH STATEMENTS

Simple example to switch statements using string. Syntax : switch(String variable) { case "" : case "" : case "" : : : . } Example : public class StringSwitchDemo { public static void main(String[] args) {                StringSwitchDemo demo = new StringSwitchDemo();                String day = "Sunday";                switch (day)                {                               case "Sunday":                               demo.doSomething();                               break;                         ...

JDBC - JAVA DATABASE CONNECTIVITY

Java Database connectivity: JDBC is not that difficult as it seem to. Following steps will guide you to set up a java database connection. In the end a simple example will get you the clear idea of how this thing actually works. Step 1: Firstly open "Data Sources".  Start -> Control panel ->Administrative tools -> Data Sources Now you have to add data source that JDBC - ODBC bridge driver can open. To do so click add and the following dialog will appear. Make sure you select Microsoft Access Driver driver as shown above and click finish. In the next screen enter the name of data source name. This is the name you will be using in your java code to open your database, also enter description. Use select button to browse your MS access file that you have created. Click ok .Your database will now be in the list of data source.  Following is the sample java code that will help you to interface your database file. import java.sql.*; ...

SEQUENCER

Title: Sequencer Circuit: Components: IC 555 IC 4017 Resistor: 1 M 470 ohms    x 10 Capacitor: 0.1 uf Battery: 9 - 12 volt Description: The model 4017 integrated circuit is a CMOS counter with ten output terminals. One of these ten terminals will be in a "high" state at any given time, with all others being "low," giving a "one-of-ten" output sequence. If low-to-high voltage pulses are applied to the "clock" (Clk) terminal of the 4017, it will increment its count, forcing the next output into a "high" state. With a 555 timer connected as an astable multivibrator (oscillator) of low frequency, the 4017 will cycle through its ten-count sequence, lighting up each LED, one at a time, and "recycling" back to the first LED. The result is a visually pleasing sequence of flashing lights. Feel free to experiment with resistor and capacitor values on the 555 timer to create different flash rate...

SIMPLE METAL DETECTOR

Title :  A Simple metal detector Circuit:  Components: Capacitor: 1000 uf   x 1 4.7 nf      x 1  10 nf       x 2   Resistor: 10 k (variable resistor) 1 k Oscillator:     x2  40 Khz Miscellaneous: Switch 9v battery Piezo sounder Enammeled copper wire Description: This circuit uses a single coil and nine components to make a particularly sensitive low-cost metal locator. It works on the principle of a beat frequency oscillator (BFO). The circuit incorporates two oscillators, both operating at about 40kHz. The first, IC1a, is a standard CMOS oscillator with its frequency adjustable via VR1. The frequency of the second, IC1b, is highly dependent on the inductance of coil L1, so that its frequency shifts in the presence of metal. L1 is 70 turns of 0.315mm enamelled copper wire wound on a 120mm diameter former. The Faraday shield is made of aluminium foil, which is wound around a...

HEART RATE MONITOR

Title: Heart Rate Monitor Circuit: Components: Resistors: 100 k x 2 3.3 M x 2 15 k x 2 220 k x 1 10 M OPamps: x 2 Capacitor: 0.1 uf 4.7 uf 10 uf Battery:  A 9v battery Miscellaneous: Multimeter: LDR:(Z-4801) Switch:  Description: The secret is a high gain circuit, based on a dual op amp IC which can be either the low power LM358 or the JFET TL072. The LDR is connected in series across the 9V battery supply via a 100kO resistor (R1) and the minute signal caused by the blood pulsing under the skin is fed to the non-inverting (+) input, pin 3, of IC1a via a 0.µF capacitor. Pin 3 is biased by a high impedance voltage divider consisting of two 3.3MO resistors. The feedback resistors to pin 2 set the gain to 11 times. The output of IC1a is fed via a 0.47µF capacitor and 220kO resistor to IC1b. This is configured as an inverting op amp with a gain of 45 so that the total circuit gain is about 500. The output of IC1b is used to dr...

HOW TO ADD BACKGROUND IMAGE IN JAVA SWING

The simple example to insert an image to background of frame in java Syntax : ImageIcon("Path-to-imagefile//image_name.its-extension"))); Example :  import javax.swing.*; import java.awt.*; import java.awt.event.*; class BackgroundImageJFrame extends JFrame { JButton b1; JLabel l1;                public BackgroundImageJFrame()                {                setTitle("Background Color for JFrame");                 setLocationRelativeTo(null);                setDefaultCloseOperation(EXIT_ON_CLOSE);                setVisible(true);                  setContentPane(new JLabel(new                             ...

HOW TO CONFIGURE ANDROID IN ECLIPSE

Simple way to configure android in eclipse. Step 1: Download the ADT Plugin Start Eclipse, then select Help > Install New Software. Click Add, in the top-right corner. In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location: https://dl-ssl.google.com/android/eclipse/ Click OK. If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons). In the Available Software dialog, select the checkbox next to Developer Tools and click Next. In the next window, you'll see a list of the tools to be downloaded. Click Next. Read and accept the license agreements, then click Finish.If you get a security warning saying that the authenticity or validity of the software can't be established, click OK. When the installation completes, restart Eclipse. Step 2:Download the ADT Plugin Once Eclipse restarts, y...

DJ LIGHTS - Simplest DJ lights

TITLE DJ LIGHTS specially for home parties. CIRCUIT: Figure: 1 Figure 2 Figure 3 COMPONENTS: Figure 1: 12v Battery  ON / OFF switch Resistor:  1R  0.5 watt 100k     x 3 Capacitors: 100u Figure 2: Resistor:  100k    x 3 Transistor:  BD 689 Capacitor: 100u Switch:  On / OFF 12v Battery Figure 3: Resistors: R1 - 33K R2 - 220R R3 - 100K R4 - 100R R5 - 2k2 Capacitor: 100 u 22 u 2200u Transistor: BC 547 Battery: 9v LED: White colour IC 555 x 2 DESCRIPTION: Make your home parties more special. Above given circuits are for different effects in lights. If you want fade ON and fade OFF then go for figure 1 In figure 2 you can also connect series of LEDs. If you want up/down fading LEDs then go for figure 3. You can even use combination of all these circuits to make your party more like a DJ party.ENJOY APPLICATIONS: DJ setup at home f...

REMOTE CONTROL HOME APPLIANCE

TITLE:                        Remote controlled home appliance CIRCUIT: COMPONENTS: Resistors: R1 : 220K R2 : 330R R3 : 1K R4 : 330R R5 : 47R Capacitors: C1 : 100uF-16V C2 : 100nF-63V C3 : 470uF-16V Diodes: D1 : 1N4007 D2 : Red LED D3 : Green LED Transistors: Q1 : BC558 Q2 : BC548 IR : TSOP1738 IC1 : CD4017 Relay: 5V DC DESCRIPTION: Here we have the simple circuit diagram of remote controlled home appliances.Connect this circuit to any of the appliances and you can turn them on or off.This circuit can be controlled using remote of any TV, VCR,DVD Player etc.The circuit can be activated from distance of 10 meters. Circuit description: The 38 kHz infrared ray generated by the remote control are received by the IR receiver module TSOP1738 of the receiver.Pin 1 of TSOP1738 is connected to ground and output is taken from pin 3. This output signal is amplified by by Q1. Outp...

DRIVE A RELAY USING IC 555

TITLE:           DRIVE A RELAY USING IC 555 CIRCUIT: COMPONENTS: IC 555                           x 1 12v battery                   x 1 Diode 1N4004              x 1 Relay  12v                      x 1 Resistor  220k               x 1   DESCRIPTION: This is the simple circuit to drive a relay.When pins 2 and 6 are connected as an input the chip requires only about 1 uA to activate the output. In figure A output will be opposite to that of input.Figure B has output same as input i.e for logic high input high output is obtained. Important thing to be noted that input should be 2-3 V for output to be low and 1-3 V for output to be high.This is called HYSTERESIS and prevents any noi...

CLAP SWITCH

TITLE: Simple circuit to activate devices on clap. CIRCUIT: COMPONENTS : Transistor: BC 547       x 3 Resistor :                     33 K              x 2                     1 M             x 1                     5 k               x 1                     270 R          x 2                    47 K            x 2   Capacitor:                    10 uF           x 2                     ...

POINTERS EXAMPLE IN C PROGRAMMING

Simple example to understand how pointer works Syntax: Datatype *pointer_name; Example: #include <stdio.h>   int main () {    int  var = 20;    // actual variable declaration     int  *ip;        // pointer variable declaration      ip = &var;  // store address of var in pointer variable      printf("Address of var variable: %x\n", &var   );       /* address stored in pointer variable */     printf("Address stored in ip variable: %x\n", ip );       /* access the value using the pointer */     printf("Value of *ip variable: %d\n", *ip );      return 0; } Output: Address of var variable: bffd8b3c Address stored in ip variable: bffd8b3c Value of *ip variable: 20 Description: This topic seems little bit difficult but its very simple. Key poi...

ARRAY EXAMPLE IN C PROGRAMMING LANGUAGE

This example describes how to use array in c language. Syntax:      Declaration: Datatype array_name [size];      Initialization: array_name[size]; Example: #include <stdio.h> int main () {    int n[ 10 ];   // n is an array of 10 integers     int i,j;     for ( i = 0; i < 10; i++ )    {       n[ i ] = i + 100;   //  set element at location i to i + 100     }           for (j = 0; j < 10; j++ )    {       printf("Element[%d] = %d\n", j, n[j] ); //Print each array element on console    }      return 0; } Description: In this example we first simply declare an array for 10 elements, initialize it using for loop, and print all the elements on console. Line 4: This line declares an array of 10 elements.   Line 5: Declares variable Li...

TOUCH PLATE BASED DOOR BELL

Title:  Touch plate based door bell  Circuit:  Components: IC 555 Resistors: 1 M, 100k, 330 ohms Transistor: BC547  PN2222A Capacitor: 10n 1 Copper plate : as touch plate. A 6v battery An LED / Ic UM66 Description: This is the simple circuit for touch plate based security system. In this project what basically done is, circuit detects stray voltages produced by mains voltage and electrostatic built  up in the room.If sufficient static voltage is detected by the plate then chip will charge up. Transistor BC 547 or PN2222A is used basically to increase the sensitivity.In place of led just connect IC um 66(melody IC). Applications: In homes, of course. This can be specially used in places like hospitals, when patients need to call doctor by himself.

TOUCH PLATE BASED SECURITY SYSTEM

Title:  Touch plate based door bell  Circuit:  Components: IC 555 Resistors: 1 M, 100k, 330 ohms Transistor: BC547  PN2222A Capacitor: 10n 1 Copper plate : as touch plate. A 6v battery An LED. Description: This is the simple circuit for touch plate based security system. In this project what basically done is, circuit detects stray voltages produced by mains voltage and electrostatic built  up in the room.If sufficient static voltage is detected by the plate then chip will charge up. Transistor BC 547 or PN2222A is used basically to increase the sensitivity. Applications: In places like museum where precious metal objects are kept. In homes, banks, hotels etc