Welcome to my blog, hope you enjoy reading
RSS

Friday, 9 November 2012

create and copy database through java

create and copy database through java


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Iterator;

public class CopyDbToAnotherDb
{
public static void main(String[] args)
{
try
{
BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Source Database name");
String sourcedb=reader.readLine();
System.out.println("Enter Username");
String uname=reader.readLine();
System.out.println("Enter Password");
String pwd=reader.readLine();
System.out.println("Enter Destination Database name");
String destinationdb=reader.readLine();
//creating database
CopyDbToAnotherDb db=new CopyDbToAnotherDb();
db.createDatabase(destinationdb, uname, pwd);
//getting tableslist
ArrayList<String> tablist=db.getTablesFromDatabase(sourcedb, uname, pwd);
//System.out.println(tablist);

String s=db.copyTablesStructuresAndData(sourcedb, destinationdb, uname, pwd, tablist);
System.out.println(s);


}catch(Exception e)
{
System.out.println(e.getMessage());
}
}

private void createDatabase(String dbname,String uname,String pwd)
{
//for creating database
Connection Conn=null;
try
{
Conn = DriverManager.getConnection("jdbc:mysql://localhost/?user="+uname+"&password="+pwd);
Statement st=Conn.createStatement();
int Result=st.executeUpdate("CREATE DATABASE "+dbname);
if(Result>0)
{
System.out.println("database created successfully");
}
System.out.println("successfully created");
}
catch(Exception e)
{
System.out.println(e);
}
}

private ArrayList<String> getTablesFromDatabase(String dbname,String uname,String pwd)
{
Connection con=null;
Statement st=null;
//for getting the tables from database
ArrayList<String> tableslist=new ArrayList<String>();
try
{
con=connect(dbname, uname, pwd);
DatabaseMetaData dbm =con.getMetaData();
ResultSet rs = null;
String types[] = { "TABLE" };
rs = dbm.getTables(null, null, "", types);
while (rs.next())
{
String str = rs.getString("TABLE_NAME");
tableslist.add(str);
}
}catch(Exception e)
{
System.out.println(e.getMessage());
}
return tableslist;
}
public Connection connect(String dbname,String uname,String pwd)
{
//for connect database
Connection con=null;
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
String url="jdbc:mysql://localhost:3306/"+dbname;
con=DriverManager.getConnection(url,uname,pwd);
}
catch(Exception e)
{
System.err.println(e);
}
return con;
}
private String copyTablesStructuresAndData(String sourcedbname,String destdbname,String uname,String pwd,ArrayList<String> tablist)
{
//for creating the database struture
String result1="start";
Connection soucon=null;
Connection destcon=null;
Statement soust=null;
Statement destst=null;
try
{
soucon=connect(sourcedbname,uname,pwd);
destcon=connect(destdbname,uname,pwd);
soust=soucon.createStatement();
destst=destcon.createStatement();
Iterator<String> it=tablist.iterator();

destcon.setAutoCommit(false);
int k=0;
while(it.hasNext())
{
k++;
StringBuffer result = new StringBuffer();
String tabname=it.next();
try
{
//for creating the table structure
StringBuffer sql = new StringBuffer();
sql.append("SELECT * FROM ");
sql.append(tabname);
ResultSet rs = soust.executeQuery(sql.toString());
ResultSetMetaData md = rs.getMetaData();
result.append("CREATE TABLE ");
result.append(tabname);
result.append(" ( ");
for (int i = 1; i <= md.getColumnCount(); i++)
{
if (i != 1)
result.append(',');
result.append("`"+md.getColumnName(i)+"`");
result.append(' ');

String type = md.getColumnTypeName(i);
result.append(type);

if (md.getPrecision(i) < 65535)
{
result.append('(');
result.append(md.getPrecision(i));
if (md.getScale(i) > 0)
{
result.append(',');
result.append(md.getScale(i));
}
result.append(") ");
} else
result.append(' ');

/*if (this.isNumeric(md.getColumnType(i)))
     {
       if (!md.isSigned(i))
         result.append("UNSIGNED ");
     }*/

if (md.isNullable(i) == ResultSetMetaData.columnNoNulls)
result.append("NOT NULL ");
else
result.append("NULL ");
if (md.isAutoIncrement(i))
result.append(" auto_increment");
}
DatabaseMetaData dbm = soucon.getMetaData();
ResultSet primary = dbm.getPrimaryKeys(null, null, tabname);
boolean first = true;
while (primary.next())
{
if (first)
{
first = false;
result.append(',');
result.append("PRIMARY KEY(");
} else
result.append(",");
result.append(primary.getString
("COLUMN_NAME"));
}

if (!first)
result.append(')');

result.append(" )TYPE=innodb ");
//System.out.println(k+"---"+result.toString());
destst.addBatch(result.toString());

//for copy the data
String datasql="INSERT INTO "+tabname+" SELECT * FROM "+sourcedbname+"."+tabname;
//System.out.println(k+"---"+datasql);
destst.addBatch(datasql);

}
catch (Exception e)
{
System.out.println(e);
}

}
int a[]=destst.executeBatch();
destcon.commit();
result1="successfully copied";
}
catch(Exception e)
{
try
{
destcon.rollback();
}catch(Exception e1)
{
System.out.println("rollback"+e1.getMessage());
}
System.out.println(e);
}
return result1;
}
}
Share

