Results 1 to 8 of 8
  1. #1
    MightyKing is offline Member
    Join Date
    Apr 2012
    Posts
    4
    Rep Power
    0

    Default Java iPad compiler issue

    Hello all, It's my first time in these forums and I have no idea as to where i should post this, so I figured might as well here.

    Anyways let's get down to business.

    I've downloaded a compiler app for java for my ipad Java Programming Language - iOS app from Yauheni Shauchenka | Appolicious ™ iPhone and iPad App Directory and I've been getting some issues that don't happen in a compiler for a PC. For example apparently I can't have a program that asks the user to input information such as names, numbers, etc. here is the code of the program I'm currently trying out :

    Java Code:
    import java.io.*;
    import java.util.*;
    public class Main{
    public static BufferedReader var=new BufferedReader(new InputStreamReader(System.in));
    public static void main(String []arg)throws Exception{
    
          String cadena1;
          String cadena2;
          String sub1;
          String sub2; 
          String sub3;
          String sub4; 
          String sub5;
          String sub6;
    
         System.out.println("Escribe tu nombre (Primer Nombre, Apellido Paterno y Apellido Materno) "); //. first and last names
          cadena1=var.readLine();
         System.out.println("Escribe el dia que naciste en el formato dd/mm/aaaa "); // date of birth DD/MM/YYYY
          cadena2=var.readLine();
    
          StringTokenizer token1;
          token1=new StringTokenizer(cadena1," ");
          String cad1=token1.nextToken();
          String cad2=token1.nextToken();
          String cad3=token1.nextToken();
    
          StringTokenizer token2;
          token2=new StringTokenizer(cadena2,"/");
          String cad4=token2.nextToken();
          String cad5=token2.nextToken();
          String cad6=token2.nextToken();
    
          sub1=cad1.substring(0,1);
          sub2=cad2.substring(0,2);
          sub3=cad3.substring(0,1);
          sub4=cad4.substring(0,2);
          sub5=cad5.substring(0,2);
          sub6=cad6.substring(2,4);
    
         System.out.println("Tu RFC es " + sub2 + sub3 + sub1 + sub6 + sub5 + sub4); // RFC = latin american document
    
     }
    }
    And the erros I took screenshots of are:
    Java iPad compiler issue-imagefgr.jpg
    Java iPad compiler issue-imagewbb.jpg

    I took the liberty of translating parts of the code that were in spanish to english in comments.

    I should point out that this program works 100% in my netbeans compiler on my PC. I've also compiled and ran various simple programs in this app for the ipad, and no issues there. However I've encountered issues on programs that require the user's input.

    Here are the screenshots of how my code looks in the actual app:

    Java iPad compiler issue-imagexva.jpg
    Java iPad compiler issue-imageslm.jpg


    Anyways, any ideas or clues as how to fix the specific issue of this code? Or better yet, can this app actually compile and run programs which require user input?

    Thank you for reading.
    Last edited by MightyKing; 04-11-2012 at 06:35 PM. Reason: Asterisks removed to avoid confusion

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Java iPad compiler issue

    Quote Originally Posted by MightyKing View Post
    here is the code of the program I'm currently trying out :

    Java Code:
    import java.io.*;
    import java.util.*;
    public class Main{
    public static BufferedReader var=new BufferedReader(new InputStreamReader(System.in));
    public static void main(String []arg)throws Exception{
    
    * * String cadena1;
    * * String cadena2;
    * * String sub1;
    * * String sub2; * *
    * * String sub3;
    * * String sub4; * *
    * * String sub5;
    * * String sub6; * *
    * * * * * * * **
    * * System.out.println("Escribe tu nombre (Primer Nombre, Apellido Paterno y Apellido Materno) "); //. first and last names
    * * cadena1=var.readLine();
    * * System.out.println("Escribe el dia que naciste en el formato dd/mm/aaaa "); // date of birth DD/MM/YYYY
    * * cadena2=var.readLine();
    * **
    * * StringTokenizer token1;
    * * token1=new StringTokenizer(cadena1," ");
    * * String cad1=token1.nextToken();
    * * String cad2=token1.nextToken();
    * * String cad3=token1.nextToken();
    * **
    * * StringTokenizer token2;
    * * token2=new StringTokenizer(cadena2,"/");
    * * String cad4=token2.nextToken();
    * * String cad5=token2.nextToken();
    * * String cad6=token2.nextToken();
    * **
    * * sub1=cad1.substring(0,1);
    * * sub2=cad2.substring(0,2);
    * * sub3=cad3.substring(0,1);
    * * sub4=cad4.substring(0,2);
    * * sub5=cad5.substring(0,2);
    * * sub6=cad6.substring(2,4);
    * **
    * * System.out.println("Tu RFC es " + sub2 + sub3 + sub1 + sub6 + sub5 + sub4); // RFC = latin american document
    * **
    * * }
    }
    Don't be silly, you can't even compile that code with all the asterisks.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    MightyKing is offline Member
    Join Date
    Apr 2012
    Posts
    4
    Rep Power
    0

    Default Re: Java iPad compiler issue

    Quote Originally Posted by DarrylBurke View Post
    Don't be silly, you can't even compile that code with all the asterisks.

    db
    Sorry I thought that was a no brainer, the asterisks were placed there after adding the [ CODE][/CODE] parameters in the post. No real asterisks are there in the actual code.. That's exactly the reason I posted the screenshots of the actual code in the app in the first place. Allow me to do so again.

    This is how the real code looks in the compiler:

    Java iPad compiler issue-imagexva.jpg
    Java iPad compiler issue-imageslm.jpg


    Thank you.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Java iPad compiler issue

    Can you copy and paste the errors instead of putting up screenshots...they're a pain.
    Please do not ask for code as refusal often offends.

  5. #5
    MightyKing is offline Member
    Join Date
    Apr 2012
    Posts
    4
    Rep Power
    0

    Default Re: Java iPad compiler issue

    Quote Originally Posted by Tolls View Post
    Can you copy and paste the errors instead of putting up screenshots...they're a pain.
    Java Code:
    Exception in thread "main" java.lang.NullPointerException
    	at java.util.StringTokenizer.<init>(StringTokenizer.java:182)
    	at java.util.StringTokenizer.<init>(StringTokenizer.java:204)
    	at Main.main(Main.java:22)

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Java iPad compiler issue

    And which line is line 22 (again paste it in)?
    What is null on that line?
    Please do not ask for code as refusal often offends.

  7. #7
    MightyKing is offline Member
    Join Date
    Apr 2012
    Posts
    4
    Rep Power
    0

    Default Re: Java iPad compiler issue

    Quote Originally Posted by Tolls View Post
    And which line is line 22 (again paste it in)?
    What is null on that line?
    I had already done that if you read the first post. Anyways here it is again...

    Java Code:
    import java.io.*;
    import java.util.*;
    public class Main{
    public static BufferedReader var=new BufferedReader(new InputStreamReader(System.in));
    public static void main(String []arg)throws Exception{
     
          String cadena1;
          String cadena2;
          String sub1;
          String sub2;
          String sub3;
          String sub4;
          String sub5;
          String sub6;
     
         System.out.println("Escribe tu nombre (Primer Nombre, Apellido Paterno y Apellido Materno) "); //. first and last names
          cadena1=var.readLine();
         System.out.println("Escribe el dia que naciste en el formato dd/mm/aaaa "); // date of birth DD/MM/YYYY
          cadena2=var.readLine();
     
          StringTokenizer token1;
          token1=new StringTokenizer(cadena1," ");
          String cad1=token1.nextToken();
          String cad2=token1.nextToken();
          String cad3=token1.nextToken();
     
          StringTokenizer token2;
          token2=new StringTokenizer(cadena2,"/");
          String cad4=token2.nextToken();
          String cad5=token2.nextToken();
          String cad6=token2.nextToken();
     
          sub1=cad1.substring(0,1);
          sub2=cad2.substring(0,2);
          sub3=cad3.substring(0,1);
          sub4=cad4.substring(0,2);
          sub5=cad5.substring(0,2);
          sub6=cad6.substring(2,4);
     
         System.out.println("Tu RFC es " + sub2 + sub3 + sub1 + sub6 + sub5 + sub4); // RFC = latin american document
     
     }
    }

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Java iPad compiler issue

    Except many people don't print their entire code here so the line numbers rarely match.
    Consequently I try not to waste my time looking at lines that may well turn out not to be the ones causing the problem.

    Add a println prior to the creation of the tokeniser to print out what cadena1 is.
    It seems to think it's null at this point.

    readLine() will only return null if end of stream is encountered, which it shouldn't do in this case (though who knows with an iPad). It could well be a bug in the JVM/SDK you're forced to use.
    Please do not ask for code as refusal often offends.

Similar Threads

  1. Medical iPad and iPhone Icons
    By java software in forum Java Software
    Replies: 0
    Last Post: 12-17-2011, 03:23 PM
  2. Interfacing with an ipad
    By cullam in forum Advanced Java
    Replies: 2
    Last Post: 09-08-2011, 01:11 AM
  3. Compiler Output Window Issue
    By sweetpea123 in forum New To Java
    Replies: 2
    Last Post: 04-10-2010, 05:56 PM
  4. How to Set up my Java Compiler
    By Galore in forum New To Java
    Replies: 4
    Last Post: 01-17-2010, 05:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •