New to computers New to programing New to java

I downloaded jdk1.3.1 and it installed itself into C:\jdk1.3.1, I followed the tutorial on this site `your first cup of java` but the first example would'nt compile. The tutorial suggested typing in the path manually to javac which I did and got the following -
error: cannot read: HelloWorldApp.java
1 error
HelloWorld.java being the example given in the tutorial.
If any kind person could help

You need to be in the same directory as your .java file, and make sure the the filename is correct. The complaint you are getting is that the Java Compiler (javac) cannot find your class file.
Here are a couple of tips that might help get you going:
1) Put the JDK bin directory in your path. If you are in Windows 95/98/ME, you have to do this by editing the autoexec.bat file. In Windows NT/2000, right-click on my computer, goto properties, then the Advanced tab. On there is a button called Environment Variables. Edit the path (preferably in the System variables set) and restart any open DOS windows.
2) Add "." to your CLASSPATH variable. If you do not have a CLASSPATH, see #1) and add one that looks like CLASSPATH=.
3) Get a good editor, and stay away from IDEs! I usually tell my students to download Scite...it's free, and it color codes java, C++, HTML, and many others. IDEs (Integrated Development Environments) are very nice, but they also teach really bad habbits...best to stay off of them for the time being.
Well, good luck, and hope this helps