Send Email Through Java


mail types and all



package com.mail;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.util.Date;
import java.util.Properties;

import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.mail.Address;
import javax.mail.Authenticator;
import javax.mail.BodyPart;
import javax.mail.Flags;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.mail.search.FlagTerm;


import com.mail.imagesendMail.GMailAuthenticator;

public class mailProject
{

 public static void main(String[] args) throws Exception
 {
  mailProject mproj=new mailProject();
  System.out.println("menu");
  System.out.println("1.read mail");
  System.out.println("2. reply");
  System.out.println("3. farward mail");
  System.out.println("4. delete mail");
  System.out.println("5. send email");
  System.out.println("6. send attachment");
  System.out.println("exit. to exit");
  BufferedReader breader=new BufferedReader(new InputStreamReader(System.in));
  boolean check=true;
  while(check)
  {
   System.out.println("enter option number");
   String option=breader.readLine().trim();
   if(option.equalsIgnoreCase("1"))
    mproj.readmail();
   else if(option.equalsIgnoreCase("2"))
    mproj.reply();
   else if(option.equalsIgnoreCase("3"))
    mproj.fwdmail();
   else if(option.equalsIgnoreCase("4"))
    mproj.deletemail();
   else if(option.equalsIgnoreCase("5"))
    mproj.sendemails();
   else if(option.equalsIgnoreCase("6"))
    mproj.sendAttachments();
   else if(option.equalsIgnoreCase("exit"))
    mproj.sendAttachments();
   else
    System.out.println("enter corect option");
  }
 
 }


//read the mails
public void readmail()
   {
  try
  {
   //working fine
   String host = "smtp.gmail.com";
   BufferedReader breader=new BufferedReader(new InputStreamReader(System.in));
   System.out.println("enter from email");
   String username=breader.readLine().trim();
   System.out.println("enter password");
   String password=breader.readLine().trim();

   Properties properties = System.getProperties();
   Session session = Session.getDefaultInstance(properties);
   Store store = session.getStore("imaps");
   store.connect(host, username, password);
   Folder folder = store.getFolder("inbox");
   if (!folder.exists()) {
    System.out.println("No INBOX...");
    System.exit(0);
   }
   folder.open(Folder.READ_WRITE);
   FlagTerm ft = new FlagTerm(new Flags(Flags.Flag.SEEN), false);
   Message msg[] = folder.search(ft);

   for (int i = 0; i < msg.length; i++) {
    System.out.println("------------ Message " + (i + 1) + " ------------");
    String from = InternetAddress.toString(msg[i].getFrom());
    if (from != null) {
     System.out.println("From: " + from);
    }

    String replyTo = InternetAddress.toString(
      msg[i].getReplyTo());
    if (replyTo != null) {
     System.out.println("Reply-to: " + replyTo);
    }
    String to = InternetAddress.toString(
      msg[i].getRecipients(Message.RecipientType.TO));
    if (to != null) {
     System.out.println("To: " + to);
    }

    String subject = msg[i].getSubject();
    if (subject != null) {
     System.out.println("Subject: " + subject);
    }
    Date sent = msg[i].getSentDate();
    if (sent != null) {
     System.out.println("Sent: " + sent);
    }

    System.out.println();
    System.out.println("Message : ");

    Multipart multipart = (Multipart) msg[i].getContent();

    for (int x = 0; x < multipart.getCount(); x++)
    {
     BodyPart bodyPart = multipart.getBodyPart(x);

     String disposition = bodyPart.getDisposition();

     if (disposition != null && (disposition.equals(BodyPart.ATTACHMENT))) {
      System.out.println("Mail have some attachment : ");

      DataHandler handler = bodyPart.getDataHandler();
      System.out.println("file name : " + handler.getName());
     } else {
      System.out.println(bodyPart.getContent());
     }
    }
    System.out.println();
   }
   System.out.println("no mails");
   folder.close(true);
   store.close();
  }catch(Exception e)
  {
   System.out.println(e);
  }
   }



//send email for with html image
 public void sendemails()
 {
  try
  {
   BufferedReader breader=new BufferedReader(new InputStreamReader(System.in));
   System.out.println("enter from email");
   String username=breader.readLine().trim();
   System.out.println("enter password");
   String password=breader.readLine().trim();
   System.out.println("enter to email");
   String to=breader.readLine().trim();
   System.out.println("enter image path");
   String url=breader.readLine().trim();
   System.out.println("enter subject");
   String subject=breader.readLine().trim();
   System.out.println("enter body");
   String body=breader.readLine().trim();
   String servername="smtp.gmail.com";
   Properties props = System.getProperties();
   props.put("mail.smtp.starttls.enable", "true");
   props.put("mail.smtp.host", servername);
   props.put("mail.smtp.user", username);
   props.put("mail.smtp.password", password);
   props.put("mail.smtp.port", 587);
   props.put("mail.smtp.auth", "true");
   //props.put("mail.debug", "true");

   Session sessions = Session.getInstance(props,  new GMailAuthenticator(username, password));
   MimeMessage message = new MimeMessage(sessions);
   Address fromAddress = new InternetAddress(username);
   //Address toAddress = new InternetAddress(emailTo);

   message.setFrom(fromAddress);
   message.addRecipients(Message.RecipientType.TO, to);

   message.setSubject(subject);
   String str = "<html><h1>Hello</h1></br>  <h6>"+body+"</h6>" +
     "<img src=\"cid:image_cid\">" +
     "<img border=0 src="+url+" alt=abc width=304 height=228 /></html>";
   MimeMultipart multipart = new MimeMultipart();

   // Create bodypart.
   BodyPart bodyPart = new MimeBodyPart();
   // Set the MIME-type to HTML.
   bodyPart.setContent(str, "text/html");

   // Add the HTML bodypart to the multipart.
   multipart.addBodyPart(bodyPart);

   // Create another bodypart to include the image attachment.
   bodyPart = new MimeBodyPart();

   // Read image from file system.
   DataSource ds = new FileDataSource("/home/prabhu/image.jpg");
   bodyPart.setDataHandler(new DataHandler(ds));

   // Set the content-ID of the image attachment.
   // Enclose the image CID with the lesser and greater signs.
   bodyPart.setHeader("Content-ID", "<image_cid>");

   // Add image attachment to multipart.
   multipart.addBodyPart(bodyPart);

   // Add multipart content to message.
   message.setContent(multipart);
   Transport transport = sessions.getTransport("smtp");
   transport.connect(servername, username, password);
   message.saveChanges();
   Transport.send(message);
   transport.close();
   System.out.println("send email successfully");

  } catch (MessagingException mex) {
   mex.printStackTrace();
   Exception ex = null;
   if ((ex = mex.getNextException()) != null) {
    ex.printStackTrace();
   }
  } catch (Exception ioex) {
   ioex.printStackTrace();
  }


 }




//send attachments
  public void sendAttachments()
   {
    //working fine
    try
    {
     String host = "smtp.gmail.com";
     BufferedReader breader=new BufferedReader(new InputStreamReader(System.in));
     System.out.println("enter from email");
     String username=breader.readLine().trim();
     System.out.println("enter password");
     String password=breader.readLine().trim();
     System.out.println("enter to email");
     String to=breader.readLine().trim();
     System.out.println("enter attach file path");
     String filename=breader.readLine().trim();
    // String filename="/home/prabhu/projects/javaEE1/narmaljava.zip";
     Properties props = System.getProperties();
     props.put("mail.smtp.starttls.enable", "true");
     props.put("mail.smtp.host", host);
     props.put("mail.smtp.user", username);
     props.put("mail.smtp.password", password);
     props.put("mail.smtp.port", 587);
     props.put("mail.smtp.auth", "true");
     //props.put("mail.debug", "true");
     Session session = Session.getInstance(props,  new GMailAuthenticator(username, password));

     Message msg=new MimeMessage(session);
     msg.setSubject("Photo Attached");
     msg.setFrom(new InternetAddress(username));
     msg.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
     BodyPart msgBP=new MimeBodyPart();
     msgBP.setText("Take a look at this\n");
     Multipart mPart=new MimeMultipart();
     mPart.addBodyPart(msgBP);
     msgBP=new MimeBodyPart();
     DataSource src=new FileDataSource(filename);
     msgBP.setDataHandler(new DataHandler(src));
     msgBP.setFileName(filename);
     mPart.addBodyPart(msgBP);
     msg.setContent(mPart);
     Transport.send(msg);
     System.out.println("mail sent");
    }catch(Exception e)
    {
     System.out.println(e);
    }

   }



//reply to mail
 public void reply()
 {
  try
  {
   String host = "smtp.gmail.com";
   BufferedReader breader=new BufferedReader(new InputStreamReader(System.in));
   System.out.println("enter from email");
   String username=breader.readLine().trim();
   System.out.println("enter password");
   String password=breader.readLine().trim();
   Date date = null;
   Properties props = System.getProperties();
   props.put("mail.smtp.starttls.enable", "true");
   props.put("mail.smtp.host", host);
   props.put("mail.smtp.user", username);
   props.put("mail.smtp.password", password);
   props.put("mail.smtp.port", 587);
   props.put("mail.smtp.auth", "true");
   //props.put("mail.debug", "true");
   Session session = Session.getInstance(props,  new GMailAuthenticator(username, password));

   Store store = session.getStore("imaps");
   store.connect(host, username, password);

   Folder folder = store.getFolder("Inbox");
   if (!folder.exists()) {
    System.out.println("inbox not found");
    System.exit(0);
   }
   folder.open(Folder.READ_ONLY);
   //for getting unread messages only
   FlagTerm ft = new FlagTerm(new Flags(Flags.Flag.SEEN), false);
   Message message[] = folder.search(ft);
   BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

   //for all messages
   //Message[] message = folder.getMessages();
   System.out.println("message length"+message.length);
   if (message.length != 0)
   {
    System.out.println("no. From \t\tSubject \t\tDate");
    for (int i = 0, n = message.length; i < n; i++)
    {
     date = message[i].getSentDate();

     System.out.println(" " + (i + 1) + ": " + message[i].getFrom()[0] + "\t" +
       message[i].getSubject() + "  \t" + date.getDate() + "/" +
       date.getMonth() + "/" + (date.getYear() + 1900));
     System.out.print("Do you want to reply [y/n] : ");
     String ans = reader.readLine();
     if ("Y".equals(ans) || "y".equals(ans))
     {

      // Create a reply message
      MimeMessage reply = (MimeMessage) message[i].reply(false);

      // Set the from field
      reply.setFrom(message[i].getFrom()[0]);
      reply.setSubject("Reply message");
      // Create the reply content
      // Create the reply content, copying over the original if text
      MimeMessage orig = (MimeMessage) message[i];
      StringBuffer buffer = new StringBuffer("Thanks \n Prabhukumar Gade \n 9533051699 ");
      if (orig.isMimeType("text/plain")) {
       String content = (String) orig.getContent();
       StringReader contentReader = new StringReader(content);
       BufferedReader br = new BufferedReader(contentReader);
       String contentLine;
       while ((contentLine = br.readLine()) != null) {
        buffer.append("> ");
        buffer.append(contentLine);
        buffer.append("\r\n");
       }
      }
      // Set the content
      reply.setText(buffer.toString());

      // Send the message
      Transport.send(reply);
      System.out.println("message send successfully");
     } else if ("n".equals(ans))
     {
      //break;
     }
    }
    System.out.println("messages completed");

   } else {
    System.out.println("There is no msg....");
   }
  }catch(Exception e)
  {
   System.out.println(e.getMessage());
  }

 }




//forward the email
 public void fwdmail()
 {
   //working fine
  try
  {
   boolean deleteStatus=false;
   String host = "smtp.gmail.com";
   BufferedReader breader=new BufferedReader(new InputStreamReader(System.in));
   System.out.println("enter from email");
   String username=breader.readLine().trim();
   System.out.println("enter password");
   String password=breader.readLine().trim();
   System.out.println("enter forward to email");
   String to=breader.readLine().trim();
   Date date = null;
   Properties props = System.getProperties();
   props.put("mail.smtp.starttls.enable", "true");
   props.put("mail.smtp.host", host);
   props.put("mail.smtp.user", username);
   props.put("mail.smtp.password", password);
   props.put("mail.smtp.port", 587);
   props.put("mail.smtp.auth", "true");
   //props.put("mail.debug", "true");
   Session session = Session.getInstance(props,  new GMailAuthenticator(username, password));

   Store store = session.getStore("imaps");
   store.connect(host, username, password);

   Folder folder = store.getFolder("Inbox");
   if (!folder.exists()) {
    System.out.println("inbox not found");
    System.exit(0);
   }
   folder.open(Folder.READ_WRITE);
   //for getting unread messages only
   FlagTerm ft = new FlagTerm(new Flags(Flags.Flag.SEEN), false);
   Message message[] = folder.search(ft);
   BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

   //for all messages
   //Message[] message = folder.getMessages();
   if (message.length != 0)
   {
    System.out.println("no. From \t\tSubject \t\tDate");
    for(int i=0,n=message.length;i<n;i++)
    {
     System.out.println(i+"  :  "+message[i].getFrom()[0] +"\t"+message[i].getSubject());
     System.out.println("Do u want to forward the message :[y/n]");
     String line=reader.readLine();
     if("Y".equalsIgnoreCase(line))
     {
      Message fwd=new MimeMessage(session);
      fwd.setSubject("Fwd  : "+message[i].getSubject());
      fwd.setFrom(new InternetAddress(username));
      fwd.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
      BodyPart msgBP=new MimeBodyPart();
      msgBP.setText("Your message goes here \n");
      Multipart mPart=new MimeMultipart();
      mPart.addBodyPart(msgBP);
      msgBP=new MimeBodyPart();
      msgBP.setDataHandler(message[i].getDataHandler());
      mPart.addBodyPart(msgBP);
      fwd.setContent(mPart);
      Transport.send(fwd);
     }

    }
    System.out.println("no messages");
    folder.close(deleteStatus);
    store.close();
    System.out.println("messages completed");

   } else {
    System.out.println("There is no msg....");
   }
  }catch(Exception e)
  {
   System.out.println(e.getMessage());
  }

 }



//for deleting the mail
  public void deletemail()
  {
    //working fine
   try
   {
    boolean deleteStatus=false;
    String host = "smtp.gmail.com";
    BufferedReader breader=new BufferedReader(new InputStreamReader(System.in));
    System.out.println("enter from email");
    String username=breader.readLine().trim();
    System.out.println("enter password");
    String password=breader.readLine().trim();
    Properties props = System.getProperties();
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.host", host);
    props.put("mail.smtp.user", username);
    props.put("mail.smtp.password", password);
    props.put("mail.smtp.port", 587);
    props.put("mail.smtp.auth", "true");
    //props.put("mail.debug", "true");
    Session session = Session.getInstance(props,  new GMailAuthenticator(username, password));

    Store store = session.getStore("imaps");
    store.connect(host, username, password);

    Folder folder = store.getFolder("Inbox");
    if (!folder.exists()) {
     System.out.println("inbox not found");
     System.exit(0);
    }
    folder.open(Folder.READ_WRITE);
    //for getting unread messages only
    FlagTerm ft = new FlagTerm(new Flags(Flags.Flag.SEEN), false);
    Message message[] = folder.search(ft);
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

    //for all messages
    //Message[] message = folder.getMessages();
    System.out.println("message length"+message.length);
    if (message.length != 0)
    {
     System.out.println("no. From \t\tSubject \t\tDate");
     for(int i=0,n=message.length;i<n;i++)
     {
      System.out.println(i+"  :  "+message[i].getFrom()[0] +message[i].getSubject());
      System.out.println("Do u want to delete message :[y/n]");
      String line=reader.readLine();
      if("Y".equalsIgnoreCase(line))
      {
       message[i].setFlag(Flags.Flag.DELETED,true);
       deleteStatus=true;
      }
     }
     System.out.println("no messages");
     folder.close(deleteStatus);
     store.close();
     System.out.println("messages completed");

    } else {
     System.out.println("There is no msg....");
    }
   }catch(Exception e)
   {
    System.out.println(e.getMessage());
   }

  }



