Some java help needed!!!!

Exception in thread "main" java.lang.NullPointerException
     at Standings.<init>(Standings.java:15)
     at Client.main(Client.java:21)
this is my program and I dont understand what is going wrong, I am also including the 2 classes that complement it.
class 1
public class Team
// Declaring Private Variables
private double wins;
private double loses;
private String Name;
public Team()
     Name="";
     wins=0;
     loses=0;
public Team(String t, double w, double l)
     Name=t;
     wins=w;
     loses=l;
public void setName (String n)
     Name=n;
public void setWins (double w)
     wins=w;
public void setLoses (double l)
     loses=l;
public String getName ()
     return Name;
public double getWins ()
     return wins;
public double getLoses ()
     return loses;
public String toString ()
     String toString=Name + " " + wins + " " + loses;
     return toString;
public boolean equals (Team p1, Team p2)
     if ((p1.Name.equals(p2.Name))&&(p1.wins==p2.wins) && (p1.loses==p2.loses))
          return true;
     else
          return false;
class 2
public class Standings
private Team [] teams;
private String [] steams;
public Standings (Team [] arr)
     for(int i=0;i<arr.length;i++)
          teams[i] = new Team(arr.getName(), arr[i].getWins(), arr[i].getLoses());
public Team [] toString2 ()
          return teams;
client program
import java.text.DecimalFormat;
import java.util.Scanner;
import java.io.File;
import java.io.IOException;
public class Client
public static void main( String [] args ) throws IOException
     //first let's create an array of football teams
     Team [] array = new Team[5];
     array[0] = new Team("Alabama", 6, 6);
     array[1] = new Team("Georgia", 7, 4);
     array[2] = new Team("Tennessee", 8, 3);
     array[3] = new Team("Vanderbilt", 4, 8);
     array[4] = new Team("Mississippi", 1, 6);
     // now instantiate the team calling the overloaded constructor
     Standings temp = new Standings(array);
     // now let's print the team (call toString)
     System.out.println(temp.toString());
//Standings another = new Standings( temp );

private Team [] teams;You never allocated this array, as in:
teams = new Team[size];
so when you get to this line:
teams[ i ] = new Team(...);teams is null, ergo the NullPointerException.