Similar Messages

  • New TO JAVA Programming

    Dear Forummembers,
    I am student doing postgraduate studies in IT.i have some queries related to one of my programming staff.i am very much new into Java programming and i am finding it a bit difficult to handle this program.The synopsis of the program is given below -
    You are required to design and code an object-oriented java program to process bookings for a theatre perfomance.
    Your program will read from a data file containing specifications of the performance,including the names of the theatre, the play and its author and the layout of the theatre consisting of the number of seats in each row.
    It will then run a menu driven operation to accept theatre bookings or display the current
    status of seating in the theatre.
    The name of the file containing the details of the performance and the theatre should be
    provided at the command line, eg by running the program with the command:
    java Booking Theatre.txt
    where Theare.txt represents an example of the data file.
    A possible data file is:
    Opera
    U and Me
    Jennifer Aniston
    5 10 10 11 12 13 14
    The data provided is as follows
    Line 1
    Name of the Theatre
    Line 2
    Name of the play being performed
    Line 3
    Name of the author of the play being performed
    Line 4
    A list of the lengths (number of seats) of each row in the theatre, from front to
    back.
    The program must start by reading this file, storing all the appropriate parameters and
    establishing an object to accept bookings for this performance with all details for the theatre
    and performance.
    The program should then start a loop in which a menu is presented to the user, eg:
    Select from the following:
    B - Book seats
    T - Display Theatre bookings
    Q - Quit from the program
    Enter your choice:
    And keep performing selected operations until the user�s selects the quit option, when the
    program should terminate.
    T - Display Theatre bookings
    The Display Theatre Bookings option should display a plan of the theatre. Every available
    seat should be displayed containing its identification, while reserved seats should contain an
    Rows in each theatre are indicated by letters starting from �A� at the front. Seats are
    numbered from left to right starting from 1. A typical seat in the theatre might be designated
    D12, representing seat 12 in row D.
    B - Book seats
    The booking of seats is to offer a number of different options.
    First the customer must be asked how many adjacent seats are
    required. Then start a loop offering a further menu of choices:
    Enter one of the following:
    The first seat of a selected series, eg D12
    A preferred row letter, eg F
    A ? to have the first available sequence selected for you
    A # to see a display of all available seats
    A 0 to cancel your attempt to book seats
    Enter your selection:
    1. If the user enters a seat indentifier such B6, The program should attempt to
    reserve the required seats starting from that seat. For example if 4 seats are
    required from B6, seats B6, B7, B8 and B9 should be reserved for the customer,
    with a message confirming the reservation and specifying the seats reserved..
    Before this booking can take place, some testing is required. Firstly, the row
    letter must be a valid row. Then the seat number must be within the seats in the
    row and such that the 4 seats would not go beyond the end of the row. The
    program must then check that none of the required seats is already reserved.
    If the seats are invalid or already reserved, no reservation should be made and the
    booking menu should be repeated to give the customer a further chance to book
    seats.
    If the reservation is successful, return to the main menu.
    2. The user can also simply enter a row letter, eg B.IN this case, the program should
    first check that the letter is a valid row and then offer the user in turn each
    adjacent block of the required size in the specified row and for each ask whether
    the customer wants to take them. Using the partly booked theatre layout above, if
    the customer wanted 2 seats from row B, the customer should be offered first:
    Seats B5 to B6
    then if the customer does not want them:
    Seats B10 to B11
    and finally
    Seats B11 to B12
    If the customer selects a block of seats, then return to the main menu. If none are
    selected, or there is no block of the required size available in the row, then report
    that no further blocks of the required size are available in the row and repeat the
    booking menu.
    3. If the user enters a ? the program should offer the customer every block of seats
    of the required size in the whole theatre. This process should start from the first
    row and proceed back a row at a time. For example, again using the partially
    booked theatre shown above, if the user requested 9 seats, the program should
    offer in turn:
    Seats A1 to A9
    Seats C1 to C9
    Seats C2 to C10
    Seats E3 to E11
    Seats E4 to E12
    If the customer selects a block of seats, then return to the main menu. If none are
    selected, or there is no block of the required size available in the whole theatre,
    then report that no further blocks of the required size are available and repeat the
    booking menu.
    4. If the user enters a # the program should display the current status of the seating
    in the theatre, exactly the same as for the T option from the main menu and then
    repeat the booking menu.
    5. If the user enters a 0 (zero), the program should exit from the booking menu back
    to the main menu. If for example the user wanted 9 seats and no block of 9 was
    left in the theatre, he would need to make two separate smaller bookings.
    The program should perform limited data validation in the booking process. If a single
    character other than 0, ? and # is entered, it should be treated as a row letter and then tested
    for falling within the range of valid rows, eg A to H in the example above. Any invalid row
    letters should be rejected.
    If more than one character is entered, the first character should be tested as a valid row letter,
    and the numeric part should be tested for falling within the given row. You are NOT
    required to test for valid numeric input as this would require the use of Exception handling.
    You are provided with a class file:
    Pad.java
    containing methods that can be used for neat alignment of the seat identifiers in the theatre
    plan.
    File Processing
    The file to be read must be opened within the program and if the named file does not exist, a
    FileNotFoundException will be generated. It is desirable that this Exception be caught and
    a corrected file name should be asked for.
    This is not required for this assignment, as Exception handling has not been covered in this
    Unit. It will be acceptable if the method simply throws IOException in its heading.
    The only checking that is required is to make sure that the user does supply a file on the
    command line, containing details of the performance. This can be tested for by checking the
    length of the parameter array args. The array length should be 1. If not, display an error
    message telling the user the correct way to run the program and then terminate the program
    System.exit(0);
    The file should be closed after reading is completed.
    Program Requirements
    You are expected to create at least three classes in developing a solution to this problem.
    There should be an outer driving class, a class to represent the theatre performance and its
    bookings and a class to represent a single row within the theatre.
    You will also need to use arrays at two levels. You will need an array of Rows in the Theatre
    class.
    Each Row object will need an array of seats to keep track of which seats have been reserved.
    Your outer driving class should be called BookingOffice and should be submitted in a file named BookingOffice.java
    Your second, third and any additional classes, should be submitted in separate files, each
    class in a .java file named with the same name as the class
    I am also very sorry to give such a long description.but i mainly want to know how to approach for this program.
    also how to designate each row about it's column while it is being read from the text file, how to store it, how to denote first row as row A(second row as row B and so on) and WHICH CLASS WILL PERFORM WHICH OPERATIONS.
    pls do give a rough guideline about designing each class and it's reponsibilty.
    thanking u and looking forward for your help,
    sincerely
    RK

    yes i do know that........but can u ppl pls mention
    atleast what classes shud i consider and what will be
    the functions of each class?No, sorry. Maybe somebody else will, but in general, this is not a good question for this forum. It's too broad, and the question you're asking is an overall problem solving approach that you should be familiar with at this point.
    These forums are best suited to more specific questions. "How do I approach this homework?" is not something that most people are willing or able to answer in a forum like this.

  • New to JAVA, but old school to programming

    Objects & Classes & Methods, Oh my!
    I'm pretty new to java, but I've been programming in several languages over the years. I thought it was about time to update my skill set, especially with the job market as it is today. I wanted to go JAVA because it's not specific to any environment.
    I picked up a begining JAVA book and was a little confused. When I was learning programming a program was called a program. a peice of code in a program called by a statement was called a subroutine (it was performed then control returned to the calling line and continued).
    Now I'm trying to make sense of everything I have read so far and trying to relate it back to my old school of thinking. I was hoping it would make it easier to retain and I could expand it as I learn and possibly realize that it IS different. I know it's a new way of thinking, but stay with me for minute.
    What I used to call a program is now a CLASS in JAVA (this can be a collection of code or other objects). A sub-routine in a CLASS is a Method. I know that the language part will come as I use it since I understand if's then's and whatever you use to gosub or goto, but I want to make sure I have down the lingo before I go to deep.

    I have no idea how you can compare Java to Cobol.
    DataFlex? How about that! In about '84 I switched to
    DataFlex from dBaseII. In '91 DataFlex changed from
    procedural to OOP. It took most of us at least a year
    to adjust, and then some to write concrete code. It
    was tough. They had bugs and we were limited with DOS.
    BUT, it was a great OOP training experience. Anyhow,
    needless to day Java is miles ahead on all fronts.Small world. I was stuck in the old DataFlex Ver 2.3 at that time. The company I worked for had the newer OOP package. I did get to work with it some, but not enough to become totally familiar with it. We started to move out of DataFlex towards PowerBuilder towards the end of 1995. I did get some OOP from that experience, but again only enough to learn about global variables, instance variables, and a few other items. I hoping that I will be able to get the solid OOP background that I need from JAVA since I hear through the grapevine that it may be a new tool that we will be looking at to enhance our programming. I was looking at PERL but even the PERL programmers we have agree that JAVA is more scalable.

  • New to Java and need help with this program..please!

    I'd really appreciate any helpful comments about this program assignment that I have to turn in a week from Friday. I'm taking a class one night a week and completely new to Java. I'd ask my professor for help, but we can't call him during the week and he never answers e-mails. He didn't tell us how to call from other classes yet, and I just can't get the darn thing to do what I want it to do!
    The assignment requirements are:
    1. Change a card game application that draws two cards
    and the higher card wins, to a Blackjack application
    2. Include a new class called Hand
    3. The Hand class should record the number of draws
    4. The application should prompt for a number of draws
    5. The game is played against the Dealer
    6. The dealer always draws a card if the dealer's hand total is <= 17
    7. Prompt the player after each hand if he wants to quit
    8. Display the total games won by the dealer and total and the total games wond by the player after each hand
    9. Display all of the dealer's and player's cards at the
    end of each hand
    10. Player has the option of drawing an additional card after the first two cards
    11. The Ace can have a value of 11 or 1
    (Even though it's not called for in the requirements, I would like to be able to let the Ace have a value of 1 or an 11)
    The following is my code with some comments about a few things that are driving me nuts:
    import java.util.*;
    import javax.swing.*;
    import java.text.*;
    public class CardDeck
    public CardDeck()
    deck = new Card[52];
    fill();
    shuffle();
    public void fill()
    int i;
    int j;
    for (i = 1; i <= 13; i++)
    for (j = 1; j <= 4; j++)
    deck[4 * (i - 1) + j - 1] = new Card(i, j);
    cards = 52;
    public void shuffle()
    int next;
    for (next = 0; next < cards - 1; next++)
    int rand = (int)(Math.random()*(next+1));
    Card temp = deck[next];
    deck[next] = deck[rand];
    deck[rand] = temp;
    public final Card draw()
    if (cards == 0)
    return null;
    cards--;
    return deck[cards];
    public int changeValue()
    int val = 0;
    boolean ace = false;
    int cds;
    for (int i = 0; i < cards; i++)
    if (cardValue > 10)
    cardValue = 10;
    if (cardValue ==1)     {
    ace = true;
    val = val + cardValue;
    if ( ace = true && val + 10 <= 21 )
    val = val + 10;
    return val;
    public static void main(String[] args)
    CardDeck d = new CardDeck();
    int x = 3;
    int i;
    int wins = 1;
    int playerTotal = 1;
    do {
    Card dealer = (d.draw());
    /**I've tried everything I can think of to call the ChangeValue() method after I draw the card, but nothing is working for me.**/
    System.out.println("Dealer draws: " + dealer);
    do {
    dealer = (d.draw());
    System.out.println(" " + dealer);
    }while (dealer.rank() <= 17);
    Card mine = d.draw();
    System.out.println("\t\t\t\t Player draws: "
    + mine);
    mine = d.draw();
    System.out.println("\t\t\t\t\t\t" + mine);
    do{
    String input = JOptionPane.showInputDialog
    ("Would you like a card? ");
    if(input.equalsIgnoreCase("yes"))
         mine = d.draw();
    System.out.println("\t\t\t\t\t\t" + mine);
         playerTotal++;
         else if(input.equalsIgnoreCase("no"))
    System.out.println("\t\t\t\t Player stands");
         else
    System.out.println("\t\tInvalid input.
    Please try again.");
    I don't know how to go about making and calling a method or class that will combine the total cards delt to the player and the total cards delt to the dealer. The rank() method only seems to give me the last cards drawn to compare with when I try to do the tests.**/
    if ((dealer.rank() > mine.rank())
    && (dealer.rank() <= 21)
    || (mine.rank() > 21)
    && (dealer.rank() < 22)
    || ((dealer.rank() == 21)
    && (mine.rank() == 21))
    || ((mine.rank() > 21)
    && (dealer.rank() <= 21)))
    System.out.println("Dealer wins");
    wins++;
         else
    System.out.println("I win!");
    break;
    } while (playerTotal <= 1);
    String stop = JOptionPane.showInputDialog
    ("Would you like to play again? ");
    if (stop.equalsIgnoreCase("no"))
    break;
    if (rounds == 5)
    System.out.println("Player wins " +
    (CardDeck.rounds - wins) + "rounds");
    } while (rounds <= 5);
    private Card[] deck;
    private int cards;
    public static int rounds = 1;
    public int cardValue;
    /**When I try to compile this nested class, I get an error message saying I need a brace here and at the end of the program. I don't know if any of this code would work because I've tried adding braces and still can't compile it.**/
    class Hand()
    static int r = 1;
    public Hand() { CardDeck.rounds = r; }
    public int getRounds() { return r++; }
    final class Card
    public static final int ACE = 1;
    public static final int JACK = 11;
    public static final int QUEEN = 12;
    public static final int KING = 13;
    public static final int CLUBS = 1;
    public static final int DIAMONDS = 2;
    public static final int HEARTS = 3;
    public static final int SPADES = 4;
    public Card(int v, int s)
    value = v;
    suit = s;
    public int getValue() { return value; }
    public int getSuit() { return suit;  }
    public int rank()
    if (value == 1)
    return 4 * 13 + suit;
    else
    return 4 * (value - 1) + suit;
    /**This works, but I'm confused. How is this method called? Does it call itself?**/
    public String toString()
    String v;
    String s;
    if (value == ACE)
    v = "Ace";
    else if (value == JACK)
    v = "Jack";
    else if (value == QUEEN)
    v = "Queen";
    else if (value == KING)
    v = "King";
    else
    v = String.valueOf(value);
    if (suit == DIAMONDS)
    s = "Diamonds";
    else if (suit == HEARTS)
    s = "Hearts";
    else if (suit == SPADES)
    s = "Spades";
    else
    s = "Clubs";
    return v + " of " + s;
    private int value; //Value is an integer, so how can a
    private int suit; //string be assigned to an integer?
    }

    Thank you so much for offering to help me with this Jamie! When I tried to call change value using:
    Card dealer = (d.changeValue());
    I get an error message saying:
    Incompatible types found: int
    required: Card
    I had my weekly class last night and the professor cleared up a few things for me, but I've not had time to make all of the necessary changes. I did find out how toString worked, so that's one question out of the way, and he gave us a lot of information for adding another class to generate random numbers.
    Again, thank you so much. I really want to learn this but I'm feeling so stupid right now. Any help you can give me about the above error message would be appreciated.

  • New to java - glitch in my program/game? should be a simple fix :)

    hey everyone, I'm a student who's new to java programming :) It's is also the first programming language that I'm learning. I know the basics, but nothing very complicated.
    I'm making a pong-like game, in an applet.
    As I was making the paddle and using a mouselistener to make it move vertically, I came across this problem, the paddle will move vertically with the mouse's position, but one end of my paddle will grow abnormally (I want it to stay the same size as it moves up and down)
    Here's my code: (I'm not using most of the mouselistener and keylistener classes yet, so you can ignore them. I'm guessing the problem is probably in one of the last classes, at the bottom)
    ypaddle is the variable used for getting the co-ordinates of the mouse and transferring them to the paddle itself
    // The "Ping" class.
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    *Ping
    public class Ping extends Applet
        implements KeyListener, MouseListener, MouseMotionListener
        int width, height, x, ypaddle;
        Graphics g;
        char move;
         *Initializes variables
        public void init ()
            resize (700, 500);
            setBackground (Color.white);
            addKeyListener (this);
            addMouseListener (this);
            addMouseMotionListener(this);
        public void keyPressed (KeyEvent e)
        public void keyReleased (KeyEvent e)
        public void keyTyped (KeyEvent e)
        public void mouseEntered (MouseEvent e)
        public void mouseExited (MouseEvent e)
        public void mousePressed (MouseEvent e)
        public void mouseReleased (MouseEvent e)
        public void mouseClicked (MouseEvent e)
        public void mouseMoved (MouseEvent e)
            ypaddle = e.getY ();
            repaint();
        public void mouseDragged (MouseEvent e)
        public void paint (Graphics g)
            paddle (g, ypaddle);
         * Creates the paddle for hitting the ball
         *@param    y   value used to move the paddle vertically
        public void paddle (Graphics g, int y)
            g.fillRect (10, 10+y, 15, 60+y);
    } // Ping classI'm totally stumped, I've tried for 2 hours to find the problem, and I have a feeling it's something very simple that I'm passing over...
    If you have any questions about the variables or other things, please ask!
    And one last little quick question, is there a way I can restrict the movement of the paddle between two Y values? (i.e not higher than y=10 or lower than y=100)
    Thanks in advance :)

    soundweave wrote:
    I'm not exactly sure how to find out, Eh?
    You wrote this code:
    g.fillRect (10, 10+y, 15, 60+y);Do you understand what fillRect does? If I call fillRect(10, 20, 30, 40) where will that rectangle be drawn? If you don't know how to answer that, I don't see how you could have written that line of code.
    but here's some pictures of what happens ( I put in 0 and 80 as the y values in each picture, and left the code window open so you can see )I don't need to see them.
    Y at 0: [http://i731.photobucket.com/albums/ww314/len56/Untitled.jpg?t=1263077701|http://i731.photobucket.com/albums/ww314/len56/Untitled.jpg?t=1263077701]
    Y at 80: [http://i731.photobucket.com/albums/ww314/len56/Untitled2.jpg?t=1263077625|http://i731.photobucket.com/albums/ww314/len56/Untitled2.jpg?t=1263077625]
    So, given that the first one comes from fillRect(10, 10, 15, 60), (you get where that comes from I hope) and the second comes from fillRect(10, 90, 15, 150) (that too), does that not suggest that something is wrong with the numbers you're passing to fillRect? And since you have read the docs for fillRect and know what it does and what each of its parameters represents (right?), does it not suggest exactly what is wrong with those numbers?

  • Why is New to Java so much faster than Java Programming?

    It feels like the New to Java server is at my neighbor's house, and Java Programming is on Neptune. What gives? It always takes like 10 seconds to load the Java Programming board.

    I've noticed that, too. I've attributed it to message volume, since there are so many more messages under that category.
    Maybe the database doesn't have an index, or perhaps they bring back LOTS of entries and cache them. Who knows?
    %

  • I just heard a news report that there is a problem with malware in mac computers that came through a recent java update. Is this true? If so, what should be done about it?

    I just heard a news report that there is a problem with malware in mac computers that came through a recent java update. Is this true? If so, what should be done about it?

    As usual those "news" reports mangled the facts and got most of the story completely wrong. This particular attack did not arise through a Java update, it was distributed through a fraudulent Flash download popup window, or malicious websites that Safari is designed to block.
    If you run Java on your Mac you may be vulnerable to this malware. If you do not run Java there is no risk. If you routinely keep your Mac up to date with Software Update the risk is greatly reduced.
    Shut off the mass market junk that masquerades as "news" and read this to learn some real facts:
      https://discussions.apple.com/docs/DOC-3271

  • Brand New to Java and Programming

    I'm brand new, ( RAW ) to software programming at this time. I'm starting from scratch, I work on a Help Desk for the government so I can perform some software functionality but nothing as far as programming.. I would like recommendations for someone starting out brand new.. Books to read (JAVA for Dummies?) any beginner courses? What steps would you take if you were starting out brand new as I am myself.. Thanks..
    PS, I plan on taking courses after I get the beginning stuff out of the way, just don't want to go in with no knowledge base..

    For a nice list of stock answers: The One to Torment Newbies with
    Sun's basic Java tutorial
    Sun's New To Java Center. Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
    http://javaalmanac.com . A couple dozen code examples that supplement The Java Developers Almanac.
    jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
    JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
    Bruce Eckel's Thinking in Java (Available online.)
    Joshua Bloch's Effective Java
    Bert Bates and Kathy Sierra's Head First Java.
    James Gosling's The Java Programming Language. Gosling is
    the creator of Java. It doesn't get much more authoritative than this.

  • Help needed, new to java programming

    hi,
    I have craeted a Frame with some check boxes and button called "button1".
    Can anyone tell me how can i count the number of CHECKED check boxes so that when i press the button1 in my code it should display the result as number of checked check boxes divided by total number of check boxes. It should display the result in a textfield here RESULT textfield in my code
    Thanks in advance ...i am sending the code i have written so far....
    public class Frame extends java.awt.Frame {
        /** Creates new form Frame */
        public Frame() {
            initComponents();
            setSize(600, 600);
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        private void initComponents() {
            buttonGroup1 = new javax.swing.ButtonGroup();
            checkbox1 = new java.awt.Checkbox();
            checkbox2 = new java.awt.Checkbox();
            checkbox3 = new java.awt.Checkbox();
            button1 = new java.awt.Button();
            textField1 = new java.awt.TextField();
            setLayout(null);
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    exitForm(evt);
            checkbox1.setLabel("checkbox1");
            add(checkbox1);
            checkbox1.setBounds(160, 50, 84, 20);
            checkbox2.setLabel("checkbox2");
            add(checkbox2);
            checkbox2.setBounds(160, 70, 84, 20);
            checkbox3.setLabel("checkbox3");
            add(checkbox3);
            checkbox3.setBounds(160, 90, 84, 20);
            button1.setLabel("button1");
            button1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    button1ActionPerformed(evt);
            add(button1);
            button1.setBounds(150, 180, 57, 24);
            textField1.setText("Result");
            textField1.setName("Result");
            add(textField1);
            textField1.setBounds(260, 180, 44, 20);
            pack();
        private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
            // Add your handling code here:
        /** Exit the Application */
        private void exitForm(java.awt.event.WindowEvent evt) {
            System.exit(0);
         * @param args the command line arguments
        public static void main(String args[]) {
            new Frame().show();
        // Variables declaration - do not modify
        private java.awt.Button button1;
        private javax.swing.ButtonGroup buttonGroup1;
        private java.awt.Checkbox checkbox1;
        private java.awt.Checkbox checkbox2;
        private java.awt.Checkbox checkbox3;
        private java.awt.TextField textField1;
        // End of variables declaration
    }

    Two problems in the code you repost-ed:
    1. It lacks import statements.
    2. There is an extraneous } at the end of the button1ActionPerformed method.
    Correct them and it'll work fine. Posting the full source code:
    import java.awt.Component;
    import java.awt.Checkbox;
    public class Frame extends java.awt.Frame
         /** Creates new form Frame */
         public Frame()
              initComponents();
          * This method is called from within the constructor to initialize the form.
          * WARNING: Do NOT modify this code. The content of this method is always
          * regenerated by the Form Editor.
         private void initComponents()
              checkbox1 = new java.awt.Checkbox();
              checkbox2 = new java.awt.Checkbox();
              checkbox3 = new java.awt.Checkbox();
              button1 = new java.awt.Button();
              textField1 = new java.awt.TextField();
              setLayout( null );
              addWindowListener( new java.awt.event.WindowAdapter()
                   public void windowClosing( java.awt.event.WindowEvent evt )
                        exitForm( evt );
              checkbox1.setLabel( "checkbox1" );
              add( checkbox1 );
              checkbox1.setBounds( 120, 40, 84, 20 );
              checkbox2.setLabel( "checkbox2" );
              add( checkbox2 );
              checkbox2.setBounds( 120, 60, 84, 20 );
              checkbox3.setLabel( "checkbox3" );
              add( checkbox3 );
              checkbox3.setBounds( 120, 80, 84, 20 );
              button1.setLabel( "button1" );
              button1.addActionListener( new java.awt.event.ActionListener()
                   public void actionPerformed( java.awt.event.ActionEvent evt )
                        button1ActionPerformed( evt );
              add( button1 );
              button1.setBounds( 50, 170, 57, 24 );
              textField1.setText( "textField1" );
              add( textField1 );
              textField1.setBounds( 240, 170, 60, 20 );
              pack();
         private void button1ActionPerformed( java.awt.event.ActionEvent evt )
              // Add your handling code here:
              Component[] components = getComponents();
              int numOfCheckBoxes = 0;
              int numChecked = 0;
              for ( int i = 0; i < components.length; i++ )
                   if ( components[i] instanceof Checkbox )
                        numOfCheckBoxes++;
                        Checkbox checkBox = (Checkbox) components;
                        if ( checkBox.getState() )
                             numChecked++;
              double ratio = (double) numChecked / (double) numOfCheckBoxes;
              textField1.setText( Double.toString( ratio ) );
         /** Exit the Application */
         private void exitForm( java.awt.event.WindowEvent evt )
              System.exit( 0 );
         * @param args the command line arguments
         public static void main( String args[] )
              new Frame().show();
         // Variables declaration - do not modify
         private java.awt.Button button1;
         private java.awt.Checkbox checkbox1;
         private java.awt.Checkbox checkbox2;
         private java.awt.Checkbox checkbox3;
         private java.awt.TextField textField1;
         // End of variables declaration
    I can see from the code that the GUI was generated by a tool. Since you're new to Java programming, I'd recommend ditching the tool and writing everything by hand, otherwise you're not learning much. It's just like when you're learning proofs in Maths, where you start with first principles before making use of the proofs on their own.
    Also, it'll help tremendously if you could spend some time going through the Java Tutorial (http://java.sun.com/docs/books/tutorial/). It's free, and I find it very useful.
    Hth.

  • New to Java...Tough program to write I think...

    Alright, I have a problem. I have never coded in java before, but a teacher wants a program written that is too much for html/php/VB to handel, and a friend suggestion I use java.
    my problem is that I have never coded in Java before, but supposidly because its object oriented, the language should make the program easier to write.
    The program is a "Group Generator"
    Anyway, here is what the teacher wants:
    Step 1) Program Asks user how many students are in his class, and how many students he wants in each group
    Step 2) Program Asks user the names of all X students
    Step 3) Program makes a list of every combination of groups that can be made out of these X people (never repeating 2 people in a group)
    Step 4) Program outputs results
    Here is a quick example because I know its confusing
    10 kids in my class, groups of 2
    Group Set 1:
    1: AB
    2: CD
    3: EF
    4: GH
    5: IJ
    Group Set 2:
    1: AC
    2: BD
    3: GF
    4: IH
    5: EJ
    and the program would keep finding sets of unique grounds...but A will never be grouped with B again, or C again...so the ammount of group sets is actually quite low.
    Anway, this isnt for a grade or anything, its just something some teacher wants and I think would help teachers a bit in forming unique grounds of kids....
    Any input or ideas would be GREATLY appriciated :-)

    Alright, I have a problem. I have never coded in java
    before, but a teacher wants a program written that is
    too much for html/php/VB to handel, and a friend
    suggestion I use java.HTML is markup, so it won't be of much use. However, PHP, VB, and a host of other languages can handle this easily. Write it using the language with which you are comfortable.
    If you want to learn Java, however, here are some good resources...
    Your First Cup of Java - http://java.sun.com/docs/books/tutorial/getStarted/cupojava/index.html
    Essentials, Part 1, Lesson 1: Compiling & Running a Simple Program - http://java.sun.com/developer/onlineTraining/Programming/BasicJava1/compile.html
    The Java Tutorial - A practical guide for programmers - http://java.sun.com/docs/books/tutorial/
    New to Java Center - http://java.sun.com/learning/new2java/index.html
    How To Think Like A Computer Scientist - http://www.ibiblio.org/obp/thinkCSjav/
    Introduction to Computer Science using Java - http://chortle.ccsu.ctstateu.edu/CS151/cs151java.html
    The Java Developers Almanac 1.4 - http://javaalmanac.com/
    JavaRanch: a friendly place for Java greenhorns - http://www.javaranch.com/
    jGuru - http://www.jguru.com
    Object-Oriented Programming Concepts - http://java.sun.com/docs/books/tutorial/java/concepts/
    Object-oriented language basics - http://www.javaworld.com/javaworld/jw-04-2001/jw-0406-java101.html
    Don't Fear the OOP - http://sepwww.stanford.edu/sep/josman/oop/oop1.htm
    Books:
    Bert Bates and Kathy Sierra's Head First Java - http://www.amazon.com/exec/obidos/tg/detail/-/0596004656?v=glance
    Bruce Eckel's Thinking in Java (Free online) - http://mindview.net/Books/DownloadSites
    Joshua Bloch's Effective Java - http://www.amazon.co.uk/exec/obidos/Author=Bloch,%20Josh
    Java Design: Building Better Apps and Applets (2nd Edition) - http://www.amazon.com/exec/obidos/tg/detail/-/0139111816/qid=1101309882/sr=8-7/ref=sr_8_xs_ap_i7_xgl14/104-6417153-1511164?v=glance&s=books&n=507846

  • New to Java - why won't my program run ?

    Hi
    I am new to Java - this compiles but does not run - any suggestions please ?
    class ThinkofANumberApp extends basic{
         public static void main (String param[]) throws Exception
         input source = new input ();
         output sink = new output ();
         int result = source.readint();
         //list number questions for numbers
              sink.writeln("Think of a number");
              source.readln();
              sink.writeln("Multiply it by 5");
              source.readln();
              sink.writeln("Add 6");
              source.readln();
              sink.writeln("Multiply it by 4");
              source.readln();
              sink.writeln("Add 9");
              source.readln();
              sink.writeln("Multiply it by 5");
              source.readln();
              sink.writeln("Type the final result");
              sink.write("My \"guess\" is that your"
              + " original number was ");
              sink.writeln((result-165)/100);
    Thanks in advance.
    Nadjie

    What is "input" and "output" and have you included these classes in your classpath?

  • PLz Help New To Java

    Hey im brand new to java and i just downloaded and installed jdk-1_5_0_01-windows-i586-p now im tryin to set up the PATH permanently but i have no clue how to i went to the install notes and typed in C:\Program Files\Java\jdk1.5.0_<windows>\bin in the command.com but everytime i do it says access is denied. i have no clue how to set up the path permanently beside what i tried plz help!!!

    You didn't which OS you are running, but it's fairly similar for all windows.
    Start->settings->control panel->system->advanced->environment variables
    Go to System variables, click on path, click edit button and add a semicolon and the path at the end. DO NOT REPLACE EVERYTHING THAT'S THERE NOW.
    I don't have 1.5 installed on this computer, but I'm willing to bet the real path doesn't have '<windows>' in it. Use Windows Explorer to find out where java.exe actually exists on the hard disk and use that path

  • I'm new to Java, anyone want to lend a hand?

    Please copy my program in to Java and take a look. What I am trying to do is when the button is pressed to buy a Mr Big bar I want the quantity value to rise by one, only it doesn't. I have tried several things to no avail! I may be missing something really easy but if someone could help I would be very grateful.
    many thanks.
    Sorry for the length of it....
    package myprojects.avending;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class AVending
    public AVending()
    AVControl control = new AVControl();
    public static void main(String args[])
    System.out.println("Starting ACME Vending Machine, please stand by...");
    AVending startup = new AVending();
    class AVControl extends Frame
    public AVControl()
    setSize(700, 150);
    setBackground(Color.black);
    setTitle("ACME Vending Machine Control Room");
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    dispose();
    System.exit(0);
    setVisible(true);
    AVCustomer custobj = new AVCustomer(this);
    class AVCustomer extends Frame implements ActionListener
    private JButton ACC;
    public AVCustomer(AVControl avc)
    setSize(150, 350);
    setLayout(new BorderLayout());
    setBackground(Color.black);
    setTitle("Customer Location");
    ACC = new JButton("ACC");
    ACC.setForeground(Color.black);
    ACC.setBackground(Color.white);
    ACC.setEnabled(true);
    ACC.setVisible(true);
    ACC.setBounds(0, 0, 100, 30);
    add(BorderLayout.NORTH, ACC);
    ACC.addActionListener(this);
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    dispose();
    System.exit(0);
    setVisible(true);
    AVendingMachine vmachine = new AVendingMachine(this);
    public void actionPerformed(ActionEvent ae)
    ae.getSource();
    if(ae.getSource()==ACC)
    VMachine vm = new VMachine(this);
    public void paint(Graphics g)
    g.setColor(Color.white);
    g.drawString("Vending Machines", 10, 80);
    g.drawString("currently available - 1", 10, 95);
    class VMachine extends Frame implements ActionListener
    private JButton buybut1;
    public int quan;
    private JTextField tf2a;
    public VMachine(AVCustomer c)
    setSize(200, 400);
    setLayout(new BorderLayout());
    setBackground(Color.red);
    setTitle("Vending Machine");
    Panel panel1 = new Panel();
    panel1.setBackground(Color.black);
    panel1.setLayout(new FlowLayout());
    add(BorderLayout.NORTH, panel1);
    JTextField tf1 = new JTextField("Air Canada Center", 12);
    tf1.setHorizontalAlignment(JTextField.CENTER);
    tf1.setEditable(false);
    panel1.add(tf1);
    Panel panel2 = new Panel();
    panel2.setBackground(Color.red);
    panel2.setLayout(new GridLayout(4,3));
    add(panel2);
    quan = 0;
    Panel panel3 = new Panel(new FlowLayout());
    panel3.setBackground(Color.red);
    add(panel3);
    JTextField tf2 = new JTextField("Mr Big", 6);
    JTextField tf2a = new JTextField(""+quan);
    tf2.setHorizontalAlignment(JTextField.CENTER);
    tf2.setEditable(false);
    tf2a.setHorizontalAlignment(JTextField.CENTER);
    tf2a.setEditable(false);
    panel3.add(tf2);
    panel3.add(tf2a);
    buybut1 = new JButton("Buy");
    buybut1.setForeground(Color.black);
    buybut1.setEnabled(true);
    buybut1.setVisible(true);
    buybut1.setBounds(0, 0, 100, 30);
    panel3.add(buybut1);
    buybut1.addActionListener(this);
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    dispose();
    setVisible(true);
    public void actionPerformed(ActionEvent ae)
    if(ae.getSource()==buybut1)
    System.out.println("Button works ok");
    quan = quan + 1;
    tf2a.setText(""+quan);
    }

    first, the code you provided does not compile - there was no AVendingMachine class...I assumed you meant VMachine
    once that is solved you get a NullPointerException when you press the button, which was caused by the fact that you declared the text field inside the constructor, when you stop declaring it, and just initialize it everything works fine..
    also, you might want to change your JTextFields to JLabels -- they will look nicer

  • New to Java, using Vista, can't find javaws?

    i'm used to running java on windows 2000, and now i am using windows vista. i used to be able to type javaws in the run program and get java to pop up, but with the new os it tells pops up a info sheet? has anyone seen this? i downloaded the latest java and also the previous version i had running on my old computer with windows 2000, both had the same result
    please help

    Run away from vista~

  • New to java, having trouble with classes

    I am new to java and I am having problems importing classes in my first program, please help

    hi
    please tell, what`s your problem exatly?

  • Change A String Sentence -- Brand new to Java!

    Hello --
    I am brand new to Java, so please excuse my ignorance ...
    i'm working on a very simple project at school, so i dont need any high tech ways of doing this.. lol ... the program prompts the user to enter a sentence .... the program takes this sentence and outputs the first word of the sentence and moves it to the last word of the sentence .... for example:
    user enters: hello how are you today
    the program outputs it: how are you today hello
    this is a practice exercise, but im having trouble .... new student here!! help! lol
    thanks,
    cindy :)

    ok,
    assuming you have the reading the input part and stuff. the most straight forward and explainative way is :
    1. break the sentence into an array of words
    2. print the last word
    3. etc.
    use the java.util.StringTokenizer class. A sentence is a series of words delimited by <space>. String Tokenizer is used like java.util.Enumeration.
    In this case we are going to read the tokens/words in to an array, then you can print them in what ever order.
    like this
    import java.io.*;
    import java.util.*;
    public class wordswitch {
    public static void main(String[] args) {
    String sentence = new String();
    // get the sentence
    System.out.println("enter a sentence : ");
    try {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    sentence = reader.readLine();
    reader.close();
    } catch( Exception e ) {
    System.out.println("Exception : "+e.getMessage());
    // convert the Sentence in to an array of words
    StringTokenizer strTok = new StringTokenizer(sentence, " ");
    int numWords = strTok.countTokens();
    String [] words = new String[numWords];
    int i=0;
    while( strTok.hasMoreTokens() )
    words[i++] = new String(strTok.nextToken());
    // display the new sentence
    if( numWords < 2 ) // if there is 1 or 0 words just echo back the original sentence
    System.out.println(sentence);
    else {
    // print the words in the new order
    System.out.print( words[numWords-1]+" " ); // last word first
    for( i=1; i<numWords-1; i++ ) // the second word the the second from last word
    System.out.print( words[i]+" " );
    System.out.println(words[0]); // the first word last

Maybe you are looking for