 class GMailAuthenticator extends Authenticator
  {
      String user;
      String pw;
      public GMailAuthenticator (String username, String password)
      {
         super();
         this.user = username;
         this.pw = password;
      }
     public PasswordAuthentication getPasswordAuthentication()
     {
        return new PasswordAuthentication(user, pw);
     }
  }
}
Share

How Encrypt the GWT String from Client Side


  • Download the jar file from link.
  • Add the following in the .gwt.xml file 

  •         <inherits name='com.googlecode.gwt.crypto.Crypto'/>

     
  • Use the following code in the class

                  String getSHA1for(String text) 
               {
 SHA1Digest sd = new SHA1Digest();
 byte[] bs = text.getBytes();
 sd.update(bs, 0, bs.length);
 byte[] result = new byte[20];
 sd.doFinal(result, 0);
 return byteArrayToHexString(result);
}

String byteArrayToHexString(final byte[] b) 
               {
 final StringBuffer sb = new StringBuffer(b.length * 2);
 for (int i = 0, len = b.length; i < len; i++) {
   int v = b[i] & 0xff;
   if (v < 16) sb.append('0');
   sb.append(Integer.toHexString(v));
 }
 return sb.toString().toUpperCase();
}
Share

Tuesday, 6 November 2012

How can I use my PC's keyboard on the Android emulator?


How can I use my PC's keyboard on the Android emulator?

That's howI fixed it.
  1. Eclipse > Window menu > AVD Manager
  2. Select your virtual device and click Edit
  3. Under Hardware, Click New
  4. Select Keyboard Support then click OK
  5. Edit its value to yes
My other AVDs that don't have this "keyboard support" hardware property added for sure don't accept my physical keyboard input

Share

Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties


Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties


That isn't the problem, Jack. Android SDK isn't x64, but works ok with x64 jvm (and x64 eclipse IDE).
As helios said, you must set project compatibility to Java 5.0 or Java 6.0.
To do that, 2 options:
  1. right-click on your project and select "Android Tools -> Fix Project Properties" (if this din't work, try second option)
  2. right-click on your project and select "Properties -> Java Compiler", check "Enable project specific settings" and select 1.5 or 1.6 from "Compiler compliance settings" select box.
Share

how to test website google android on your pc



             The addon for the bowser is the User-Agent Switcher

For chrome:
             A.  To install the following addon click here.

             B. For add the new User Agents.

Share

how-to-change-eclipse-svn-password(Ubuntu)



    1. Remove the .keyring file from eclipse.

         1.1  Goto  /eclipse/configuration/org.eclipse.core.runtime folder

         1.2  In menu select view-->Show Hidden Files

         1.3  Remove .keyring file

    2. Restart the eclipse .
Share

Saturday, 20 October 2012

Running GWT Tests in Eclipse




You should be able to run most of your GWT tests from within Eclipse using the following steps.
  1. Right-click on a test that extends GWTTestCase and go to Run As > JUnit Test. It's likely you will see the error message below.
    Invalid launch configuration: -XstartOnFirstThread not specified.
    
    On Mac OS X, GWT requires that the Java virtual machine be invoked with the
    -XstartOnFirstThread VM argument.
    
    Example:
      java -XstartOnFirstThread -cp gwt-dev-mac.jar com.google.gwt.dev.GWTShell
    
  2. To fix this error, go to Run > Open Run Dialog. Click on the Arguments tab and add the following values. The 2nd value is to increase the amount of memory available to the test and avoid an OOM error.
    -XstartOnFirstThread -Xmx512M
  3. When you re-run the test, you will probably see the following error:
    com.google.gwt.junit.JUnitFatalLaunchException: The test class 'org.richresume.client.home.HomeControllerGwtTest' 
    was not found in module 'org.richresume.client.Application'; no compilation unit for that type was seen
      at com.google.gwt.junit.JUnitShell.checkTestClassInCurrentModule(JUnitShell.java:193)
      at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:628)
      at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:150)
      at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:219)
    
  4. To fix this, open the Run Dialog again, click on the Classpath tab and click on User Entries. Click on the Advanced button and select Add Folders. In the Folder Selection dialog, select your source and test directories (e.g. src/main/java andsrc/test/java).
  5. Run the test again and you should see a green bar in your JUnit tab.
  6. To create a JUnit configuration that runs all tests, duplicate the previously mentioned run configuration. Then change the name to "All Tests" and select the 2nd radio button to run all tests in the project.
  7. Click Run to execute all the tests in the project.