Similar Messages

  • Some urgent help needed with MobileMe suddenly saying my password is wrong

    Hi
    First of all I want to say sorry if this is in the wrong forum, but I needed some urgent help and I couldn't find a forum other than this that might relate to this issue.
    The issue that I am having is with my MobileMe Account. I was on my Mac, when when my MobileMe Account suddenly dropped its connection and told me that I had entered the wrong username or password (I know I hadn't) I tried to re-enter them but every time I try I just get a message that says I have entered the wrong username or password. I no longer have access to my Mail, I can not sing-in to MobileMe to access my online account and it wont let me change the password because it keeps saying that safari can not open the page.
    I can not sign-in to my MobileMe folders on my Mac and it wont sync. I was signed in perfectly fine before this happened so I know its nothing to-do with my password or user name.
    I am now locked out of MobileMe and need some help as to what might have went wrong
    Can someone please give me some quick help as this is really worrying me as I am afraid my MobileMe account might of been hacked (that is the kind of behaviour that I am seeing - saying that my username and password are wrong, when they are not, and not letting me sign in to change them)
    Huge thanks

    Ughhh,
    it seems my panic was for nothing. I just ran apple 24 hour support and they put it right for me it cost me but I'd rather be safe and pay then loose all the information I have on MobileMe. This has taught me a lesson anyway, I need to keep a backup of everything and not just rely on time machine

  • Need some java help - arrays

    I've been learning java for the past few weeks and I'mstuck with the following question:
    Write a short program to store the input values of a user-specified amount of whole numbers and output them in a multipcation matrix form, with correct formatting.
    For example, the input of of three numbers 1, 2 and 3 would produce the followinf matrix:
    *1 2 3*
    *2 4 6*
    *3 6 9*
    or the input of 4 numbers 3,7, 4 and 9 would produce the following matrix:
    *3 7 4 9*
    *7 49 28 63*
    *4 28 16 36*
    *9 63 36 81*
    whereby the inner numbers in the grid represent the product of the number on the corresponding top row and left most column, i.e 36 = 9 4*
    The user must be initially be allowed to specify how many numbers they wish to enter, followed by the number themselves. You must maked use of an array for this exercise. Ensure the proper formatting rules are adhered to, i.e. that all columns are aligned vertically (right justified). You can assume no input number greater than 100 will be entered.
    I was wondering if someone could help me with this?

    Or better yet:
    [] 3  7  4  9
    3  9 21 12 27
    7 21 49 28 63
    4 12 28 16 36
    9 27 63 36 81which is i am sure what you were after flounder, the formatting for some reason kept moving the top row over to the left.
    P.S. If the OP is still here...here is a bit of a head start.
    public static void main(String[] args) {
           Scanner sc1 = new Scanner(System.in);
           int[] array;
           int x;
           int y;
           System.out.println("How many numbers do you want to enter? ");
           x = sc1.nextInt();
           array = new int[x];
           System.out.println("Please enter your numbers ");
           for (int i=0;i<x;i++){
               y = sc1.nextInt();
               array=y;
    //test printing contents of array
    System.out.println("--------------");
    System.out.println();
    System.out.println("OUTPUT");
    System.out.println();
    System.out.println("--------------");
    for(int j=0;j<array.length;j++){
    System.out.print(array[j]);

  • *Basic* Java help needed...

    I feel like a complete novice for posting this kinda stuff, but i figured somebody would take 5 minutes and help me out. My final in my programming class depends on 2 programs, one of which is giving me some actual trouble.
    What I have to do is create a java applet that allows a user to input their weight, select a planet, and then have their weight converted to what their weight would be on the selected planet. However, if the ouput is higher than 60 pounds, I need a picture of the michelin man to appear and the theme from star wars to play. If it is below 60, A multicolored asterisk should be displayed with applause.
    I will post what code I have already made. Please note: ITS VERY VERY BASIC. I may have overcomplicated some things, and there is always more than one way to do something (in my experience). Also, I kinda just converted a temperature conversion applet, so there may be some extra stuff I don't need.
    Please help.
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    public class tempsapp2 extends Applet implements ActionListener
    Label prompt1;
    TextField input1;
    Label prompt2;
    TextField input2;
    int number1, number2;
    int mercury, venus, earth, mars, jupiter, saturn, neptune, uranus, pluto, result;
    public void init()
    prompt1 = new Label ("Enter your weight:");
    add (prompt1);
    input1 = new TextField (10);
    add (input1);
    prompt2 = new Label ("Enter the Number of the Planet you would like to have your weight converted to:");
    add (prompt2);
    input2 = new TextField (10);
    add (input2);
    input2.addActionListener(this);
    add (input2);
    public void paint (Graphics g)
    number1 = Integer.parseInt(input1.getText());
    number2 = Integer.parseInt(input2.getText());
    mercury = (number1*3780)/1000;
    venus = (number1*9070)/1000;
    earth = (number1*10)/1000;
    mars = (number1*3770)/1000;
    saturn = (number1*9160)/1000;
    uranus = (number1*8890)/1000;
    neptune = (number1*1125)/1000;
    jupiter =  (number1*2364)/1000;
    pluto = (number1*670)/1000;
    if(number2==1)
    g.drawString("Your weight on Mercury would be "+mercury+" lbs",100,150);
    else if(number2==2)
    g.drawString("Your weight on Venus would be "+venus+" lbs",100,150);
    else if(number2==3)
    g.drawString("Your weight on Earth would be "+earth+" lbs",100,150);
    else if(number2==4)
    g.drawString("Your weight on Mars would be "+mars+" lbs",100,150);
    else if(number2==5)
    g.drawString("Your weight on Jupiter would be "+jupiter+" lbs",100,150);
    else if(number2==6)
    g.drawString("Your weight on Saturn would be "+saturn+" lbs",100,150);
    else if(number2==7)
    g.drawString("Your weight on Uranus would be "+uranus+" lbs",100,150);
    else if(number2==8)
    g.drawString("Your weight on Neptune would be "+neptune+" lbs",100,150);
    else if(number2==9)
    g.drawString("Your weight on Pluto would be "+pluto+" lbs",100,150);
    public void actionPerformed(ActionEvent evt)
      number1 = Integer.parseInt(input1.getText());
      number2 = Integer.parseInt(input2.getText());
      repaint();
    }

    I am guessing that you are wondering where to go from here. If so http://java.sun.com/products/plugin/1.5.0/demos/applets/Animator/Animator.java may prove helpful.
    Also I would recommend using arrays of planet names and weight multipliers. It could make your code a lot less cumbersome.

  • Java help needed(PLEASE)

    I have a Question for all you gifted people:
    I am designing a sort of quiz which takes questions and three possible answers from a database(which also holds the real answer).It prints these on the dos screen and I then have a System.in statement which allows the user to enter his or her answer (eg A,B,C or 1,2,3). I need a way of adding up the score at the end!!I was thinking of storing there answers in an array and compairing there answer to my correct answer in the database and if it is the same add 1 and if it not the same add 0???
    How would i write the System.in answers into an array and add them up???
    These are my thoughts on how to do this i would love to hear yours!! And also a help with writing the code for the above system of scoreing would be GREATLY appriciated!!
    thanks everyone,
    james.

    As mathuoa pointed out, since you already display the 3 possible answers to the user, get them into an array and display them on the screen. Then, as the user enters an answer, compare them with the three answers and if it is correct, update the score variable as such. If you want the history of answers that the user has given, then u will have to use a Vector/List/some such collection object to hold the user's answers.
    java.util.Vector answers = new java.util.Vector();
    answers.add(usersAnswer1);
    answers.add(usersAnswer2);
    Then, to get the entries,
    for(Enumeration e = answers.elements(); e.hasMoreElements();)
    System.out.println(e.nextElement());
    //Do something with the answer.
    This is one possible way of getting the answers from the user!

  • Adobe Lightroom 4 - Some Questions / Help Needed

    Hi everyone.
    After advice from several experts, I've just purchased Adobe Lightroom 4. I've already got Photoshop CS5, but I was looking for something proper to organise my photos, plus I found Lightroom easier to do the sort of editing I am wanting to do. Now, I only really use photoshop for things like colour pops, or really in-depth editing. Anyway, I'm loving Lightroom so far, but there is some stuff I'm not very sure of, so I'd appreciate some help
    1. Organising
    Firstly, I'm not really sure how to organise. At the moment, I've just got lots of folders with random events in My Pictures on W7, so I might have a folder called April 11, which contains photos from that month but that might have been a wedding or an easter holiday or both. So it doesn't really work. \
    I understand in Lightroom what catalogs are. But I know enough to know that I don't want to group mine into those, its getting too complicated. What I don't know though is the difference between a collection and a folder. Basically, I'm wanting to reimport and reorganise all my photos, so I want to put them into "events" as such like you can do on iPhoto on a mac, so I would have "France Summer Holiday 11" for example, or "Mia's Wedding". I'm not really sure on the best way to do this ...?
    2. Editing
    I've played around quite a bit so far, and I really like what I've seen. On a lot of photos, I've made a lot of changes. But from what I can see, these changes are stored merely in Lightroom itself. For example, at the moment I'm importing photos from my external disk into Lightroom, which then saves them in C://My Pictures/Lightroom/Pictures . When I go look at these photos in windows explorer which I know I have edited, it doesn't show any of the changes or editing I've done on them. Now I realise this is me being stupid, but why doesn't it? Supposing I then want to email that photo to a friend that I have edited? How would I do that? I don't want to have to open lightroom and export every single photo I edit? There must be a simpler way?
    Likewise for backing up, because all my files are in subfolders within C:// My pictures / Lightroom / Pictures, to back up I was simply going to set up windows to copy that latter folder onto my external HDD everytime I plugged it in. This would be pointless however if it isn't physically overwriting the original photo with my edited version?
    3. Editing 2
    Something else I like to do is make lots of different edits to the same photo. For example, at the moment I'm editing a photo of a pier at night. I spent ages adjusting colours and lighting and so on, and now it looks great. But I would also like to save a copy of that photo with the "old age photo" effect preset on. Is this possible? and how do I do it? Other than obviously importing a duplicate?
    4. & 5. & 6 - Misc:
    4. Simple question - how do I add tags, keywords or comments if I haven't done it on import?
    5. My camera doesn't have built in GPS. Is it possible for me to manually geotag photos (in a batch, say for a Summer Holiday to NY), could I manually add a geotag for all these photos?
    6. I also forgot to add copyright information on import for some, is it possible to do this after import and how?
    7. I normally shoot in JPEG. I probably shoot shoot in RAW as everyone tells me to do so. Are there any significant advantages in terms of quality, and for editing with?
    Thanks for any help given. I appreciate this is a lot of questions, but I could really use the advice.

    Hi William,
    1. Organising
    Firstly, I'm not really sure how to organise. At the moment, I've just got lots of folders with random events in My Pictures on W7, so I might have a folder called April 11, which contains photos from that month but that might have been a wedding or an easter holiday or both. So it doesn't really work. \
    I understand in Lightroom what catalogs are. But I know enough to know that I don't want to group mine into those, its getting too complicated. What I don't know though is the difference between a collection and a folder. Basically, I'm wanting to reimport and reorganise all my photos, so I want to put them into "events" as such like you can do on iPhoto on a mac, so I would have "France Summer Holiday 11" for example, or "Mia's Wedding". I'm not really sure on the best way to do this ...?
    I am not so sure if you understand *catalogs*.
    You need a catalog, exactly 1 in my opinion. A catalog is a database. The Lightroom database, where records about your images are stored, including the pointers to your images, which are not inside a catalog! LR backups just does the backup of the catalog (i.e. a file ending .lrcat). You need to take care separately that your real images are backed up !
    Inside your LR database the best way to organize is via collections - this will give you what you want with "France summer holiday 11" etc.
    Folders are relatively unimportant, just storage buckets. They should be *handy portions*, I would prefer them with below 3000 images each, as there currently some bugs to those bigger ones.
    Before you start with LR, you can organize your pictures in Mac Finder / WindowsExplorer.
    Or you could do it with the help of LR, by copying your images over during import into the destination folders (and deleting today's folders afterwards after having verified that everything is fine).
    A simple date-based structure will do, I'd recommend  a root parent folder like "LR images", underneath one folder per year (\2010\, \2011\, \2012\...) and underneath them either
    just one folder per month (LR can auto-create them for you)
    or you create the folders in import dialog as e.g. "YYYY-MM-DD description of shoot", to have a mini-diary overview also in your OS.
    Apart from that you create collections, either *dumb ones*, where you drag images into, or smart ones, where you specify criteria according to which they get auto-filled.
    2. Editing
    I've played around quite a bit so far, and I really like what I've seen. On a lot of photos, I've made a lot of changes. But from what I can see, these changes are stored merely in Lightroom itself. For example, at the moment I'm importing photos from my external disk into Lightroom, which then saves them in C://My Pictures/Lightroom/Pictures . When I go look at these photos in windows explorer which I know I have edited, it doesn't show any of the changes or editing I've done on them. Now I realise this is me being stupid, but why doesn't it? Supposing I then want to email that photo to a friend that I have edited? How would I do that? I don't want to have to open lightroom and export every single photo I edit? There must be a simpler way?
    Likewise for backing up, because all my files are in subfolders within C:// My pictures / Lightroom / Pictures, to back up I was simply going to set up windows to copy that latter folder onto my external HDD everytime I plugged it in. This would be pointless however if it isn't physically overwriting the original photo with my edited version?
    LR will never overwrite your original photos.
    You can save most of the catalog content into the xmp-part of the original photo, which is either a sidecar-file (.xmp) or part of the file format, like for DNG, TIFF, PSD, JPG. To do so you select the image in LR and hit <ctrl> s. Or you set it up for continuous update, which creates a lot of operations while you play back and forth in develop.
    I do that on my own, typically twice per file: once I am done with develop, once I am done with keywording and other metadata update.
    LR contains records about your images, i.e. a set of instructions how they are to be interpreted. That is all.
    So of course you need LR to export the result of these instructions, which is actually pretty quick.
    To backup your images you need to do that just once, plus you backup your LR catalog. Or if you save xmp to the files, you can do another backup once xmp is ready.
    I would not consider this pointless. You just have to think that there are 2 places with data for your images: the images themselves and a database with interpretation instructions.
    3. Editing 2
    Something else I like to do is make lots of different edits to the same photo. For example, at the moment I'm editing a photo of a pier at night. I spent ages adjusting colours and lighting and so on, and now it looks great. But I would also like to save a copy of that photo with the "old age photo" effect preset on. Is this possible? and how do I do it? Other than obviously importing a duplicate?
    Yes, this is one of LR's beauties: you create a so-called *virtual copy*, which is just a 2nd record for the same original image file with different interpretation settings, like black-and-white, a different crop size, different development etc. You can have as many virtual copies as you like, and you'll see them as additional thumbnails.
    Virtual copies are not saveable into xmp, though. There is another concept which is saveable into xmp: snapshots. but these are different states in develop history, and you do not see outside develop module that you have several.
    If you export virtual copies e.g. to jpg one file per virutal copy will be created.
    4. & 5. & 6 - Misc:
    4. Simple question - how do I add tags, keywords or comments if I haven't done it on import?
    5. My camera doesn't have built in GPS. Is it possible for me to manually geotag photos (in a batch, say for a Summer Holiday to NY), could I manually add a geotag for all these photos?
    6. I also forgot to add copyright information on import for some, is it possible to do this after import and how?
    7. I normally shoot in JPEG. I probably shoot shoot in RAW as everyone tells me to do so. Are there any significant advantages in terms of quality, and for editing with?
    Thanks for any help given. I appreciate this is a lot of questions, but I could really use the advice.
    ad 4: you use the library module, metadata panel to enter.
    ad 5: you use the map module. Either you manually drop your images on a map, or you have a separate GPS track to load and have LR assign via matching time-stamps.
    ad 6: like 4
    ad 7: You don't need JPG from your camera, you can achieve better results viy LR from RAW. Yes, there are significant advantages as to editing headroom.
    Overall, may I suggest my favorite learning material for LR? First watch Julieanne's Tutorial Videos.
    Then go play and use Victoria Bampton's eBook or paper copy of her "Missing FAQs to LR4": http://www.lightroomqueen.com/books/adobe-lightroom-4-missing-faq/
    Have fun,
    Cornelia

  • Java help needed-Inventory System

    I urgently need help in finishing my java inventory project for school. Can anyone help me usin files and streams to get the program to save data and help me get the menu to work pls THANKS> Heres the source code below:
    // TextForm.java
    // A simple label/field form panel
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class TextForm extends JPanel {
    private JTextField[] fields;
    // Create a form with the specified labels, tooltips, and sizes.
    public TextForm(String[] labels,
    int[] widths, String[] tips) {
    super(new BorderLayout());
    JPanel labelPanel = new JPanel(new GridLayout(labels.length, 1));
    JPanel fieldPanel = new JPanel(new GridLayout(labels.length, 1));
    add(labelPanel, BorderLayout.WEST);
    add(fieldPanel, BorderLayout.CENTER);
    fields = new JTextField[labels.length];
    for (int i=0; i < labels.length; i+=1) {
    fields[i] = new JTextField();
    if (i < tips.length) fields.setToolTipText(tips[i]);
    if (i < widths.length) fields[i].setColumns(widths[i]);
    JLabel lab = new JLabel(labels[i], JLabel.RIGHT);
    lab.setLabelFor(fields[i]);
    labelPanel.add(lab);
    JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
    p.add(fields[i]);
    fieldPanel.add(p);
    JScrollBar JScrollBar = new JScrollBar();
    JScrollBar vbar = new JScrollBar(JScrollBar.VERTICAL, 30, 40, 0, 300);
    add(vbar, BorderLayout.EAST);
    public String getText(int i) {
    return( fields[i].getText() );
    public static void main(String[] args) {
    String[] labels = { "115ml Medicine", "236.60ml Water-clear", "236.60 Water-Amber", "250ml Irish Moss",
    "250ml Sauce", "355ml Water", "380ml Juice", "473ml Vinegar", "500ml Water", "500 ml Blue Water", "600ml Water",
    "750ml Syrup/honey", "900ml Disinfectant", "1000ml Syrup", "1500ml Water", "Total # caps:" };
    int[] widths = { 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 ,12 };
    String[] descs = { "", "Enter Quantity" };
    final TextForm form = new TextForm(labels, widths, descs);
    JButton submit = new JButton("Save Inventory");
    JButton cancel = new JButton( "Cancel");
    submit.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    JOptionPane.showConfirmDialog(null,"Are you sure you want to save this record?");
    JOptionPane.showMessageDialog(null, " Inventory status updated");
    JOptionPane.showConfirmDialog(null, "Do you want to exit?");
    JFrame f = new JFrame("Sweet Inventory System");
    f.getContentPane().add(form, BorderLayout.NORTH);
    JPanel p = new JPanel();
    p.add(submit);
    f.getContentPane().add(p, BorderLayout.CENTER);
    f.pack();
    f.setVisible(true);
    Its error free except i cant see the menubar or get it to save items usin files and streams.
    HELP PLEASE

    TELL ME THE CODE I CAN USE TO MAKE IT SAVE ITEMS LIKE
    IN A TEXT FILE AND HOW CAN I ATTACH IT TO THE SAVE
    BUTTON USIN A LISTENER
    THANKS
    PLS POST HEREPosts like this make me ignore you forever.

  • A little assistance and some big help needed

    I seem to be running into a problem migrating an MSAccess 2000 database to XE.
    I open the omwb2000.mde, select the database and define the location for the schema and data export.
    The DAO msi opens and I get error 1706. No Valid Source could be found for product DAO. the windows installer cannot continue.
    If I cancel the DAO and if I add forms and reports from the .mde I get error #5 - XML Exporter. Invalid procedure or call argument (the database location) Database Schema Export did not complete successfully.
    Any help is very appreciated.
    My local environment is:
    Win XP SP2
    Office 03 SP2
    Oracle XE
    OMWB 10.1.0.4.0

    Hi,
    Have you tried re-registering the DAO dao360.dll? If, for some reason, your MDAC install has gotten corrupt, you'll need to re-register. Try executing the following from the Start | Run command:
    regsvr32 "c:\program files\common files\microsoft shared\dao\dao360.dll"
    I would also recommend using the omwb2003.mde, and converting your MS Access 2000 database to 2003, seeing as you have MS Access 2003 installed on your machine. We recommend using the version of the Exporter Tool that corresponds with the version of MS Access installed on your machine.
    I hope this helps.
    Regards,
    Hilary

  • CSS11506 - Some basic help needed

    Alright, I have a CSS11506 in the lab and I am trying to configure it into a reverse proxy config. So I would like to have all inbound http requests hit the CSS and then have it redirect to our web server on correct DMZ. Having never setup a CSS before I need some help.
    - Is my service type proxy-cache, type redirect or type transparent cache ?
    I know this should be fairly easy to do with the 11506. Can you also provide some docs explaining the config walkthru.
    Any help would be appreciated.
    Cheers
    Dave

    Thanks, that explains a few things.
    So assuming the following, DMZ web server ip is 192.168.20.50 and VIP for CSS is 192.168.20.100, basically I would want to redirect all inbound http requests from 192.168.20.100 to the 192.168.20.50 using the following CSS config ?
    service rprox1
    ip address 192.168.20.50
    protocol tcp
    port 8080
    active
    owner clee
    content redirect_rule
    add service rprox1
    vip address 192.168.20.100
    protocol tcp
    port 8080
    url "/*"
    Like I said, never configured one yet so this is my first attemtp.
    Thanks again for the help
    Cheers
    Dave

  • Some more help needed.

    Hi,
    I'm back again.
    This time I need help with just one part of the code for my program.
    right now in part of my code I have it ask for a name, but now I want to put in an if statement and see if soemone writes a number instead of a letter. I can't find that code anywhere, so can anyone help with this?
    Thanks.

    Even though I'm 11 I am trying to obtain madcore Java skillz.
    I don't understand what you said in that program. I have this:
    class majorAssignment {
      public static void main (String[] args) {
        //Introduction to Pinkerton
        System.out.println("Welcome to the Christopher Walken paycheck calculator, aka: 'The Walken Experience'.");
        System.out.println("Please make sure that what you input into The Walken Experience is exactly what he asks for... Or else you'll find a pile of your own organs knocking at your door.");
        System.out.println("The Walken Experience: Hello, \n Now scootch over and tell me your first name. Please. Do not make me tell you again. About the scootching.");
           //Lets be greedy and grab someone's personal information
           String familyName = In.getString();
             if (familyName
                 //run
             else
                //runHow can I fit it in like that?

  • Calling perl script from java ---help needed

    I haven't been doing a lot with java lately and i'm building an app with netbeans and having some difficulty with my button calling an outside perl script I'm pasting the code and error below...any help would be greatly appreciated. It's running on fedora 9 pretty much default install...
    thanks.
    code:
    Runtime r = Runtime.getRuntime();
    Process p = null;
    String s = null;
    String cmd123[] = { "perl /home/deaddev/test1.pl" };
    try {
    p = r.exec(cmd123);
    catch {
    foo bar/etc/etc
    error:
    Oct 12, 2008 4:09:37 PM photomainmgr readToPerlActionPerformed
    SEVERE: null
    java.io.IOException: Cannot run program "perl /home/deaddev/test1.pl": java.io.IOException: error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:474)
    at java.lang.Runtime.exec(Runtime.java:610)
    at java.lang.Runtime.exec(Runtime.java:483)
    at photomainmgr.readToPerlActionPerformed(photomainmgr.java:117)
    at photomainmgr.access$000(photomainmgr.java:21)
    at photomainmgr$1.actionPerformed(photomainmgr.java:54)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:253)
    at java.awt.Component.processMouseEvent(Component.java:6101)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3276)
    at java.awt.Component.processEvent(Component.java:5866)
    at java.awt.Container.processEvent(Container.java:2105)
    at java.awt.Component.dispatchEventImpl(Component.java:4462)
    at java.awt.Container.dispatchEventImpl(Container.java:2163)
    at java.awt.Component.dispatchEvent(Component.java:4288)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4461)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4125)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4055)
    at java.awt.Container.dispatchEventImpl(Container.java:2149)
    at java.awt.Window.dispatchEventImpl(Window.java:2478)
    at java.awt.Component.dispatchEvent(Component.java:4288)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:604)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
    Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:164)
    at java.lang.ProcessImpl.start(ProcessImpl.java:81)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:467)
    ... 30 more
    error executing perl /home/deaddev/test1.pl

    jschell wrote:
    sabre150 wrote:
    As and alternative you can useString cmd123 = "perl /home/deaddev/test1.pl";Using the single string approach YOU have to do any quoting so with this line no quoting takes place and the script /home/deaddev/test1.pl will be executed.Although that should be true apparently it isn't. I have just run  
    Process p = Runtime.getRuntime().exec("perl /home/sabre/work/dev/perl/xxx.pl");
    new Thread(new SyncPipe(p.getErrorStream(), System.err)).start();
    new SyncPipe(p.getInputStream(), System.out).run();
    int returnCode = p.waitFor();
    System.out.println("Return code = " + returnCode);which correctly executes the perl script xxx.pl.
    P.S. SyncPipe is a Runnable that copies an InputStream to an OutputStream.
    Edited by: sabre150 on Oct 14, 2008 9:19 AM
    Interesting! Even though Runtime.exec() works with a single String, ProcessBuilder fails with this approach! You have to split the argument string. This certainly looks like a bug! Some while ago I looked at the source for Runtime.exec() to look at the differences between Runtime.exec() and ProcessBuilder and found that behind the scenes Runtime.exec() uses ProcessBuilder.
    More research is required.

  • Psuedocode to java. help needed if poss

    i need to convert the following into java, but i am not sure how to output it..
    Roll a 12 sided die to choose a number between 1...12
    while the user has not made an incorrect guess
    ask the user if the next number will be higher or lower
    choose random number
    if users guess is correct
    increment count of correct guesses
    update the stored current number
    end if
    end while
    tell the user how many correct guesses there are
    any help would be greatful, i am a beginning so go easy!!!
    thanks alot
    stevie

    hey, sorry if i've caused a 'cross post', i am not too sure what it is but i hope i haven't done anything wrong! so far i am just trying to put a basic program together before building on it..
    import java.util.scanner;
    public class dice
    public static void main (String [] args)
    Scanner in = new Scanner(System.in);
    Random rnd = new Random();
    System.out.print("input a number between one and twelve")     int r =in.nextInt;
                   int r = rnd.nextInt(12) + 1;
              System.out.println(r);
    i know this has errors, but i was just hoping for a hint/clue for the basic program before researching more to build on it.. hope this code will help. reply when you can, thank you very much
    stevie

  • New to java,,,help needed urgently

    I am geeting a compile error..."cannot resolve symbol" in my main class. The program is supposed to prompt the user for five sets of data, and calculate the tax and total of the entered products and print it back to the screen, it is also supposed to calculate the cheapest and most expensive item and print them back. can someone pls shed some light on this error msg, as I cant seem to get my head around it.
    import java .io.*;
    import java.util.StringTokenizer;
    import java.text.NumberFormat;
    import java.util.Locale;
    //set up a class to call on the constructors from the catalogueitem class
    public class Myassg4
         private static final int MAX = 2;//sets the length to 2
         private static CatalogueItem[] prodlist ;//sets array for product list
         NumberFormat cash = NumberFormat.getCurrencyInstance(new Locale("en","AU"));
         private static void main(String[] args) throws IOException
         {//declare the variables and initialize
         double preTotal = 0.00;
         String inString;
         double maximum, lowest;
         double sum = 0.00;
         BufferedReader stdin = new BufferedReader (new
         InputStreamReader(System.in));
         prodlist = new CatalogueItem[];//sets the length (THIS IS WHERE THE PROBLEM OCCURS!!!!)
    System.out.println("Enter 5 sets of data");
         //loop through the array and read the data in
         for(int i = 0;i <prodlist.length;i++)
              inString = stdin.readLine();
              //create a String Tokenizer to read the data separately
              StringTokenizer tok = new StringTokenizer(inString, ":");
    prodlist[i] = new CatalogueItem(tok.nextToken(), tok.nextToken(),
    Double.parseDouble(tok.nextToken()));
    }//end of loop
    //create a header and print the data back to the screen
    System.out.println();
    System.out.println("LISTING OF ALL GOODS");
    System.out.println();
    System.out.println("Cat\tDescription\tExTax\tTax\tIncTax");
    System.out.println("___\t___________\t_____\t___\t______");
    System.out.println();
    for(int j = 0;j <prodlist.length;j++){
    System.out.println(prodlist[j].getCatno()+"\t"+prodlist[j].getDesc()+
    "\t"+prodlist[j].getPrice()+"\t"+prodlist[j].getTax()
    +"\t"+prodlist[j].getIncTax());
    I have errors every where the prodlist is used, I know I am not initializing it correctly but dont know what the alternatives are.

    daniel here is the entire code if you do get a chance can you pls have a look at it for me thanks.
    import java .io.*;
    import java.util.StringTokenizer;
    import java.text.NumberFormat;
    import java.util.Locale;
    //set up a class to call on the constructors from the catalogueitem class
    public class Myassg4
         private static final int MAX = 2; //sets the length to 2
         private static CatalogueItem[] prodlist; //sets array for product list
         NumberFormat cash = NumberFormat.getCurrencyInstance(new Locale("en","AU"));
         private static void main(String[] args) throws IOException
         {//declare the variables and initialize
         double preTotal = 0.00;
         String inString;
         double maximum, lowest;
         double sum = 0.00;
         BufferedReader stdin = new BufferedReader (new
         InputStreamReader(System.in));
         prodlist = new CatalogueItem[5];//sets the length
         System.out.println("Enter 5 sets of data");
         //loop through the array and read the data in
         for(int i = 0;i <prodlist.length;i++)
              inString = stdin.readLine();
              //create a String Tokenizer to read the data separately
              StringTokenizer tok = new StringTokenizer(inString, ":");
    prodlist[i] = new CatalogueItem(tok.nextToken(), tok.nextToken(),
    Double.parseDouble(tok.nextToken()));
    }//end of loop
    //create a header and print the data back to the screen
    System.out.println();
    System.out.println("LISTING OF ALL GOODS");
    System.out.println();
    System.out.println("Cat\tDescription\tExTax\tTax\tIncTax");
    System.out.println("___\t___________\t_____\t___\t______");
    System.out.println();
    for(int j = 0;j <prodlist.length;j++){
    System.out.println(prodlist[j].getCatno()+"\t"+prodlist[j].getDesc()+
    "\t"+prodlist[j].getPrice()+"\t"+prodlist[j].getTax()
    +"\t"+prodlist[j].getIncTax());
    //use this data and call the cheapest method to print
    //the cheapest goods in the catalogue
    System.out.println();
    System.out.println("CHEAPEST GOODS IN THE CATALOGUE");
    System.out.println();
    lowest = cheapest(prodlist, MAX);
    System.out.println("Cat\tDescription\tExTax\tTax\tIncTax");
    System.out.println("___\t___________\t_____\t___\t______");
    System.out.println();
    for(int k = 0;k <prodlist.length;k++){
    if(prodlist[k].getTaxInc == lowest)
    System.out.println(prodlist[k].Catno()+"\t"+prodlist[k].getDesc()+
    "\t"+prodlist[k].getPrice()+"\t"+prodlist[k].getTax()
    +"\t"+prodlist[k].getIncTax());
    //use the listing of all goods and call the most expensive method
    //to calculate and display back on screen
    System.out.println();//create two lines of space in between
    System.out.println();
    System.out.println("MOST EXPENSIVE GOODS IN THE CATALOGUE");
    System.out.println();
    maximun = expensive(prodlist, MAX);
    System.out.println("Cat\tDescription\tExTax\tTax\tIncTax");
    System.out.println("___\t___________\t_____\t___\t______");
    System.out.println();
    for(int l = 0;l < prodlist.length;l++){
    if(prodlist[l].getTaxInc == maximum)
    System.out.println(prodlist[l].Catno()+"\t"+prodlist[l].getDesc()+
    "\t"+prodlist[l].getPrice()+"\t"+prodlist[l].getTax()
    +"\t"+prodlist[l].getIncTax());
    //print the pretax worth of goods by calling the method and display
    System.out.println();//create a two lines of space in between
    System.out.println();
    System.out.println("TOTAL OF PRE-TAX WORTH OF CATALOGUE ITEMS: "+preTaxWorth
    (prodlist));
    //print the avg tax payable per item
    System.out.println();
    System.out.println("AVERAGE AMOUNT OF TAX PAYABLE PER ITEM:"+avgTax
    (prodlist));
    //declare the other methods within the scope of the main class
    public static double cheapest(CatalogueItem[] prodlist, int size)
         double lowest = prodlist[0].getIncTac();
         for(int i = 0; i < size;i++)
              if(prodlist.getIncTax() < lowest)
              lowest = prodlist[i].getIncTax();
         return lowest;
    public static double expensive(CatalogueItem[] prodlist, int size)
         double maximum = prodlist[0].getTaxInc();
         for(int i = 0; i < size; i++)
              if(prodlist[i].getIncTax() > maximum)
              maximum = prodlist[i].getIncTax();
         return maximum;
    public static double preTaxWorth(CatalogueItem[] prodlist)
    {//add all the getPrice's in together
    double preTax = 0; //prodlist[0].getPrice();
    for(int i =0; i <prodlist.length; i++)
         preTax += prodlist[i].getPrice();
    return preTax;
    public static double avgTax(CatalogueItem[] prodlist)
    {//run through the array and add all the getTax amounts up.
         double sum = 0;
         for(int i = 0; i < prodlist.length; i++)
              sum = sum + prodlist[i].getTax();
         //to get the avg we divide the sum by the MAX number of entries
         double Total = sum / MAX;
         return Total;
    }//end of main class
    //CatalogueItem class      
    //catalogue item class
    //ensure that the accesors and mutators
    //are visible and cannot be overridden
    class CatalogueItem
    //declare the data types
    private String catno;
    private String desc;
    private double price;     
    //declare the taxation rate constant
    //but make it visible
    public CatalogueItem(){
         catno = " ";
         desc = " ";
         double price;
    //declare the full constructor
    CatalogueItem (String inCatno, String inDesc, double Price)
         inCatno = catno;
         inDesc = desc;
         Price = price;
    //name accessor---not overidable
    public final String getCatno()
         return catno;
    //name product description accessor--not overidable
    public final String getDesc()
         return desc;
    //name the extax method
    public double getPrice()
         return price;
    //tax utility method
    public double Tax()
    double Tax;     
         Tax = 00.15 * getPrice();
         return Tax;
    //Including Tax method
    public double IncTax()
         double IncTax;
         IncTax = Tax() + getPrice();
         return IncTax;

  • Some quick help needed with certificates and split brain dns.

    I run exch 2010 and have one cas server(srv03).  I have split brain dns configured and working in my system.  I got a new certificate this year because of the new regulations that won't allow .internal names in the san portion of an ssl cert.
     I have followed several tids on the internet and still when I tried to implement it today the outlook clients started getting a popup that says [the name on the certificate is invalid or does not match the name of the site]  At the top of this popup
    is srv03.abccorp.internal which is what it was before.
    The certificate is for mail.abccorp.com and also includes autodiscover.abccorp.com and srv03.abccorp.com.  
    When I run [Get-clientAccessServer | fl Name,AutoDiscoverServiceInternalUri] the name and the Url is correct and has the .com value.
    When I run the test email autoconfiguration from my Outlook icon, and look at the log, Autodiscover URL found through SCP, is correct and it says Succeeded at the end.  In the results tab however the Server, Availability Service, OOF URL are still showing
    the .internal instead of .com.  The Internal OWA, External OWA and the OAB are correctly displaying the .com.  What commands do I need to run to change these as they seem to be the problem.
    I wasted a lot of time chasing the autodiscover before I found out about this test in outlook and realized the autodiscover url was correct. :-)
    I have two days left on my old cert that has both .com and .internal SANs so I rolled that back into service so the users stop getting messages.  Any help would be appreciated.

    Hi OTS,
    You can run the following command to Change the InternalUrl attribute of the EWS:
    Set-WebServicesVirtualDirectory -Identity "CAS_Server_Name\EWS (Default Web Site)" -InternalUrl https://mail.abccorp.com/ews/exchange.asmx
    Best regards,
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]
    Niko Cheng
    TechNet Community Support

  • Some design help needed

    Hi all. First up, thanks for reading. The problem:
    Im currently doing a project to reflect the the difficulties involved in a large communications network (IE a mobile phone one)
    For the UI, I have a canvas class to reflect the world that the agents (users) and Base Stations (Nodes) are in. The agents and Nodes both have seperate classes Essentially, each base station needs to pick up any agents with in a certain distance (radar)
    Just wondering what would the easiest way for the nodes to pick up the agents on the canvas?
    Here is a screen shot (you'll have to expand it to get the best resoulution
    http://www.cs.ucc.ie/~ood1/project.bmp
    if People need to see the code, just ask, and i'll put it up.
    Thanks in advance

    so basically your saying that have each tower
    get the distance to each agent and then ifs
    its in the radius of that tower, pick it up?
    would this be considered cheating? Consider the real
    world (which I have to accuratly reflect....:( ) If
    you have a mobile 10 miles away from a Tower who has
    a radius of 5 miles, it wont pick you up, its not
    even aware of you.
    m thinking that I'll have to use some setBounds on
    the towers, and iterate through each xy position in
    the bounds and if another component is found, it is
    in range....
    ah hell, im just gonna cheat..Thanks guys
    Message was edited by: User
    ChopsCheating? this sin't cheating at all. it's a program, not the real world. It would be "cheating" if you didn't do this.

Maybe you are looking for

  • How do I move my  itunes music library to a new computer?

    I bought a new PC--Dell inspiron 530, running Windows Vista. I need to transfer my itunes library (itunes 7) from my old computer which runs Windows XP. I have a CD/DVD burning capability on the old computer. I understand that there is a way to trans

  • My FIOS TV only uses the Coax cable not the HDMI cable

    I can only get my STB to use the coax cable to my TV, I want it to use the HDMI cable for a better HD picture, but I do not see a way to get the STB to use the HDMI cable as the primary output. How do I tell my STB to use the HDMI cable instead of th

  • Download J2SE v 1.4.2_02

    When is 1.4.2_02 out ? Peter

  • How do I do it in logic?

    I want to create a progressive house synth bass like they show in this thread: http://www.youtube.com/watch?v=ggsHn-hwph0 The problem is that they show how to do it in reason 4.0 and I wanna know how I do it in Logic. Best regards // Freddy

  • Plsql query please help out

    Hi , I have table with columns item,product,class1,class2,item_path,category How can I query the table to find out same item_path with differnt categories.I want to update those rows. Thanks.