Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 13 of 13

Thread: Sending SMS in java

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Sending SMS in java

    Hi.I have encounter problem in my codes(SMSGateway.java) whereby when I compile,the general output is "java.lang.NullPointerException at SMSGateway$SMSQueueThread.run(SMSGateway.java:350) ".
    I can connect it to terminal and server started..waiting for client but after that I receive the above error.

    I am using Kvanttisofta and Gsm Modem.
    Please guide me for I am not sure where is my mistake?

    Below are my codes
     
    import java.io.*;
    import java.util.*;
    import java.util.concurrent.SynchronousQueue;
    import java.util.concurrent.LinkedBlockingQueue;
    import java.util.concurrent.TimeUnit;
    import java.net.*;
    import com.joomfire.sms.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
     
    public class SMSGateway implements SmsListenerInterface
     
    {
    	private static java.util.ResourceBundle res;
    	private static final String db_name = "test";
    	static SmsTerminal term = null;
    	private Connection con = null; //for database connection
    	private Statement stmt;
    	private ResultSet rs;
    	private String msgStatus = "";
    	private String check = "";
            SynchronousQueue<OutMessage> smsQueue = new SynchronousQueue<OutMessage>();
     
    	public static void main(String[] args)
    	{
    		new SMSGateway();
    	}
     
    	public SMSGateway()
    	{
    		String str;
     
    		try
    		{
    			Class.forName("com.mysql.jdbc.Driver").newInstance();
    		}
    		catch (Exception e)
    		{
    			System.out.println("Exception in init(): Unable to load JDBC driver");
    		}
     
    		try
    		{
     
    			con = DriverManager.getConnection("jdbc:mysql://localhost:8806/test", "root", "");
    		  System.out.println("conn: "+con);
    		}
    		catch (Exception e)
    		{
    			System.out.println("Exception in init(): Unable to establish connection to database '" + db_name + "'");
    		}
     
    		try
    		{
    			res = Utils.getResources();
    		}
    		catch (java.util.MissingResourceException mre)
    		{
    	    	mre.getMessage();
    	    	System.exit(1);
    		}
     
    		str = res.getString("samplesmsapp.SampleSmsApp_starting");
    		System.out.println(str);
     
    		String confFileName = "samplesmsapp.conf";
    		Properties conf = null;
    		FileInputStream confIn = null;
     
    		try
    		{
    			File confFile = new File(confFileName);
    	    	confIn = new FileInputStream(confFile);
    	    	conf = new Properties();
    	    	conf.load(confIn);
    		}
    		catch (IOException e)
    		{
    		System.err.println(res.getString("samplesmsapp.could_not_read_") + confFileName + ": " + e);
    	    	System.exit(1);
    		}
    		finally
    		{
    			try
    			{
    				if(confIn!=null)
    				confIn.close();
    	    	}
    	    	catch (IOException e) { ; }
    		}
    		System.out.println(res.getString("samplesmsapp.-_configuration_read"));
     
    		// get configuration parameter values.
    		String smsTerminalPort = conf.getProperty("smsTerminalPort");
    		int smsTerminalBitRate = Integer.parseInt(conf.getProperty("smsTerminalBitRate"));
    		boolean includeSmscInfoLen = new  Boolean(conf.getProperty("includeSmscInfoLen")).booleanValue();
    		String smscAddress = conf.getProperty("smscAddress");
     
    		System.err.println(res.getString("samplesmsapp.-_connecting_to_SMS_terminal._please_wait."));
     
    		try
    		{
    			term = new SmsTerminal(smsTerminalPort, smsTerminalBitRate, this);
    			term.initialize();
    		    if(includeSmscInfoLen)
    		    {
    				term.setMsgOutIncludeSmscAddrLen(includeSmscInfoLen);
    				if(smscAddress != null)
    					term.setMsgOutSmscAddr(smscAddress);
    		    }
    		}
    		catch (Exception e)
    		{
    			str=res.getString("samplesmsapp.unable_to_create_a_SmsTerminal");
    			System.err.println(str);
    			System.err.println(res.getString("samplesmsapp.msg:_") + e);
    			System.exit(1);
    		}
     
    		//Create new smsQueue thread here
    		SMSQueueThread smsQueueThread = new SMSQueueThread("SMS Queue Thread", smsQueue, System.out);
    		smsQueueThread.start();
     
    		str = res.getString("samplesmsapp.-_connected_to_terminal");
    		System.out.println(str);
     
    		try
    		{
    			ServerSocket ss = new ServerSocket(4444);
    			System.out.println("Server started... waiting for Client...");
     
    	  		while(true)
    	  		{
    	  			Socket connectToClient = ss.accept();
    	  				HandleAClient thread = new HandleAClient(connectToClient);
    	  			thread.start();
    			}
     		}
    		catch(IOException ex)
    		{
    			System.err.println(ex);
    		}
    	}
     
    	public void receiveSms(int statusCode, String errmsg, SmsMsgIncoming msg)
     
    	{
     
    		if(statusCode == SmsTerminal.SC_OK)
    			{
    			System.out.println(res.getString("samplesmsapp.msg_received:_") + msg.toString());
     
     
    			// Recieved SMS & HP
    			String rAdm = msg.getMessage();
    			String rNum = msg.getSenderNumber();
     
    			System.out.println("Recieve Message : " + rAdm);
    			System.out.println("Recieve Number : " + rNum);
     
    			// INSERT SMS & HP INTO DATABASE
    			try {
     
    				String xxx;
    				xxx="";
    				System.out.println("+65 ooo : " + xxx);
    				stmt = con.createStatement();
    				stmt.executeUpdate("INSERT INTO records(sms_id,admission_no,mobile_no,status,datetime) VALUES(null,'"+rAdm+"','"+rNum.substring(3, rNum.length())+"','in', now())");
     
     
    			}
    			catch (Exception e)
    			{
    				System.out.println("Exception in mySQL(): " + e.getMessage() );
    			}
    		}
    		else
    		{
    			System.err.println(res.getString("samplesmsapp.error_receiving_SMS_message:_") + errmsg);
    		}
    	}
     
    	public void destroy()
    	{
    		try {
    			if (con != null)
    				con.close();
    		}
    		catch (SQLException excIgnored){}
    	}	// End destroy()
     
     
    	class HandleAClient extends Thread
    	{
    		private Socket connectToClient;
     
    		public HandleAClient(Socket socket)
    		{
    			this.connectToClient = socket;
    		}
     
    		public void run()
    		{
     
    			synchronized(connectToClient)
    			{
    				try
    					{
    					BufferedReader fromClient = new BufferedReader(new InputStreamReader(connectToClient.getInputStream()));
    					PrintWriter toClient = new PrintWriter(connectToClient.getOutputStream(), true);
     
    					String selection, outputLine;
    					while ((selection = fromClient.readLine()) != null)
    					{
    						String msg = "";
    						String num = "";
     
    						if(selection.equals("phone"))
    						{
    							// RECIEVE NUMBERS AND MSG FROM SERVLET
    							num = fromClient.readLine();
    							msg = fromClient.readLine();
     
    							System.out.println("Phone = " + num);
    							System.out.println("Message = " + msg);
     
    							try {
    								smsQueue.offer(new OutMessage(num, msg),10,TimeUnit.SECONDS);
    							}
    							catch (InterruptedException ie)
    							{
    								ie.printStackTrace();
    							}
     
    						//	SendSMS sms = new SendSMS(num, msg);
    						//	sms.start();
    						}
    						else
    						{
    							// RECIEVE GROUP AND MSG FROM SERVLET
    							String group = fromClient.readLine();
    							msg = fromClient.readLine();
     
    							System.out.println("Group : "+group);
     
    							try
    							{
    								stmt = con.createStatement();
    								rs = stmt.executeQuery("SELECT mobile_no FROM student WHERE course = '"+group+"'");
     
    								while(rs.next())
    								{
    									num = num + rs.getString(1) + ",";
    								}
     
    								System.out.println("Numbers = " + num);
     
    								smsQueue.offer(new OutMessage(num, msg),10,TimeUnit.SECONDS);
     
    							//	SendSMS sms = new SendSMS(num, msg);
    							//	sms.start();
    							}
    							catch (Exception e) {
    								e.printStackTrace();
    							}
    						}
    					}
    				}
    				catch(IOException ex)
    				{
    					System.err.println(ex);
    				}
    			}
    		}
    	}
     
    	class SendSMS extends Thread
    	{
    		private String num;
    		private String msg;
     
    		public SendSMS(String numbers, String message)
    		{
    			num = numbers;
    			msg = message;
    			System.out.println("Message = " + message);
    		}
     
    		public void run()
    		{
    			// BREAKING NUMBERS INTO TOKENS
    			StringTokenizer st = new StringTokenizer(num,",");
     
    			while (st.hasMoreTokens())
    			{
     
    				String sendNum_65 =st.nextToken().trim();
    				String sendNum = "65" + sendNum_65;
    				System.out.println("Phone = " + sendNum);
     
    				// SEND INDIVIDUAL TOKENS
    				try
    				{
     					System.err.println(res.getString("samplesmsapp.msg:_'") + sendNum + "', '" + msg + "'");
    					term.sendMessage(sendNum, msg);
     
    					try
    					{
    						stmt = con.createStatement();
    					    stmt.executeUpdate("INSERT INTO smsrecords(admission_no,mobile_no,status,datetime)  VALUES('"+sendNum_65+"','"+msg+"', now(), 'out')");
     
    										}
    					catch (Exception e)
    					{
    						System.out.println("Exception in mySQL(): " + e.getMessage() );
    					}
    					Thread.sleep(4800);
    				}
    				catch (StringIndexOutOfBoundsException e)
    				{
    					System.err.println(res.getString("samplesmsapp.msg_format:_number:message"));
    				}
    				catch(Exception ex) { }
    			}
    		}
    	}
     
                public class SMSQueueThread extends Thread
    	{
    		private SynchronousQueue smsQueue;
    		private String consumerName;
    		private PrintStream printStream;
    		public SMSQueueThread(String consumerName, SynchronousQueue smsQueue, PrintStream printStream)
    		{
    			this.consumerName = consumerName;
    			this.smsQueue = smsQueue;
    			this.printStream = printStream;
    		}
     
    		public void run()
    		{
    			while (true)
    			{
    			  try
    			  {
     
    			    OutMessage poll = (OutMessage)smsQueue.poll(20,TimeUnit.SECONDS);
    			    printStream.println(this.consumerName + ": " + poll.getMsg() + " " + poll.gethpnumbers());
     
    				// BREAKING NUMBERS INTO TOKENS
    				StringTokenizer st = new StringTokenizer(poll.gethpnumbers(),",");
     
    				while (st.hasMoreTokens())
    				{
    					String sendNum_65 =st.nextToken().trim();
    					String sendNum = "65" + sendNum_65;
    					System.out.println("Phone = " + sendNum);
     
    					// SEND INDIVIDUAL TOKENS
    					try
    					{
     						System.err.println(res.getString("samplesmsapp.msg:_'") + sendNum + "', '" + poll.getMsg() + "'");
    						term.sendMessage(sendNum, poll.getMsg());
     
    						try
    						{
    							stmt = con.createStatement();
    							stmt.executeUpdate("INSERT INTO records(admission_no,mobile_no,status,datetime)  VALUES('"+sendNum_65+"','"+poll.getMsg()+"', now(), 'out')");
    								}
    						catch (Exception e)
    						{
    							System.out.println("Exception in mySQL(): " + e.getMessage() );
    						}
    						Thread.sleep(4800);
    					}
    					catch (StringIndexOutOfBoundsException e)
    					{
    						System.err.println(res.getString("samplesmsapp.msg_format:_number:message"));
    					}
    					catch(Exception ex) {
    						ex.printStackTrace();
    					}
    				}
    			  }
    			  catch (InterruptedException ie)
    			  {
    			    ie.printStackTrace();
    			  }
    			  catch (NullPointerException ne)
    			  {
    			    ne.printStackTrace();
    			  }
    			}
    		}
    	}
    }
    Last edited by copeg; January 24th, 2011 at 09:29 PM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Sending SMS in java

    Please read the Welcome Announcement, in it you will find instructions on how to use the code tags which makes your code actually readable (I have edited your post to input the tags).

    You have provided quite a bit of code with a line that doesn't line up to anything, can you explicitly highlight or write which line of code the exception is thrown on?

  3. #3
    Junior Member
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Re: Sending SMS in java

    Below codes are the one that it couldn't run and occur the error "java.lang.NullPointerException at SMSGateway$SMSQueueThread.run(SMSGateway.java:350) ".

    Guide me.Thank you.
     
           while(true)
                {
                    Socket connectToClient = ss.accept();
                        HandleAClient thread = new HandleAClient(connectToClient);
                    thread.start();
                }
            }
            catch(IOException ex)
            {
                System.err.println(ex);
            }
        }
     
        public void receiveSms(int statusCode, String errmsg, SmsMsgIncoming msg)
     
        {
     
            if(statusCode == SmsTerminal.SC_OK)
                {
                System.out.println(res.getString("samplesmsapp.msg_received:_") + msg.toString());
     
     
                // Recieved SMS & HP
                String rAdm = msg.getMessage();
                String rNum = msg.getSenderNumber();
     
                System.out.println("Recieve Message : " + rAdm);
                System.out.println("Recieve Number : " + rNum);
     
                // INSERT SMS & HP INTO DATABASE
                try {
     
                    String xxx;
                    xxx="";
                    System.out.println("+65 ooo : " + xxx);
                    stmt = con.createStatement();
                    stmt.executeUpdate("INSERT INTO records(sms_id,admission_no,mobile_no,status,datetime) VALUES(null,'"+rAdm+"','"+rNum.substring(3, rNum.length())+"','in', now())");
     
     
                }
                catch (Exception e)
                {
                    System.out.println("Exception in mySQL(): " + e.getMessage() );
                }
            }
            else
            {
                System.err.println(res.getString("samplesmsapp.error_receiving_SMS_message:_") + errmsg);
            }
        }
     
        public void destroy()
        {
            try {
                if (con != null)
                    con.close();
            }
            catch (SQLException excIgnored){}
        }   // End destroy()
     
     
        class HandleAClient extends Thread
        {
            private Socket connectToClient;
     
            public HandleAClient(Socket socket)
            {
                this.connectToClient = socket;
            }
     
            public void run()
            {
     
                synchronized(connectToClient)
                {
                    try
                        {
                        BufferedReader fromClient = new BufferedReader(new InputStreamReader(connectToClient.getInputStream()));
                        PrintWriter toClient = new PrintWriter(connectToClient.getOutputStream(), true);
     
                        String selection, outputLine;
                        while ((selection = fromClient.readLine()) != null)
                        {
                            String msg = "";
                            String num = "";
     
                            if(selection.equals("phone"))
                            {
                                // RECIEVE NUMBERS AND MSG FROM SERVLET
                                num = fromClient.readLine();
                                msg = fromClient.readLine();
     
                                System.out.println("Phone = " + num);
                                System.out.println("Message = " + msg);
     
                                try {
                                    smsQueue.offer(new OutMessage(num, msg),10,TimeUnit.SECONDS);
                                }
                                catch (InterruptedException ie)
                                {
                                    ie.printStackTrace();
                                }
     
                            //  SendSMS sms = new SendSMS(num, msg);
                            //  sms.start();
                            }
                            else
                            {
                                // RECIEVE GROUP AND MSG FROM SERVLET
                                String group = fromClient.readLine();
                                msg = fromClient.readLine();
     
                                System.out.println("Group : "+group);
     
                                try
                                {
                                    stmt = con.createStatement();
                                    rs = stmt.executeQuery("SELECT mobile_no FROM student WHERE course = '"+group+"'");
     
                                    while(rs.next())
                                    {
                                        num = num + rs.getString(1) + ",";
                                    }
     
                                    System.out.println("Numbers = " + num);
     
                                    smsQueue.offer(new OutMessage(num, msg),10,TimeUnit.SECONDS);
     
                                //  SendSMS sms = new SendSMS(num, msg);
                                //  sms.start();
                                }
                                catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        }
                    }
                    catch(IOException ex)
                    {
                        System.err.println(ex);
                    }
                }
            }
        }
     
        class SendSMS extends Thread
        {
            private String num;
            private String msg;
     
            public SendSMS(String numbers, String message)
            {
                num = numbers;
                msg = message;
                System.out.println("Message = " + message);
            }
     
            public void run()
            {
                // BREAKING NUMBERS INTO TOKENS
                StringTokenizer st = new StringTokenizer(num,",");
     
                while (st.hasMoreTokens())
                {
     
                    String sendNum_65 =st.nextToken().trim();
                    String sendNum = "65" + sendNum_65;
                    System.out.println("Phone = " + sendNum);
     
                    // SEND INDIVIDUAL TOKENS
                    try
                    {
                        System.err.println(res.getString("samplesmsapp.msg:_'") + sendNum + "', '" + msg + "'");
                        term.sendMessage(sendNum, msg);
     
                        try
                        {
                            stmt = con.createStatement();
                            stmt.executeUpdate("INSERT INTO smsrecords(admission_no,mobile_no,status,datetime)  VALUES('"+sendNum_65+"','"+msg+"', now(), 'out')");
     
                                            }
                        catch (Exception e)
                        {
                            System.out.println("Exception in mySQL(): " + e.getMessage() );
                        }
                        Thread.sleep(4800);
                    }
                    catch (StringIndexOutOfBoundsException e)
                    {
                        System.err.println(res.getString("samplesmsapp.msg_format:_number:message"));
                    }
                    catch(Exception ex) { }
                }
            }
        }
     
                public class SMSQueueThread extends Thread
        {
            private SynchronousQueue smsQueue;
            private String consumerName;
            private PrintStream printStream;
            public SMSQueueThread(String consumerName, SynchronousQueue smsQueue, PrintStream printStream)
            {
                this.consumerName = consumerName;
                this.smsQueue = smsQueue;
                this.printStream = printStream;
            }
     
            public void run()
            {
                while (true)
                {
                  try
                  {
     
                    OutMessage poll = (OutMessage)smsQueue.poll(20,TimeUnit.SECONDS);
                    printStream.println(this.consumerName + ": " + poll.getMsg() + " " + poll.gethpnumbers());
     
                    // BREAKING NUMBERS INTO TOKENS
                    StringTokenizer st = new StringTokenizer(poll.gethpnumbers(),",");
     
                    while (st.hasMoreTokens())
                    {
                        String sendNum_65 =st.nextToken().trim();
                        String sendNum = "65" + sendNum_65;
                        System.out.println("Phone = " + sendNum);
     
                        // SEND INDIVIDUAL TOKENS
                        try
                        {
                            System.err.println(res.getString("samplesmsapp.msg:_'") + sendNum + "', '" + poll.getMsg() + "'");
                            term.sendMessage(sendNum, poll.getMsg());
     
                            try
                            {
                                stmt = con.createStatement();
                                stmt.executeUpdate("INSERT INTO records(admission_no,mobile_no,status,datetime)  VALUES('"+sendNum_65+"','"+poll.getMsg()+"', now(), 'out')");
                                    }
                            catch (Exception e)
                            {
                                System.out.println("Exception in mySQL(): " + e.getMessage() );
                            }
                            Thread.sleep(4800);
                        }
                        catch (StringIndexOutOfBoundsException e)
                        {
                            System.err.println(res.getString("samplesmsapp.msg_format:_number:message"));
                        }
                        catch(Exception ex) {
                            ex.printStackTrace();
                        }
                    }
                  }
                  catch (InterruptedException ie)
                  {
                    ie.printStackTrace();
                  }
                  catch (NullPointerException ne)
                  {
                    ne.printStackTrace();
                  }
                }
            }
        }
    }

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Sending SMS in java

    That still doesn't help. The exception has a line number in it (350), which doesn't seem to match up to anything in your code...it is important to tell us where that is. In more general terms, should you want more expedient help you have to help those trying to answer your question with all the info available, which includes the EXACT location the exception is thrown on (given the length of code, I and probably others don't have the time to try and run the code let alone inspect every variable, line, and loop for a Null reference).

  5. #5
    Junior Member
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Sending SMS in java

    Line 350
      OutMessage poll = (OutMessage)smsQueue.poll(20,TimeUnit.SECONDS);

  6. #6
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Sending SMS in java

    Read the API for SynchronousQueue.poll, null is returned if no element is available. Suggest you first check the size of the queue first before trying to remove and cast something that isn't there.

  7. #7
    Junior Member
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Sending SMS in java

    Thank you for the above error.But it encounter the same java.lang.NullPointerExcerption in the next line which is line 351.
      printStream.println(this.consumerName + ": " + poll.getMsg() + " " + poll.gethpnumbers());

  8. #8
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Sending SMS in java

    Are you sure what the status of the variables on that line are? Try debugging by adding some println statements in there to make sure your variables are not null. For example
    if ( poll == null ){
        System.out.println("Poll is null");
    }

    Doing so allows you to run through your code several times and backtrack through the variables to see if/where a variable is set to some value (in this case null) - an important technique to learn in debugging, stripping apart code and figuring out its status at a given time to see where the errors are.

  9. #9
    Junior Member
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Sending SMS in java

    Pardon me..but I still got the same error even thou I took your advice.=(

  10. #10
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Sending SMS in java

    Quote Originally Posted by pipi View Post
    Pardon me..but I still got the same error even thou I took your advice.=(
    You will still get an error if you follow my advice from my previous post. What did it print out? The point of my previous post was for you to determine what is null using println's, then backtrack through the code using using a similar technique to determine the source of the null reference. If a NullPointerException is thrown, something is null. Add some println's to determine what is, then figure out why it is null.

  11. #11
    Junior Member
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Sending SMS in java

    I am still confuse.
    Anyway did I place the code correctly
     
    	public void run()
    		{
    			while (true)
    			{
    			  try
    			  {
    			  	//Retrieves and removes the head of this queue, waiting if necessary up to the specified wait time, for another thread to insert it.
    			  	//timeout - how long to wait before giving up, in units of unit,unit - a TimeUnit determining how to interpret the timeout parameter
    			    OutMessage poll = (OutMessage)smsQueue.poll(30,TimeUnit.SECONDS);
    			   printStream.println(this.consumerName + ": " + poll.getMsg() + " " + poll.gethpnumbers());
    			   if ( poll == null ){
                   System.out.println("Poll is null");
                      }

  12. #12
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Sending SMS in java

    That println statement is for your benefit, not the code. It lets you see the values of variables through the runtime of a program. I doubt it prints anything as you try to access poll as an object and if it is null the Exception will be thrown before that statement is reached.

  13. #13
    Junior Member
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Sending SMS in java

    Sorry but I'm kinda of lost.What should I do?

Similar Threads

  1. Sending object through socket
    By Alexandrinne in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 16th, 2010, 02:18 AM
  2. Problem sending POST request with Java..
    By lost in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 20th, 2010, 09:16 PM
  3. sending objects from client to server
    By 11moshiko11 in forum What's Wrong With My Code?
    Replies: 16
    Last Post: October 8th, 2010, 04:47 AM
  4. Sending XML over HTTP to Another Application
    By darasgar in forum Java Servlet
    Replies: 2
    Last Post: July 14th, 2010, 01:56 PM
  5. Java problem -- sending email via JSP page
    By java_beginner in forum Java Theory & Questions
    Replies: 2
    Last Post: June 28th, 2010, 02:35 AM