Need help with running a Java program on Linux

I am trying to get a Java program to run on a Linux machine. The program is actually meant for a Mac computer. I want to see if someone with Java experience can help me determine what is causing the program to stall. I was successful in getting it installed on my Linux machine and to partially run.
The program is an interface to a database. I get the login screen to appear, but then once I enter my information and hit enter the rest of the program never shows, however, it does appear to connect in the background.
Here is the error when I launch the .jar file from the command screen:
Exception in thread "main" java.lang.IllegalArgumentException: illegal component position
at java.awt.Container.addImpl(Unknown Source)
at java.awt.Container.add(Unknown Source)
I am not a programmer and I am hoping this will make some sense to someone. Any help in resolving this is greatly appreciated!

Well, without knowing a little bit about programming, and how to run your debugger, I don't think you're going to fix it. The IllegalArgumentException is saying that some call does not like what it's getting. So you'll have to go in an refactor at least that part of the code.

Similar Messages

  • Need help in my assignment, Java programing?

    Need help in my assignment, Java programing?
    It is said that there is only one natural number n such that n-1 is a square and
    n + 1 is a cube, that is, n - 1 = x2 and n + 1 = y3 for some natural numbers x and y. Please implement a program in Java.
    plz help!!
    and this is my code
    but I don't no how to finsh it with the right condition!
    plz heelp!!
    and I don't know if it right or wrong!
    PLZ help me!!
    import javax.swing.JOptionPane;
    public class eiman {
    public static void main( String [] args){
    String a,b;
    double n,x,y,z;
    boolean q= true;
    boolean w= false;
    a=JOptionPane.showInputDialog("Please enter a number for n");
    n=Double.parseDouble(a);
    System.out.println(n);
    x=Math.sqrt(n-1);
    y=Math.cbrt(n+1);
    }

    OK I'll bite.
    I assume that this is some kind of assignment.
    What is the program supposed to do?
    1. Figure out the value of N
    2. Given an N determine if it is the correct value
    I would expect #1, but then again this seem to be a strange programming assignment to me.
    // additions followI see by the simulpostings that it is indeed #1.
    So I will give the tried and true advice at the risk of copyright infringement.
    get out a paper and pencil and think about how you would figure this out by hand.
    The structure of a program will emerge from the mists.
    Now that I think about it that advice must be in public domain by now.
    Edited by: johndjr on Oct 14, 2008 3:31 PM
    added additional info

  • I need help with TV Capture Card program

    Hello,
    I want to create a JAVA program so I can schedule that the recording with my TV Capture Card begins in x seconds.
    Now to start a recording, you must press Ctrl+M and to stop an recording you must click the mouse.
    How can I realise that a Java application can "press" Ctrl+M. I have to create an timer, that must be do-able... but I don't know how the program can simulate the pressing of Ctrl+M. I also need to know how the Java program can do a mouse click for me to end the recording.
    Thanks in advance for helping me.
    Chris.

    Thank you... I think this was exactly what I needed.

  • Im DROWNING! need help with a simple java assignment! plz someone help me!

    i need help with my java assignment, with validating a sin number. easy for must who know java. im drowning... please help!

    You will need to store each digit of the social insurance number in a field of its own. To validate the entry you will:
    1. Multiply the 2nd, 4th, 6th and 8th digit by 2.
    2. If the product of any of the four multiplications result in a value greater than 9, add the two resulting digits together to yield a single-digit response. For example 6 * 2 = 12, so you would add the 1 and the 2 to get a result of 3.
    3. Add these four calculated values together, along with the 1st, 3rd, 5th, and 7th digits of the original number.
    4. Subtract this sum from the next highest multiple of 10.
    5. The difference should be equal to the 9th digit, which is considered the check digit.
    Example of validating S.I.N. 765932546
    1st digit 7
    2nd digit (6*2 =12 1+2=) 3
    3rd digit 5
    4th digit (9*2 = 18 1+8 =) 9
    5th digit 3
    6th digit (2*2 = 4) 4
    7th digit 5
    8th digit (4*2 = 8) 8
    Total 44 next multiple of 10 is 50
    50-44 = 6 which is the 9th digit
    Therefore the S.I.N. 765932546 is Valid
    ********* SIN Validation *********
    Welcome - Please enter the first number: 120406780
    Second digit value multiplied by 2 4
    Fourth digit value multiplied by 2 8
    Sixth digit value multiplied by 2 12
    Eighth digit value multiplied by 2 16
    Value derived from 6th digit 3
    Value derived from 8th digit 7
    The total is 30
    Calculated digit is 10
    Check digit must be zero because calculated value is 10
    The SIN 120406780 is Valid
    this is my assignemtn this is what i have! i dont know where to start! please help me!
    /*     File:     sinnumber.java
         Author:     Ashley
         Date:     October 2006
         Purpose: Lab1
    import java.util.Scanner;
    public class Lab1
              public static void main(String[] args)
                   Scanner input = new Scanner(System.in);
                   int sin = 0;
                   int number0, number1, number2, number3, number4, number5, number6, number7, number8;
                   int count = 0;
                   int second, fourth, sixth, eighth;
                   System.out.print("\t\n**********************************");
                   System.out.print("\t\n**********SIN Validation**********");
                   System.out.print("\t\n**********************************");
                   System.out.println("\t\nPlease enter the First sin number: ");
                   sin = input.nextInt();
                   count = int.length(sin);     
                   if (count > 8 || count < 8)
                   System.out.print("Valid: ");
         }

  • Desperately need some help with client-server java programming

    Hi all,
    I'm new to client server java programming. I would like to work on servlets and apache tomcat. I installed the apache tomcat v 5.5 into my machine and i have sun java 6 also. I created a java applet class to be as a client and embed it into an html index file, like this:
    <applet code="EchoApplet.class" width="300" height="300"></applet>However, when I try to run the html file on the localhost, it print this error: classNotFoundException, couldn't load "EchoApplet.class" class. On the other hand, when I open the index file on applet viewer or by right clicking, open with firefox version 3, it works.
    I thought that the problem is with firefox, but after running the applet through the directory not the server, i found that the problem is not any more with firefox.
    Can anyone help me to solve this problem. I'm working on it for 5 days now and nothing on the net helped me. I tried a lot of solutions.
    Any help?

    arun,
    If the browser is going to execute $myApplet, first it must get the $myApplet.class from the server, right?
    So it follows that:
    1. $myApplet.class must be acessible to server, and
    2. the server must know exactly where to find $myApplet.class
    So, the simplest solution is to is put the $myApplet.class in the same directory as the HTML file which uses it... then your applet tag is simple:
      <applet height="200" width="400" code="$myApplet.class" ></applet>* The height & width attributes are required
    * Note the +.class+ is required in the code attribute (a common mistake).
    * This works uniformly (AFAIK) accross all java-enabled browsers.
    * There are incompatibilities with the codebase attribute. Poo!
    Cheers. Keith.

  • Need help in creating a java program

    Hi everyone.
    I'd like to say before i start about my problem, that i've only begun learning java and my teacher hasn't explained anything at all. He only showed us by doing it himself and then showing us the final version. I've searched a little on how to program but i get little success in finding a good tutorial.
    I need help creating a program which has been assigned to me due in a few days in which i can't contact my teacher for help.
    I need to write a java program which inputs 3 items. The number of kilometres you drove, the number of litres of gas you used and the price you paid for the gas. Then, the program must calculate the number of litres used per 100km driven, which is litres divided by kilometres times 100, how much it costs to drive 100km, which is the result (a) times the price per litre and the number of miles per American gallon of gas ( one American gallon = 3.785 litres, and one mile = 1.609 km.
    The program has to output my name, the inputs given, the results computed and a message saying "Program Complete".
    To give you what i've done to begin with, from what i understood, is:
    import javax.swing.JOptionPane;
    public class prog1
         public static void main(String args[])
              final double americanGallon = 3.785;
              final double mile = 1.609;
              kilometresDriven,
              gasUsed;
              priceOfLiterGas;
              System.out.println("My Name");
              System.out.println("Number of kilometres driven:");
              kilometresDriven = JOptionPane.showInputDialog ("Kilometres Driven");
              System.out.println("Number of Litres of gas used:");
              gasUsed = JOptionPane.showInputDialog ("Litres of gas used");
              System.out.println("Price of a liter of gas:");
              priceOfLiterGas = JoptionPane.showInputDialog("Price per liter");
    Up to now, that's all i've got. i know i'm wrong, but i'm not sure how to do this. Could someone give me an outline of what this program is suppose to look like?
    Thanks in advance.

    Here's an update on my program. I've worked on certain details and would need your comments whether it contains errors. I'd also want to know if it would work or not because i don't know how to check it on my computer.
    Here's the update:
    import javax.swing.JOptionPane;
    public class Prog1
    public static void main(String args[])
    String name;
    double kmDriven;
    double litresUsed;
    double pricePaidForGas;
    double priceOfALiter;
    name = JOptionPane.showInputDialog("Name");
    input = JOptionPane.showInputDialog("Number of km driven");
    kmDriven = Double.parseDouble (input);
    input = JOptionPane.showInputDialog("Number of litres of gas used");
    litresUsed = Double.parseDouble (input);
    input = JOptionPane.showInputDialog("Price paid for gas");
    pricePaidForGas = Double.parseDouble (input);
    input = JOptionPane.showInputDialog("Price of a litre of gas");
    priceOfALiter = Double.parseDouble (input);
    a = (litresUsed/kmDriven)*100;
    b = ((litresUsed/kmDriven)*100)*priceOfALiter);
    c = (kmDriven/1.609)
    System.out.println("Name:" + name);
    System.out.println("Number of litres used per 100km:" + a);
    System.out.println("Cost of driving 100km" + b);
    System.out.println("Number of miles per American Gallon of Gas:" + c);
    System.out.println("Program Complete");
    System.exit(0);
    Comments please.
    Thanks in advance

  • I need help with the Bon Scott program

    Help me! I am learning Java from the book, "Teach Yourself Java through Osmosis" and I am having trouble with the Bon Scott program. Everytime I run it, which has been ca. 2 billion, it prints out, "Some balls are held for charity and some for fancy dress, but when they're held for pleasure, they're the balls that I like the best." It then proceeds to get pissed and finally vomits.
    Any suggestions ?

    What color is the vomit? That is, exactly what does it do when it gets pissed and vomits?

  • Help required - running a Java program from the command line

    Hi,
    I have a small non-graphical Java application, packaged into a Jar file. My program relies on classes in another (external) Jar file.
    When I run the application from the IDE, everything works fine. However, when I try to run the application from the command line, I keep getting a NoClassDefFoundError for classes in the external jar.
    Both the application jar file and the external jar file are in my root directory (C:\).
    My command line call is as follows:
    java -cp c:MyExternalLib.jar -jar MyApp.jar
    Any help greatly appreciated.
    Thanks,
    Walter

    hi,
    set classpath=%classpath%;c:\myjar.jar;
    here i have specified myjar.jar file as an example u give ur location.after setting the classpath run ur java application.
    java mypgm
    this will solve ur problem
    regards,
    Ganesh

  • Need help with mac and java

    Hi, I'm trying to develop an application on a Machintosh OSX 10.2.8 machine.
    I'm having a herrendous time trying to get quicktime to work on it.
    I've somehow managed t oget 1.3.1 and QTJava.jar to work together but now i need encryption, however that requires 1.4+
    Now 1.4.1 doesnt work with quicktime
    I've downloaded the latest software upgrades but Ive got no idea how to set up quicktime to work with java 1.4.1
    Now to add on top of that mac reports it can use AES encryption. this is from source code ripped striaght from this website.
    But first and foremost can anyone, annyonee help me out with setting up 1.4.1 with quicktime?
    Thank you

    If you need encryption with Java 1.3.1, download the JCE from either Sun (http://java.sun.com/products/jce/) or Bouncy Castle (http://www.bouncycastle.org/).
    Cheers,
    --Arnout                                                                                                                                                                                                                                                                                                                                                                   

  • Need help with solving the (basic) programming error

    I'm reaaaaaaaaaally new to Java and programming in general. I've been glancing through my older brother's old stuff (he's back at Uni!) and I've taken an interest.
    Anyways, so I'm trying to finish this really simple program cause I wanna wow some friends ("wow" = "haha we've done this before a gazillion times") but I can't seem to solve this "incompatible lines" bug in the code, specifically line 24. I've been looking at it for exactly 4 hours!! Programming in Java 1.6.
    Thanks for the help!! :)
    import java.util.*;
    import java.util.Scanner;
    public class LuigisPizzaProgram {
         public static void main(String args[]) {
         System.out.println("Luigi's Pizza");
         System.out.println("-------------------------------------------");
         System.out.println(" a(SML) b(MED) c(LRG)");
         System.out.println("1. Cheese 5.00 7.50 10.00");
         System.out.println("2. Pepperoni 5.75 8.63 11.50");
         System.out.println("3. Combination 6.50 9.75 13.00");
         System.out.println("4. Vegetarian 7.25 10.88 14.50");
         System.out.println("5. Meat Lovers 8.00 12.00 16.00");
         System.out.println(" ");
         System.out.println("What kind of pizza do you want?");     
         int kind = new Scanner(System.in).nextInt();
         System.out.println(kind);
         System.out.println("What size of pizza do you want?");
         char size = new Scanner(System.in).nextLine();
         System.out.println(size);
         }

    Having said that, it is nontraditional to use Scanner like you are using it. There is no way to reuse it in order to get more input. Better would be something like:
            System.out.println("What size of pizza do you want?");
            Scanner scan = new Scanner(System.in);  // create the scan variable
            String size = scan.nextLine(); // now use the scan variable
            System.out.println(size);Also, when posting your code, please use code tags so that your code will be well-formatted and readable. To do this, place the tag &#91;code&#93; at the top of your block of code and the tag &#91;/code&#93; at the bottom, like so:
    &#91;code&#93;
      // your code block goes here.
    &#91;/code&#93;good luck, pete

  • Need help with long term Java problems

    I've been having problems with Java on my computer for about a year now, and I'm hoping that someone here can help me out.
    Java used to work fine on the computer when I first got it (a Dell laptop) and I hadn't installed anything myself. But then one day it stopped loading Java applets, and hasn't worked since. By this, I mean that I get the little colorful symbol in a box when I try to play Yahoo games, use the http://www.jigzone.com site, go to chat rooms, etc. Java menus on websites like http://www.hartattack.tv used to work still, but lately they've been giving me that symbol too.
    I've tried downloading a newer version of Java, but nothing I do seems to work, and I don't know of anything I did to trigger it not working. I'm hoping there's a simple solution to this, and I'm just dumb.
    Thanks.

    This might be way off, but it's something that's tripped me up in the past:
    If you are using Sun's Java plugin, the first time you go to a site that has a particular Java applet, you may be asked to approve/reject a security request.
    If you have clicked on any other windows while the request is first being loaded (which can take some time, because this is swing based), then the security dialog box does not pop to the top of the window stack, and doesn't add an entry into the task bar.
    It appears that Java just doesn't work, but it's actually waiting for you to click "Yes". You can check this by hitting alt-tab and seeing if the Java coffee cup icon is one of the options.
    - K

  • Need Help with running expect script on MAC OS

    Hi Guys,
    I'm having an issue with running an expect script on my Mac Mini with Mac OS x 10.7.5. I think the script is correct but the not sure why its not working.
    The script is as below and also teh error from Xtern or terminal when i try to run it.
    #!/usr/bin/expect
    set telnetAddr "172.22.22.254"
    set telnetAddr1 "172.22.22.252"
    set username "ww"
    set passwords "ww"
    set enablepassword "ww"
    spawn  telnet $telnetAddr
    expect "Username: "
    send "username\r"
    expect "Password: "
    send "$passwords\r" 
    expect "Orange-ISRGW>"
    send "enable\r"
    expect "Password: "
    send "$enablepassword\r"
    expect "Orange-ISRGW#"
    send "sh flash\r"
    expect "Orange-ISRGW#"
    send "delete flash:c1140-k9w7-tar.default.JAR\r"
    expect "Delete flash:/c1140-k9w7-tar.default.JAR? [confirm]"
    send  "\r"
    expect "Orange-ISRGW#"
    send "exit/r"
    interact
    here is what happens when i try to run it. This is just a test script before i re-write it to do what i intened to use it for.
    sh-3.2# ls -al Text-Script.txt
    -rwxrwxrwx@ 1 root  wheel  592 Dec  6 08:36 Text-Script.txt
    sh-3.2# more Text-Script.txt
    #/!/usr/bin/expect -f
    set telnetAddr "172.22.22.254"
    set username "ww"
    set passwords "ww"
    set enablepassword "ww"
    spawn telnet $telnetAddr
    expect "Username: "
    send "username\r"
    expect "Password: "
    send "$passwords\r" 
    expect "Orange-ISRGW>"
    send "enable\r"
    expect "Password: "
    send "$enablepassword\r"
    expect "Orange-ISRGW#"
    send "term length 0\r"
    expect "Orange-ISRGW#"
    send "sh flash\r"
    expect "Orange-ISRGW#"
    send "delete flash:c1140-k9w7-tar.default.JAR\r"
    expect "Delete flash:/c1140-k9w7-tar.default.JAR? [confirm]"
    send  "\r"
    expect "Orange-ISRGW#"
    send "exit/r"
    sh-3.2#
    sh-3.2# pwd
    /usr/bin
    sh-3.2# Text-Script.txt
    /usr/bin/Text-Script.txt: line 8: spawn: command not found
    couldn't read file "Username: ": no such file or directory
    /usr/bin/Text-Script.txt: line 10: send: command not found
    ": no such file or directory:
    /usr/bin/Text-Script.txt: line 12: send: command not found
    ": no such file or directorySRGW>
    /usr/bin/Text-Script.txt: line 14: send: command not found
    couldn't read file "Password: ": no such file or directory
    /usr/bin/Text-Script.txt: line 16: send: command not found
    ": no such file or directorySRGW#
    /usr/bin/Text-Script.txt: line 18: send: command not found
    ": no such file or directorySRGW#
    /usr/bin/Text-Script.txt: line 20: send: command not found
    ": no such file or directorySRGW#
    /usr/bin/Text-Script.txt: line 22: send: command not found
    ": no such file or directorylash:/c1140-k9w7-tar.default.JAR? [confirm]
    /usr/bin/Text-Script.txt: line 24: send: command not found
    ": no such file or directorySRGW#
    /usr/bin/Text-Script.txt: line 26: send: command not found
    sh-3.2#
    sh-3.2#
    sh-3.2# ./Text-Script.txt
    ./Text-Script.txt: line 8: spawn: command not found
    couldn't read file "Username: ": no such file or directory
    ./Text-Script.txt: line 10: send: command not found
    ": no such file or directory:
    ./Text-Script.txt: line 12: send: command not found
    ": no such file or directorySRGW>
    ./Text-Script.txt: line 14: send: command not found
    couldn't read file "Password: ": no such file or directory
    ./Text-Script.txt: line 16: send: command not found
    ": no such file or directorySRGW#
    ./Text-Script.txt: line 18: send: command not found
    ": no such file or directorySRGW#
    ./Text-Script.txt: line 20: send: command not found
    ": no such file or directorySRGW#
    ./Text-Script.txt: line 22: send: command not found
    ": no such file or directorylash:/c1140-k9w7-tar.default.JAR? [confirm]
    ./Text-Script.txt: line 24: send: command not found
    ": no such file or directorySRGW#
    ./Text-Script.txt: line 26: send: command not found
    sh-3.2#

    Works like a Charm after making the change suggested ..
    macminiserver:ExpectScript Tola$ more Text-Script.txt
    #! /usr/bin/expect -f
    set telnetAddr "172.22.22.254"
    set username "ww"
    set passwords "ww"
    set enablepassword "ww"
    spawn telnet $telnetAddr
    expect "Username: "
    send "$username\r"
    expect "Password: "
    send "$passwords\r" 
    expect "Orange-ISRGW>"
    send "enable\r"
    expect "Password: "
    send "$enablepassword\r"
    expect "Orange-ISRGW#"
    send "term length 0\r"
    expect "Orange-ISRGW#"
    send "sh flash\r"
    expect "Orange-ISRGW#"
    send  "delete flash:c1140-k9w7-tar.default.JAR\r"
    send  "\r"
    expect "Orange-ISRGW#"
    send "sh flash\r"
    interact
    macminiserver:ExpectScript Tola$ ./Text-Script.txt
    spawn telnet 172.22.22.254
    Trying 172.22.22.254...
    Connected to 172.22.22.254.
    Escape character is '^]'.
    User Access Verification
    Username: ww
    Password:
    Orange-ISRGW>enable
    Password:
    Orange-ISRGW#term length 0
    Orange-ISRGW#sh flash
    -#- --length-- -----date/time------ path
    2         1440 Oct 24 2013 11:23:26 -07:00 vlan.dat
    3     63714548 May 3 2010 11:49:40 -07:00 c2800nm-adventerprisek9_ivs_li-mz.151-1.T.bin
    5     67871024 Nov 9 2012 19:05:24 -08:00 c2800nm-adventerprisek9-mz.151-4.M5.bin
    124751872 bytes available (131600384 bytes used)
    Orange-ISRGW#delete flash:c1140-k9w7-tar.default.JAR
    Delete flash:/c1140-k9w7-tar.default.JAR? [confirm]
    %Error deleting flash:/c1140-k9w7-tar.default.JAR (File not found)
    Orange-ISRGW#sh flash
    -#- --length-- -----date/time------ path
    2         1440 Oct 24 2013 11:23:26 -07:00 vlan.dat
    3     63714548 May 3 2010 11:49:40 -07:00 c2800nm-adventerprisek9_ivs_li-mz.151-1.T.bin
    5     67871024 Nov 9 2012 19:05:24 -08:00 c2800nm-adventerprisek9-mz.151-4.M5.bin
    124751872 bytes available (131600384 bytes used)
    Orange-ISRGW#

  • Please help with executing a java program from another java program

    Hi, I have tried to execute a very simple java program which is printed out "Hello world" from another java gui program when the user click on the "START" button. However, I don't receive any print out on the terminal when they click it. These two programs are being developed in Unix environment. Here is the code that I am trying to use.
    Runtime r = Runtime.getRuntime();
    r.exec("java HelloWorld");
    p.s. HelloWorld is java class of the HelloWorld.java

    I think you have to luanch your MS Prompt first before executing the command.

  • Need help with a cash register program.

    I'm a noob at JAVA, but having fun with i so far! I was wondering if anyone could help me with a school project I need to get done. I've done most of the work, but I can't get it to not display when I have zero results. What I mean is that the project requires you to create a cash register program that gives you change in 20's, 5's, and 1's for a hundred dollar bill. I get it to display the results, but if there are zero of any category, like in the last problem, I can't let it show. Could someone please help! Thank you in advance! Here's what I have so far (sorry about the rapidshare download ^_^;).
    [http://rapidshare.de/files/39978938/project.java.html]

    Zack,
    The user should not see the line: 0 $5 bill(s)Then you need to detect the situation where no five dollars bills are included in the change, and suppress the output of that line.
    I can read your mind... it's going something like "yeah well righto smartass, I knew that allready... my question was _HOW_ to make that happen...
    And my answer to that is "I'm not telling you"... well, not straight out anyway, coz you'll actually learn more if your struggle a bit (but not too much) yourself...
    So... I suggest you (at least) read through [this page|http://java.sun.com/docs/books/tutorial/java/nutsandbolts/if.html] on the +if+ statement, and maybe even try out the examples, which should (I imagine) take maybe half an hour or so. "Selection" is an absolutely core programming construct... and the concept is common to every programming language ever (AFAIK) invented... meaning that you will really struggle until you "get" the +if+ statement... so that half hour would be time well spent.
    When you've got +if+ concept onboard, you can attempt to apply it to your immediate problem, suppressing those annoying fivers! Have a go yourself, if get really stumped than post a _specific_ question here about the bit that's stumped you.
    I know it can be frustrating... but that just hightens the little thrill you get when you "get it".
    Cheers. Keith.

  • I need help with a lab from programming.

    I need the following tasks implemented in the code I wrote below. I would really appreciate if someone could achieve this because it would help me understand the coding process for the next code I have to write. Below are the four classes of code I have so far.
    save an array of social security numbers to a file
    read this file and display the social security numbers saved
    The JFileChooser class must be used to let the user select files for the storage and retrieval of the data.
    Make sure the code handles user input and I/O exceptions properly. This includes a requirement that the main() routine does not throw any checked exceptions.
    As a part of the code testing routine, design and invoke a method that compares the data saved to a file with the data retrieved from the same file. The method should return a boolean value indicating whether the data stored and retrieved are the same or not.
    * SSNArray.java
    * Created on February 28, 2008, 9:45 AM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package exceptionhandling;
    import java.util.InputMismatchException; // program uses class InputMismatchException
    import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName;
    * @author mer81348
    public class SSNArray
        public static int SOCIAL_SECURITY_NUMBERS = 10;
        private String[] socialArray = new String[SOCIAL_SECURITY_NUMBERS];
        private int socialCount = 0;
        /** Creates a new instance of SSNArray */
        public SSNArray ()
        public SSNArray ( String[] ssnArray, int socialNumber )
            socialArray = ssnArray;
            socialCount = socialNumber;
        public int getSocialCount ()
            return socialCount;
        public String[] getSocialArray ()
            return socialArray;
        public void addSocial ( String index )
            socialArray[socialCount] = index;
            socialCount++;
        public String toString ()
            StringBuilder socialString = new StringBuilder ();
            for ( int stringValue = 0; stringValue < socialCount; stringValue++ )
                socialString.append ( String.format ("%6d%32s\n", stringValue, socialArray[stringValue] ) );
            return socialString.toString ();
        public void validateSSN ( String socialInput ) throws InputMismatchException, DuplicateName
            if (socialInput.matches ("\\d{9}"))
                return;
            else
                throw new InputMismatchException ("ERROR! Incorrect data format");       
    * SSNArrayTest.java
    * Created on February 28, 2008, 9:46 AM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package exceptionhandling;
    import java.util.InputMismatchException; // program uses class InputMismatchException
    import java.util.Scanner; // program uses class Scanner
    import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName;
    * @author mer81348
    public class SSNArrayTest
        /** Creates a new instance of SSNArrayTest */
        public SSNArrayTest ()
         * @param args the command line arguments
        public static void main (String[] args)
            // create Scanner to obtain input from command window
            Scanner input = new Scanner ( System.in );
            System.out.printf ( "\nWELCOME TO SOCIAL SECURITY NUMBER CONFIRMER\n" );
            SSNArray arrayStorage = new SSNArray ();
            for( int socialNumber = 0; socialNumber < SSNArray.SOCIAL_SECURITY_NUMBERS; )
                String socialString = ( "\nPlease enter a Social Security Number" );
                System.out.println (socialString);
                String socialInput = input.next ();
                try
                    arrayStorage.validateSSN (socialInput);
                    arrayStorage.addSocial (socialInput);
                    socialNumber++;
                catch (InputMismatchException e)
                    System.out.println ( "\nPlease reenter Social Security Number\n" + e.getMessage() );
                catch (DuplicateName e)
            System.out.printf ("\nHere are all your Social Security Numbers stored in our database:\n");
            System.out.printf ( "\n%8s%32s\n", "Database Index", "Social Security Numbers" );
            System.out.println (arrayStorage);
    * SSNArrayExpanded.java
    * Created on February 28, 2008, 9:52 AM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package exceptionhandling;
    import java.util.InputMismatchException;
    import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName;
    * @author mer81348
    public class SSNArrayExpanded extends SSNArray
        /** Creates a new instance of SSNArrayExpanded */
        public SSNArrayExpanded ()
        public SSNArrayExpanded ( String[] ssnArray, int socialNumber )
            super ( ssnArray, socialNumber );
        public void validateSSN ( String socialInput ) throws InputMismatchException, DuplicateName
            super.validateSSN (socialInput);
                int storedSocial = getSocialCount ();
                for (int socialMatch = 0; socialMatch < storedSocial; socialMatch++ )
                    if (socialInput.equals (getSocialArray () [socialMatch]))
                        throw new DuplicateName ();
            return;
    * SSNArrayTestExpanded.java
    * Created on February 28, 2008, 9:53 AM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package exceptionhandling;
    import java.util.InputMismatchException; // program uses class InputMismatchException
    import java.util.Scanner; // program uses class Scanner
    import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName;
    * @author mer81348
    public class SSNArrayTestExpanded
        /** Creates a new instance of SSNArrayTest */
        public SSNArrayTestExpanded ()
         * @param args the command line arguments
        public static void main (String[] args)
            // create Scanner to obtain input from command window
            Scanner input = new Scanner ( System.in );
            System.out.printf ( "\nWELCOME TO SOCIAL SECURITY NUMBER CONFIRMER\n" );
            SSNArrayExpanded arrayStorage = new SSNArrayExpanded(); 
            for( int socialNumber = 0; socialNumber < SSNArray.SOCIAL_SECURITY_NUMBERS; )
                String socialString = ( "\nPlease enter a Social Security Number" );
                System.out.println (socialString);
                String socialInput = input.next ();
                try
                    arrayStorage.validateSSN (socialInput);
                    arrayStorage.addSocial (socialInput);
                    socialNumber++;
                catch (InputMismatchException e)
                catch (DuplicateName e)
                    System.out.println ( "\nSocial Security Number is already claimed!\n" + "ERROR: " + e.getMessage() ); 
            System.out.printf ("\nHere are all your Social Security Numbers stored in our database:\n");
            System.out.printf ( "\n%8s%32s\n", "Database Index", "Social Security Numbers" );
            System.out.println (arrayStorage);
    }

    cotton.m wrote:
    >
    That writes creates the file but it doesn't store the social security numbers.True.Thanks for confirming that...
    How do I get it to save?
    Also, in the last post I had the write method commented out, the correct code is:
         System.out.printf ("\nHere are all your Social Security Numbers stored in our database:\n");
            System.out.printf ( "\n%8s%32s\n", "Database Index", "Social Security Numbers" );
            System.out.println ( arrayStorage );
            try
                File file = new File ("Social Security Numbers.java");
                // Create file if it does not exist
                boolean success = file.createNewFile ();
                if (success)
                      PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("Social Security Numbers.txt")));               
    //                BufferedWriter out = new BufferedWriter (new FileWriter ("Social Security Numbers.txt")); 
                    out.write( "what goes here ?" );
                    out.close ();
                    // File did not exist and was created
                else
                    // File already exists
            catch (IOException e)
            System.exit (0);
    }It still doesn't write.

Maybe you are looking for

  • ICal displaying events that last more than one day?

    Can I change the way iCal displays an event lasting many days (particularly in the Month view)?  For example, if I put in a vacation lasting 1 week, or a conference lasting 3 days. I would just like it to look the way it does on my iPad, iPhone, or G

  • Exception condition CONFIG_NOT_FOUND raised in opportunity page

    Hi Experts,                 I am getting an exception in opportunity page as follows : The following error text was processed in the system MCD : Exception condition "CONFIG_NOT_FOUND" raised. The error occurred on the application server gsusapdp03_M

  • Table is missing in ms-access shutter

    when open the shutter bar tables is missing when I choose Query ti show tables all the line titles has moved other sumptuous is that the find box is  not show the title "serach doument" please help

  • PCM installation on MS SQL 2008 R2

    Hi Experts, I am installating PCM 7.5 on MS SQL 2008 R2, but it gives me an error, the message is "Failed to connect to the Primary Server. The following error occurred: 80880007 Incorrect Database Version". Is there a new installation which works fo

  • How to make first page to display when running the project

    hi friends, as i am new this development in webdynpro, i am getting lot of support from the forum. i am thankfull them all. now i am having many views in my project and i am navigating from one another. if i want to make one particular view as first