Share

Tuesday, 11 September 2012

Eclipse plugin for PhoneGap for Android available TODAY


Eclipse plugin for PhoneGap for Android available TODAY



Check out Announcements for the latest release and news

I'd like to let you know that the 1.0 release of the Eclipse plugin for PhoneGap for Android is available today.

You can install it into the 0.9.9 Eclipse ADT by pointing Eclipse's Install New Software to
http://www.mobiledevelopersolutions.com/home/download/pluginfilecabinet  More getting started information at http://www.mobiledevelopersolutions.com/home/start

This plugin allows you do all of your Android PhoneGap development within the Eclipse IDE.  After downloading and installing phonegap,
Eclipse is all you need - no need for droidgap, path manipulation or any other command line tools.

The plugin incorporates Eclipse JSDT's powerful development capabilities including its validator, which facilitates error detection while editing instead of deployment.

It also makes hybrid Java/JavaScript development easy, for when you have to tweak the Android Java code.

The future roadmap includes JavaScript debugging, source control integration, and improved workflow.  Let me know your ideas or participate in the open source development at http://github.com/paulb777/Eclipse-Plugin-for-Phonegap

Thanks to the Eclipse Foundation's Tools for Mobile Web (TMW) and Android's ADT open source projects which greatly facilitated the development.

I'm eager to hear any feedback and comments, either here or at the Eclipse for PhoneGap Google Group.
Share

Thursday, 16 August 2012

creating war file in eclipse


creating war file in eclipse 


If you are using eclipse 3.5 then goto window menu-> Preferences ->Server (on left side) -> Runtime Environment then click Add button then select the web server, which ever you want and click next -> browse the location of server.
Now,
Create Dynamic Web Project ,build it, right click on your project in Project Explorer, click Export->WAR file and browse the location where you want to create WAR file.
Share