Immature Java Programmer needs help...

I do not want to generate html code inside my java code, rather open a html page by referencing it in my java code to see it in the browser. For example, here is my code:
package mrpt;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Login extends HttpServlet
     public void doGet(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException
          response.setContentType ("text/html");
          PrintWriter out = response.getWriter ();
          response.sendRedirect ("http://localhost:8080/Login.htm");
The code compiles but when I open it in the browser (.\servlet\mrpt.Login) I get an error page "HTTP Status 500 -". I'm using the Tomcat Apache server. I have my html in the root directory and my .java and .class in the .\webapps\ROOT\WEB-INF\classes\mrpt. Can this be done? Is my code correct?

I do not want to generate html code inside my java
code, rather open a html page by referencing it in my
java code to see it in the browser. For example, here
is my code:
package mrpt;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Login extends HttpServlet
public void doGet(HttpServletRequest request,
HttpServletResponse response)
     throws ServletException, IOException
I don't think this is right. try leaving it out ---          response.setContentType ("text/html");
          PrintWriter out = response.getWriter (); response.sendRedirect
t ("http://localhost:8080/Login.htm");
The code compiles but when I open it in the browser
(.\servlet\mrpt.Login) I get an error page "HTTP
Status 500 -". I'm using the Tomcat Apache server. I
have my html in the root directory and my .java and
.class in the .\webapps\ROOT\WEB-INF\classes\mrpt. Can
this be done? Is my code correct?

Similar Messages

  • Newbie Java programmer needs help

    Everytime I go to run my program, I get the error
    "the class welcome.Welcome does not exist" and it's right, there is no such thing, nor will there ever be. There is a Welcome.class though, but it doesn't want to see it. Is there some setting I'm missing(i'm using Borland JBuilder 5 Personal) or is my code wrong. Here it is though, please help!
    import javax.swing.JOptionPane;
    public class Welcome
    public static void main( String args[] )
    JOptionPane.showMessageDialog(
    null, "Welcome to Java Programming" );
    System.exit( 0 );
    }

    Your code compiled and ran perfect on my machine.
    Your problem lays in either:
    1) your WYSIWYG (JBuilder or whatever)
    2) your class path
    I may be wrong. I have never used this program that you are talking about. but it seems to me that if you were able to get this program(IDE) running in the first place it should aready have some kind of JRE installed.
    You may wan't to just download the newest JDK if you don't already have it. Or try to locate the path for the command named "java" and try it like this:
    C:\whatever\path\it\is\java Welcome
    while in the same directory of the Welcome class.
    Hope this helps,
    Ian

  • Image size and mime type.. non-java guy needs help

    Image size, mime type.. non-java guy needs help
    Im not at all familiar with java so this is really weird for me to work out. I?ve been doing it all day (and half of yesterday).
    Im trying to write a custom clodFusion tag in java that gets the width, height, size and MIME types of a given file. I?ve been trying to get it to work on the command line first. I can get the width and height but cant get the size and the MIME type.
    Here is what I got
    /*import com.allaire.cfx.*;*/
    import java.awt.image.renderable.*;
    import javax.media.jai.*;
    import com.sun.media.jai.codec.*;
    import java.io.*;
    import java.util.*;
    public class ImageInfo {
    private RenderedOp image = null;
    private RenderedOp result = null;
    private int height = 0;
    private int width = 0;
    private String type = "";
    private String size = "";
    public void loadf(String file) throws IOException
    file = "80by80.jpg";
    FileSeekableStream fss = new FileSeekableStream(file);
    image = JAI.create("stream", fss);
    height = image.getHeight();
    width = image.getWidth();
    System.out.println(height + "\n");
    System.out.println(width);
    System.out.println(type);
    public static void main(String[] args) throws IOException {
    ImageInfo test = new ImageInfo();
    test.loadf(args[0]);
    can anyone please help me out to modify the above so I can also print the mime type and the file size to screen.
    thanks for any help

    any suggestions?

  • IMac: Install Java 7 need help!

    Hello, I've an iMac with the newest software version, I want to install java 7 on it for a game server, but when I download it from java.com and I install it and start the server, it still says: Computer on java 6, update to 7 to run server. I already tryed to install with Terminal and direct acess to System Library, it shows that java 7 is installed, but I have to delete java 6. When I delete all java versions, apple says I have to install java SE6, what isn't java 7 but java 6! Help please!!!

    The Oracle JRE is only a web plugin. If you need server-side Java, you'll have to use the Apple-supplied Java 6 runtime, or else the Oracle JDK (which is not a drop-in replacement for Apple's Java.) If your server application depends on Java 7, you'll most likely have to run it on another operating system.

  • Newbie to Java who needs help..

    Hello all.
    I am having some troubles making a random walker/Drunkard. What I have to do is make it that the user inputs the starting X, Y coordinates and the amount of steps he has to walk. After that, it is post to print back the new coordinates he walked to and the distance of his new coordinates is to the starting one. I am new to java so I am confused.. This is what I have so far..
    import java.util.*;
    public class Drunkard {
        private int x;
        private int y;
        private int numSteps;
        private int Distance;
        private int moveDrunk;
        public Drunkard() {
            this.x = x;
            this.y = y;
            this.numSteps = 0;
        public int getX() {
            return x;
        public int getY() {
            return y;
         public int getSteps() {
            return this.numSteps;
        private void move(int numSteps);
        private void moveDrunk(){
        moveDrunk = (int) (Math.random() * 4);
        public int getmoveDrunk() {
            return moveDrunk;
    public boolean getDistance{
    (int)(Math.sqrt((getX()*getX()) + (getY()*getY())));{
    return Distance
    import java.util.Scanner;
    public class DrunkardSimulator
        public static void main (String[] args)
            Scanner scan = new Scanner(System.in);
            System.out.print ("Enter the number of steps: ");
            numSteps = scan.nextInt();
            System.out.print ("Enter the starting x coordinate: ");
            x = scan.nextInt();
            System.out.print ("Enter the starting y coordinate: ");
            y = scan.nextInt();
            Drunkard drunk = new Drunkard();
            System.out.println("The drunk moved to X" +drunk.getX() + ", y " + drunk.getY() && "a distance of " + drunk.getDistance());
    }Any help would be nice.
    Edited by: orlfman on Apr 9, 2008 5:26 PM

    Sorry. I should have stated what I need help with..
    I need help with making him move randomly when the user types in the x,y starting coords, and the amount of steps he has to walk from what the user inputs. I also need help printing out the new x,y coords he walked to randomly and the distance his new coords are from where he first started at (the coords the user the typed in.)
    I have two files:
    Drunkard.java
    import java.awt.*;
    import java.util.*;
    public class Drunkard {
        private int x;
        private int y;
        private int numSteps;
        private int Distance;
        private int moveDrunk;
        public Drunkard(int x, int y) {
            this.x = x;
            this.y = y;
            this.numSteps = 0;
        public int getX() {
            return x;
        public int getY() {
            return y;
         public int getSteps() {
            return this.numSteps;
        public void moveDrunk(int numSteps){
             for (int i=0;i<numSteps;i++) {
            if(rand.nextInt(2)==1) { x+=1; } else { y+=1; } }
        public int getDistance(){
    (int)(Math.sqrt((getX()*getX()) + (getY()*getY())));{
    return Distance
      }And DrunkardSimulator.java
    import java.util.Scanner;
    public class DrunkardSimulator
        public static void main (String[] args)
    int x;
    int y;
    int numSteps;
            Scanner scan = new Scanner(System.in);
            System.out.print ("Enter the number of steps: ");
            numSteps = scan.nextInt();
            System.out.print ("Enter the starting x coordinate: ");
            x = scan.nextInt();
            System.out.print ("Enter the starting y coordinate: ");
            y = scan.nextInt();
            Drunkard drunk = new Drunkard(x,y);
            drunk.moveDrunk(5); //5 steps
            System.out.println("The drunk moved to X,Y" + drunk.getX() + drunk.getY() + drunk.getDistance());
    }Edited by: orlfman on Apr 10, 2008 12:29 AM
    Edited by: orlfman on Apr 10, 2008 12:31 AM

  • C++ programmer  needs help in Java.

    Greetings, I am new to Java after programming in C++ and am having a few troubles finding parallels to a few essential operations, such as:
    What are the Java equivalents to cout, cin and getch()?
    Or simply, how do you do output, get input from the user, and pause execution?
    Thank you all for any help you can offer.
    Dagkhi

    Look over this group of threads that a search of the Forum using "system.in" listed:
    http://search.java.sun.com/search/java/index.jsp?col=javaforums&qp=%2Bforum%3A54&qt=system.in&x=14&y=6

  • C++ programmer needs help w/Java :)

    Hey,
    I'm working on a project and I'm supposed to write it in java. So I've been looking around and haven't been able to figure out exactly how input/output works. My main concern is the input function. I know that in C++ we use cin << and fin << to read in data from the command line or a file. How can I translate this to java code? I'm approaching this program as I would with a c++ program so I probably won't understand if you use html source code in your reply...yes engineers can be dumb...I'm living proof. Or if you could explain how I/O works in java I would apprecitate that as well.
    Thanks,
    Mayo

    I was wrong above. here is the way below.
    I don't know what I was thinkin earlier,
    well you know what you said engineers.:-)
    If there is any questions about the below
    code please feel free to ask.
    import java.io.*;
    public class ReadKeys
         public static void main(String args[])
            BufferedReader bread;
              try {
            bread = new BufferedReader(new InputStreamReader(System.in));
            String str;
            while( (str = bread.readLine()) != null  ) {
              System.out.println(str);
           }catch(IOException io) { }
    }

  • Non-Programmer Needs Help!!! (desperately)

    Ok, I want to create games for a virtual world website. I also want the website to be a game itself. Right now, I am working on creating a card game for two players (with the option of playing the computer). They each have 2 decks to draw from and a place for 2 cards to be displayed (their "hand") before they place it on the game board. I don't want their opponent to see the cards in their "hand" until they are placed on the game board. When a player has two cards in his hand, I want them to have the capability of enlarging the image of the card to full size in a pop-up type window, so they can calculate their strategy. The game itself is similar to the popular battle card games, so regular playing card games don't help me. I want the image of the card to be displayed on the game board either right side up or upside down depending upon the button pushed by the player. I want each player to play 1 card from one pile (blue-50 cards total) and 4 cards from the other pile (red-200 cards total). They can only draw 1 blue card, and 1 red card on their first turn. After that, they can only draw 1 red card per turn, until they have drawn 4 red cards total. The total number of cards each player can have on the game board is 5 cards, then the round ends. Each deck has the same cards but shuffled in random order. The decks can't be stacked the same, for each player. Each card has a certain value. The card from the blue pile is the main card that the cards from the red pile will add to or subtract from. If the match between the opponents is tied, no score is given to either player, but the cards from both players to go to the corresponding "tie" piles (one red and one blue) that will be randomly distributed by the computer, once each player has exhausted their own decks first. The tie piles are used at the end of the game to play the final round or rounds of the game. After each round, the victor of that round gets the points on his opponents cards, plus 1000 points for winning the round. I want the cards to just "disappear" or placed in the computer's "discard" pile after each round, so they cannot be used again. I want each player to have a turn being first at the beginning or each round. (If player 1 is first in round 1, player 2 will go first in round 2 and so on.) I want the scores for each card to be calculated and placed in a box according to which player the cards belong to. Once the round is ended, the victor will receive the final score in their "total score" box. I also want a "round number" box to indicate which round it is. No winner will be declared until the players use all their cards and/or the computer deals all the tie deck cards (which are shuffled before dealing). At the end of the game, the person with the highest score is the winner.
    I also would like to allow players to challenge each other and accept or decline a challenge. In order to do that, the players must login first. There must also be a list of available players to challenge.
    Is there a program that not only builds the user interface, but also will allow me to insert my graphics? Kind of like WYSIWYG HTML builders? (Preferably FREE) I have a gui builder, but have no clue as to how to put in the graphics or get it to work. I don't have any connections to the programming world, nor am I able to return to school at this time. The programs that Sun offers are not adequate for me, because I need to be able to install it, and run it without going through the "msdos classpath" thingy. I need a "wizard" type program that is truly for "dummies." Something that I can just put in my images and tell it what I want it to do IN PLAIN ENGLISH. For instance, if I want the "login button" to save the login information to a file and/or to the game. The players can have their same login info stored in a file, and they can return without creating a new name. The website service I want to place this on, doesn't allow chmoding for CGI, so I can't use that. Another example, if I want each card to have a differnt point level and either subtract from or add to the blue. Or how to get the pop-up for the card displayed in the player's hand. I don't know what else to do. Any suggestions?

    <blockquote>
    The programs that Sun offers are not adequate for me, because I need to be able to install it, and run it without going through the "msdos classpath" thingy. I need a "wizard" type program that is truly for "dummies." Something that I can just put in my images and tell it what I want it to do IN PLAIN ENGLISH. For instance, if I want the "login button" to save the login information to a file and/or to the game. The players can have their same login info stored in a file, and they can return without creating a new name. The website service I want to place this on, doesn't allow chmoding for CGI, so I can't use that.
    </blockquote>
    This is a surely a joke. You honestly expect to get this for free. Even for an experienced programmer, to write 3/4 decent games - configure them to your network and meet these conditions. You're talking BIG or big-ish project here. As per your request, there is no such thing as point and click programming and there never ever will be.
    Use Macromedia Director. Closest thing you'll get to
    WYSIWYG programming. It's for simpletons and
    non-programmers.Ah, noooo. The shockwave games have been programmed in Lingo, which is quite powerful and much harder as a programming language than java (its also outdated, has some nasty featured and its a definite falling star). Flash gets a bit nearer with a point and click effort and you can do a surprising amount without knowing about programming, also as a media for the Internet its better supported than Shockwave and even java for the Web. But for any sort of worthwhile game need sprogramming knowledge.
    To conclude:
    you don't want to learn to program.
    noone is going to do this for you.
    You're a bit f***ed then aren't you.
    On a brighter note, if you pay me ?1,000.00 (half in advance), I'll think about it - solution in java or Flash, 3 games, ?1,500.00 for both. I can take it or leave it btw, couldn't give a sh*t either way.

  • Lost VB Programmer needs help

    Hi,
    I have created a JFrame with a JSplitPane and placed a JTree in the left side of the SplitPane. I made a class that populates the tree with a tree of options. When the user clicks the tree I want he right pane to change. The treemenu was an event listner that is working fine.
    The problem is the left pane is in a separate .java file called TreeMenu. On the JFrame I simply create a new instance of it and it populates the tree for me.
    As a VB programmer I would declare my TreeMenu to have an event such as MenuChanged("Selected Help"). The JFrame would see the message and call the right pane to update.
    How do I do this in Java? My problem occurs when I move code out to a separate class. If everything was done frm the one frame then I would be fine, but i want to modularise the application.
    Please help.
    Aaran

    Here's a bit of code that may help you with your modularity issues.
    File: Switchboard.java
    interface Switchboard {
        void operator(TreeData identity);
    }File: CallMaker.java
    import java.awt.event.*;
    public class CallMaker implements TreeSelectionListener {
        private TreeData identity;
        private Switchboard destination;
        CallMaker( TreeData id, Switchboard swbd ) {
            identity = id;
            destination = swbd;
        public void valueChanged( TreeSelectionEvent e ) {
            destination.operator( identity );
    }For what you're trying to do I would suggest the following:
    1)Declare the Tree Populator to implement the Switchboard interface.
    2)put the code that populates the table into the operator method, or
    simply call the class/method that populates the tree from the
    operator method.
    3)Use an instance of the CallMaker class as a Listener on your tree.
    It should work something like this:
    public class PanePopulator implements Switchboard;
    //Other code and whatnot...
       public void operator(TreeData td) {
          //Decide how to populate the right pane
          //based on the TreeData.  Call other classes/methods.
    }In a separate file...
    public class TreeSide {
       JTree tree = new JTree();
       //initialize the tree.
       TreeData treeInfo = new TreeData();
       PanePopulator rightPane = new PanePopulator();
       tree.addTreeSelectionListener(new CallMaker(treeInfo, rightPane));
       treeInfo = (TreeData)theCurrentTreeSelection;
    }as long as treeInfo contains the data you need to populate the right pane, you'll be fine.
    When a selection is made the CallMaker instance calls: rightPane.operator(treeInfo);
    This provides your rightPane instance with the information it needs to populate the rightPane.

  • 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.

  • Vital Program no longer works after updating JAVA SE - Need help fast!

    System Info:     Window Vista Home Premium (Service Pak 2)
              Intel Core 2 CPU T5200 @1.60 GHz
              RAM     2 GB
              32 bit OS
    JAVA 6 SE Update 18 (build 1.6.0_18_b07)
    I am just an old guy, not a techie, with diabetes who uses Bayer?s CLUCOFACTS Deluxe for Windows to monitor/manage my blood sugars.
    A couple of weeks ago I had a warning message on starting up the program which led to a call to Bayer. They advised me to update my JAVA applications, which I did. Since that time, I have not been able to open the Bayer?s CLUCOFACTS Deluxe for Windows application.
    I searched the web to see if anyone had a similar problem. It appears a number of people have the same issue and have not been able to solve the problem. I signed up and logged into the JAVA site to see if there might be some clue . . . the lingo is over my head. I did check JAVA, via the site to insure it was running properly on my local disk.
    My gut feeling is a link was broken when the original JAVA was cleaned from the computer in preparation to do a fresh download of JAVA. When the current version was loaded, I was unable to open the application. Thinking it might be a matter of how the programs were loaded, I then downloaded/reinstalled Bayer?s CLUCOFACTS Deluxe for Windows without any luck.
    I am willing to give this another go if you have any specific advice that may help me find a solution. Because I am hearing impaired, the telephone is not an option for working through this problem. We have to rely on email.
    I need very simplified, step by step, instructions get the program up and running again. (Example: Start > Control Panel > JAVA right click > Open)
    I am not into programming or the development side of JAVA; I am just a simple user who needs some advice on how to get the program up and running again in order to manage my diabetes.
    Thank you so very much for taking time to help me!
    Jim

    Seems you're [not alone|http://www.health-forums.com/alt-support-diabetes/bayer-glucofacts-deluxe-problem-136625.html] <-- link
    Best guess advice is to uninstall Java completely and then install the Java version that came on your GLUCOFACTS (not CLUCOFACTS) CD. Then, from Control Panel -- > Java, clear the checkbox for "Check for updates automatically".
    Good luck!
    db
    edit
    Oh, it's probably not a CD but the Java folder on your USB device.
    Edited by: DarrylBurke

  • New to Java and need help with error message!

    I have just installed the oracle jdbc driver and am now getting the following error message when trying to use the jbdc driver instead of the jdbc:odbc wrap driver...
    See com.borland.dx.dataset.DataSetException error code: BASE+47
    com.borland.dx.dataset.DataSetException: Chain of 2 or more Exceptions occurred
         at com.borland.dx.dataset.DataSetException.a(Unknown Source)
         at com.borland.dx.dataset.DataSetException.throwExceptionChain(Unknown Source)
         at com.borland.dx.sql.dataset.q.a(Unknown Source)
         at com.borland.dx.sql.dataset.Database.openConnection(Unknown Source)
         at com.borland.dx.sql.dataset.Database.createPreparedStatement(Unknown Source)
         at com.borland.dx.sql.dataset.o.a(Unknown Source)
         at com.borland.dx.sql.dataset.o.d(Unknown Source)
         at com.borland.dx.sql.dataset.o.f(Unknown Source)
         at com.borland.dx.sql.dataset.QueryProvider.e(Unknown Source)
         at com.borland.dx.sql.dataset.JdbcProvider.provideData(Unknown Source)
         at com.borland.dx.dataset.StorageDataSet.a(Unknown Source)
         at com.borland.dx.dataset.DataSet.a(Unknown Source)
         at com.borland.dx.dataset.DataSet.open(Unknown Source)
         at com.borland.dbswing.JdbTable.bindDataSet(JdbTable.java:2749)
         at com.borland.dbswing.JdbTable.setDataSet(JdbTable.java:819)
         at myframes.ClaimView.btnSQL_actionPerformed(ClaimView.java:279)
         at myframes.ClaimView_btnSQL_actionAdapter.actionPerformed(ClaimView.java:440)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
         at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
         at java.awt.Component.processMouseEvent(Component.java:5100)
         at java.awt.Component.processEvent(Component.java:4897)
         at java.awt.Container.processEvent(Container.java:1569)
         at java.awt.Component.dispatchEventImpl(Component.java:3615)
         at java.awt.Container.dispatchEventImpl(Container.java:1627)
         at java.awt.Component.dispatchEvent(Component.java:3477)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
         at java.awt.Container.dispatchEventImpl(Container.java:1613)
         at java.awt.Window.dispatchEventImpl(Window.java:1606)
         at java.awt.Component.dispatchEvent(Component.java:3477)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
    Chained exception:
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
         at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
         at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
         at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
         at javax.naming.InitialContext.lookup(InitialContext.java:347)
         at com.borland.dx.sql.dataset.q.a(Unknown Source)
         at com.borland.dx.sql.dataset.Database.openConnection(Unknown Source)
         at com.borland.dx.sql.dataset.Database.createPreparedStatement(Unknown Source)
         at com.borland.dx.sql.dataset.o.a(Unknown Source)
         at com.borland.dx.sql.dataset.o.d(Unknown Source)
         at com.borland.dx.sql.dataset.o.f(Unknown Source)
         at com.borland.dx.sql.dataset.QueryProvider.e(Unknown Source)
         at com.borland.dx.sql.dataset.JdbcProvider.provideData(Unknown Source)
         at com.borland.dx.dataset.StorageDataSet.a(Unknown Source)
         at com.borland.dx.dataset.DataSet.a(Unknown Source)
         at com.borland.dx.dataset.DataSet.open(Unknown Source)
         at com.borland.dbswing.JdbTable.bindDataSet(JdbTable.java:2749)
         at com.borland.dbswing.JdbTable.setDataSet(JdbTable.java:819)
         at myframes.ClaimView.btnSQL_actionPerformed(ClaimView.java:279)
         at myframes.ClaimView_btnSQL_actionAdapter.actionPerformed(ClaimView.java:440)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
         at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
         at java.awt.Component.processMouseEvent(Component.java:5100)
         at java.awt.Component.processEvent(Component.java:4897)
         at java.awt.Container.processEvent(Container.java:1569)
         at java.awt.Component.dispatchEventImpl(Component.java:3615)
         at java.awt.Container.dispatchEventImpl(Container.java:1627)
         at java.awt.Component.dispatchEvent(Component.java:3477)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
         at java.awt.Container.dispatchEventImpl(Container.java:1613)
         at java.awt.Window.dispatchEventImpl(Window.java:1606)
         at java.awt.Component.dispatchEvent(Component.java:3477)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
    Here is the code causeing the error;
    void btnSQL_actionPerformed(ActionEvent e)
    try
    String GET_DATASET = txtSQL.getText().trim();
    Display("Executing...");
    try
    MyDisplayTable.setDataSet(null);
    catch (DataSetException ex)
    Display("ERROR 1: " + ex.toString());
    try
    queryDataSet1.close();
    catch (DataSetException ex)
    Display("ERROR 2: " + ex.toString());
    try
    queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(
    database1, GET_DATASET, null, true, Load.ALL));
    catch (DataSetException ex)
    Display("ERROR 3: " + ex.toString());
    try
    if (!queryDataSet1.isOpen()) {
    queryDataSet1.open();
    catch (DataSetException ex) {
    Display("ERROR 5: " + ex.toString());
    try {
    queryDataSet1.refresh();
    catch (Exception ex) {
    Display("ERROR 5.5: " + ex.toString());
    try {
    Display("setDataSet");
    MyDisplayTable.setDataSet(queryDataSet1);
    Display("DONE setDataSet");
    catch (DataSetException ex) {
    Display("ERROR 6: " + ex.toString());
    Display("Query: ' " + GET_DATASET.trim() + " ' was executed successfully");
    catch (Exception ex)
    Display(ex.toString());
    Please let me know if more information is required. I am completely at a loss as to what more I need to do to get this to work using the new driver.
    Thank you all in advance,
    Malcolm Diaz
    Application Developer
    [email protected]
    PlanVista Solutions Inc.
    419 E.Main St.
    Middletown NY 10940
    845-346-2692

    this is more of a jdbc question rather than an internationalization. You might be able to get more help if you post it in java programming section.

  • I'm new to java and need help please

    I have an assignment involves modifying a previous assignment. the code for the previous assigment is shown below.(it was required to be done as an applet this assigment can be an application or an applet) I'm trying to modify this code to read a text file (items.txt) that looks like this:
    item # description price(this line does not appear in the text file)
    001 shaving cream 400.00
    999 razors 30.00
    I need to load the item# and price from the text file into arrays(I have no clue how to use multi-dimensional arrays in java and would prefer not to)
    I need to search the arrays based on the values entered by the user (item # and quantity) calculate the total for that item then create a new text file which has each line item for that order in the form:
    item# quant price per item total(price per item*quant entered)
    also also I need to be able to display the four items listed above after each loop as well as all the previous item number and quantities they selected until they indicate they don't want to select anymore.
    I've been working on this for days and it seems like nothing I try works. My major problems are:
    1. I have no idea how to read the text file and load those 2 items into their respective arrays
    2. I can't seem to create a textfile that looks like text for the output file.
    code]
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.text.*;
    import java.util.Locale;
    public class arraySelection
    extends JApplet {
    //Initialize the applet
    private Container getContentPane=null;
    public void init() {
    String string_item, string_quantity;
    String output = "";
    String description= "";
    int counter= 0;
    int itemNumber= 0;
    double quantity = 0 ;
    double tax_rate=.07;
    double total= 0, price= 0;
    double tax, subtotal;
    double Pretotal= 0;
    double priceArray[] = {1, .5, 3.65, 0.02, 0.09};
    String descriptionArray[] = {"salt", "pepper", "paprika", "garlic", "thyme"};
    // create number format for currency in US dollar format
    NumberFormat moneyFormat = NumberFormat.getCurrencyInstance( Locale.US );
    //format to have the total with two digits precision
    DecimalFormat twoDigits = new DecimalFormat("0.00");
    //Jtextarea to display results
    JTextArea outputArea = new JTextArea ();
    // get applet's content pane
    Container container = getContentPane ();
    //attach output area to container
    container.add(outputArea);
    //set the first row of text for the output area
    output += "Invoice\nItem#\tDescription\tQuant@Price\t Line Total" + "\n";
    do //begin loop structure obtain input from user
    // obtain item number from user
    string_item = JOptionPane.showInputDialog(
    "Please enter an item number 1, 2, 3, 4, or 5:");
    //obtain quantity of each item that user enter
    string_quantity = JOptionPane.showInputDialog("Enter the quantity:");
    // convert numbers from type String to Integer or Double
    itemNumber = Integer.parseInt(string_item);
    quantity = Double.parseDouble(string_quantity);
    switch (itemNumber) {//Determine input from user to assign price and description
    case 10: // user input item =10
    price = priceArray[0];
    description = descriptionArray[0];
    break;
    case 20: // user input item =20
    price = priceArray [1];
    description = descriptionArray[1];
    break;
    case 30: //user input item =30
    price=priceArray[2];
    description = descriptionArray[2];
    break;
    case 40: //user input item =40
    price=priceArray[3];
    description = descriptionArray[3];
    break;
    case 50: //user input item =50
    price=priceArray[4];
    description = descriptionArray[4];
    break;
    default: // user input item is not on the list
    output += "Invalid value entered"+ "\n";
    price=0;
    description= "";
    //Calculates the total for each item number and stores it in subtotal
    subtotal = price * quantity;
    //display input from user
    output += itemNumber + "\t" + description + "\t\t"+ quantity + "@" +
    moneyFormat.format( price) + "\t" + moneyFormat.format( subtotal) + "\n";
    //accumulates the overall subtotal for all items
    Pretotal = Pretotal + subtotal;
    //verifies that the user wants to stop entering data
    string_item = JOptionPane.showInputDialog(" Enter a positive integer to continue or 0 to stop. ");
    itemNumber = Integer.parseInt(string_item);
    // loop termination condition if user's input is 0 .It will end the loop
    } while ( itemNumber!= 0);
    tax = Pretotal * tax_rate; // calculate tax amount
    total = Pretotal + tax; //calculate total = subtotal + tax
    //appends data regarding the subtotal, tax, and total to the output area
    output += "\n" + "Order Subtotal" + "\t" + moneyFormat.format( Pretotal) +
    "\n" + "Tax" + "\t\t" + twoDigits.format( tax ) + "\n" + "Order Total" +
    "\t\t" + moneyFormat.format( total );
    //attaches the data in the output variable to the output area
    outputArea.setText( output );
    } //end init
    }// end applet Invoice
    Any help or sugestions would be greatly appreaciated. I've been working on this for over a week and everything I try goes nowhere.

    item # description price(this
    line does not appear in the text file)
    001 shaving cream 400.00
    999 razors 30.00
    I need to load the item# and price from the text file
    into arrays(I have no clue how to use
    multi-dimensional arrays in java and would prefer not
    to)That's good, because you shouldn't use multidimensional arrays here. You should have a one-dimensional array (or java.util.List) of objects that encapsulate each line.
    I've been working on this for days and it seems like
    nothing I try works. My major problems are:
    1. I have no idea how to read the text file and load
    those 2 items into their respective arrays
    2. I can't seem to create a textfile that looks like
    text for the output file.The java.io package has file reading/writing classes.
    Here's a tutorial:
    http://java.sun.com/docs/books/tutorial/essential/io/index.html

  • I'm new to java and need help please(repost)

    I have an assignment involves modifying a previous assignment. the code for the previous assigment is shown below.(it was required to be done as an applet this assigment can be an application or an applet) I'm trying to modify this code to read a text file (items.txt) that looks like this:
    item # description price(this line does not appear in the text file)
    001 shaving cream 400.00
    999 razors 30.00
    I need to load the item# and price from the text file into arrays(I have no clue how to use multi-dimensional arrays in java and would prefer not to)
    I need to search the arrays based on the values entered by the user (item # and quantity) calculate the total for that item then create a new text file which has each line item for that order in the form:
    item# quant price per item total(price per item*quant entered)
    also also I need to be able to display the four items listed above after each loop as well as all the previous item number and quantities they selected until they indicate they don't want to select anymore.
    I've been working on this for days and it seems like nothing I try works. My major problems are:
    1. I have no idea how to read the text file and load those 2 items into their respective arrays
    2. I can't seem to create a textfile that looks like text for the output file.
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.text.*;
    import java.util.Locale;
    public class arraySelection
        extends JApplet {
      //Initialize the applet
      private Container getContentPane=null;
      public void init() {
           String string_item, string_quantity;
           String output = "";
           String description= "";
           int counter= 0;
           int itemNumber= 0;
           double quantity = 0 ;
           double tax_rate=.07;
           double total= 0, price= 0;
           double tax, subtotal;
           double Pretotal= 0;
           double priceArray[] = {1, .5, 3.65, 0.02, 0.09};
           String descriptionArray[] = {"salt", "pepper", "paprika", "garlic", "thyme"};
         // create number format for currency in US dollar format
         NumberFormat moneyFormat = NumberFormat.getCurrencyInstance( Locale.US );
         //format to have the total with two digits precision
         DecimalFormat twoDigits = new DecimalFormat("0.00");
         //Jtextarea to display results
         JTextArea outputArea = new JTextArea ();
         // get applet's content pane
          Container container = getContentPane ();
          //attach output area to container
          container.add(outputArea);
         //set the first row of text for the output area
        output +=  "Invoice\nItem#\tDescription\tQuant@Price\t Line Total" + "\n";
        do //begin loop structure obtain input from user
               // obtain item number from user
               string_item = JOptionPane.showInputDialog(
                   "Please enter an item number 1, 2, 3, 4, or 5:");
               //obtain quantity of each item that user enter
               string_quantity = JOptionPane.showInputDialog("Enter the quantity:");
               // convert numbers from type String to Integer or Double
               itemNumber = Integer.parseInt(string_item);
               quantity = Double.parseDouble(string_quantity);
                 switch (itemNumber) {//Determine input from user to assign price and description
                    case 10: // user input item =10
                      price = priceArray[0];
                      description = descriptionArray[0];
                      break;
                    case 20: // user input item =20
                      price = priceArray [1];
                      description = descriptionArray[1];
                      break;
                    case 30: //user input item =30
                      price=priceArray[2];
                      description = descriptionArray[2];
                      break;
                    case 40: //user input item =40
                      price=priceArray[3];
                      description = descriptionArray[3];
                      break;
                    case 50: //user input item =50
                      price=priceArray[4];
                      description = descriptionArray[4];
                      break;
                    default: // user input item is not on the list
                    output += "Invalid value entered"+ "\n";
                    price=0;
                    description= "";
             //Calculates the total for each item number and stores it in subtotal
             subtotal = price * quantity;
             //display input from user
             output += itemNumber + "\t" + description + "\t\t"+ quantity + "@" +
                       moneyFormat.format( price) + "\t" + moneyFormat.format( subtotal) + "\n";
             //accumulates the overall subtotal for all items
             Pretotal = Pretotal + subtotal;
            //verifies that the user wants to stop entering data
            string_item = JOptionPane.showInputDialog(" Enter a positive integer to continue or 0 to stop. ");
            itemNumber = Integer.parseInt(string_item);
          // loop termination condition if user's input is 0 .It will end the loop
       } while ( itemNumber!= 0);
        tax = Pretotal * tax_rate; // calculate tax amount
        total = Pretotal + tax; //calculate total = subtotal + tax
        //appends data regarding the subtotal, tax, and total to the output area
        output += "\n" + "Order Subtotal" + "\t" + moneyFormat.format( Pretotal) +
                  "\n" + "Tax" + "\t\t" + twoDigits.format( tax ) + "\n" + "Order Total" +
                  "\t\t" + moneyFormat.format( total );
         //attaches the data in the output variable to the output area
         outputArea.setText( output );
      } //end init
    }// end applet InvoiceAny help or sugestions would be greatly appreaciated. I've been working on this for over a week and everything I try goes nowhere.

    First answer: You shouldn't ask multiple questions in the same thread. Ask a specific question, with an appropriate subject line (optionally, assign the number of Dukes you are willing to give for the help). When question #1 is answered and question #2 arises, it's time for a new thread (don't forget to give out Dukes before moving on).
    Second answer: I think you need a Transfer Object (http://java.sun.com/blueprints/patterns/TransferObject.html). It's whole purpose is to hold/transfer instance data where it is needed. Create a class something like this:
    public class ItemTO
        private String _number;
        private String _description;
        private double _price;
        public ItemTO( String number, String description, double price )
            _number = number;
            _description = description;
            _price = price
        // Getter/Setter methods go here
    }then, in the code where you read in the file do something like this:
    BufferedReader input = null;
    try
        input  = new BufferedReader( new FileReader( "c:\\a.txt" ) );
        List items = new ArrayList();
        String line;
        String itemNumber;
        String itemDescription;
        double itemPrice;
        while ( (line  = input.readLine() ) != null )
         System.out.println( line );
            itemNumber = // Parse it from line
            itemDescription // Parse it from line
            itemPrice = // Parse it from line
            items.add( new ItemTO( itemNumber, itemDescription, itemPrice ) );
    catch ( FileNotFoundException fnfe )
        fnfe.printStackTrace();
    catch ( IOException ioe )
        ioe.printStackTrace();
    finally
        try
            if ( input != null )
                input.close();
        catch ( Exception e )
            e.printStackTrace();
    }As for how to parse the line of the file, I'll leave that to you for now. Are the three values delimited with any special characters?
    jbisotti

  • Java noob needing help - First applet won't compile

    I'm trying to make a simple audio player applet for a web page. The basic way it works is: There are four buttons Play 1, Play 2, Play 3 and Stop, as well as a label for applet credits, a label for music credits and a label for the applet's current status.
    This is the applet so far:
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    public class wifflesaudio extends Applet implements MouseListener {
    add(new Label("(applet credits"));
    add(new Label("(music credits"));
    Label labelDoing = new Label("Stopped");
    Button buttonOne = new Button("Play 1");
    Button buttonTwo = new Button("Play 2");
    Button buttonThree = new Button("Play 3");
    Button buttonStop = new Button("Stop");
    add(buttonOne);
    add(buttonTwo);
    add(buttonThree);
    add(buttonStop);
    addMouseListener(this);
    String clipName[] = {getParameter("clipOne"),
    getParameter("clipTwo"),
    getParameter("clipThree")};
    AudioClip clipOne;
    AudioClip clipTwo;
    AudioClip clipThree;
    int whichIsPlaying = 0;
    public void loadClip(int clipNumber) {
    switch (clipNumber) {
    case 1:
    if (AudioClip.clipOne == null) {
    try {
    labelDoing = "Loading clip 1...";
    clipOne = Applet.newAudioClip(newURL(getCodeBase(), clipName[1]));
    catch (MalformedURLException e) {
    labelDoing = "WARNING: clip 1 didn't load";
    if (clipOne != null) {
    clipTwo.stop();
    clipThree.stop();
    clipOne.loop();
    whichIsPlaying = 1;
    break;
    case 2:
    if (clipTwo == null) {
    try {
    labelDoing = "Loading clip 2...";
    clipTwo = Applet.newAudioClip(newURL(getCodeBase(), clipName[2]));
    catch (MalformedURLException e) {
    labelDoing = "WARNING: clip 2 didn't load";
    if (clipTwo != null) {
    clipOne.stop();
    clipThree.stop();
    clipTwo.loop();
    whichIsPlaying = 2;
    break;
    case 3:
    if (clipThree == null) {
    try {
    labelDoing = "Loading clip 3...";
    clipThree = Applet.newAudioClip(newURL(getCodeBase(), clipName[3]));
    catch (MalformedURLException e) {
    labelDoing = "WARNING: clip 3 didn't load";
    if (clipTwo != null) {
    clipOne.stop();
    clipTwo.stop();
    clipThree.loop();
    whichIsPlaying = 3;
    break;
    public void actionPerformed(ActionEvent evt) {
    Button source = (Button)evt.getSource();
    if (source.getLabel().equals("Play 1")) {
    loadClip(1);
    if (source.getLabel().equals("Play 2")) {
    loadClip(2);
    if (source.getLabel().equals("Play 3")) {
    loadClip(3);
    if (source.getLabel().equals("Stop")) {
    clipOne.stop();
    clipTwo.stop();
    clipThree.stop();
    Naturally, it doesn't work. When I try to compile it with javac I get 21 errors thrown back at me. Being the noob that I am I have absolutely no idea why it isn't working, so I'm turning to all you clever people for some advice. :)

    Think anyone's going to copy your code into their own machine and compile it to see those messages for you? Well I did. Since there are a zillion error messages, I think it's fair to help a little bit:
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    // no need to implement MouseListener
    // see below
    public class wifflesaudio extends Applet {
        Label labelDoing = new Label("Stopped");
        Button buttonOne = new Button("Play 1");
        Button buttonTwo = new Button("Play 2");
        Button buttonThree = new Button("Play 3");
        Button buttonStop = new Button("Stop");
        String[] clipName;
        AudioClip clipOne;
        AudioClip clipTwo;
        AudioClip clipThree;
        int whichIsPlaying = 0;
        // statements in JAVA must be located with methods or constructors
        // here is the default constructor (with no param)
        wifflesaudio() {
            add(new Label("(applet credits"));
            add(new Label("(music credits"));
            add(buttonOne);
            add(buttonTwo);
            add(buttonThree);
            add(buttonStop);
            clipName = new String[3];
            clipName[0] = getParameter("clipOne");
            clipName[1] = getParameter("clipTwo");
            clipName[2] = getParameter("clipThree");
            addMouseListener(new wifflesaudioMouseListener()); // instead of addMouseListener(this)
        public void loadClip(int clipNumber) {
            switch (clipNumber) {
            case 1:
                if (clipOne == null) {
                    try {
                        // To set the text of a label, you must use setText() method.
                        labelDoing.setText("Loading clip 1...");
                        clipOne = newAudioClip(new URL(getCodeBase(), clipName[1])); // 'new URL' instead of 'newURL'
                    } catch (MalformedURLException e) {
                        // To set the text of a label, you must use setText() method.
                        labelDoing.setText("WARNING: clip 1 didn't load");
                if (clipOne != null) {
                    clipTwo.stop();
                    clipThree.stop();
                    clipOne.loop();
                    whichIsPlaying = 1;
                break;
            case 2:
                if (clipTwo == null) {
                    try {
                        // To set the text of a label, you must use setText() method.
                        labelDoing.setText("Loading clip 2...");
                        clipTwo = newAudioClip(new URL(getCodeBase(), clipName[2])); // 'new URL' instead of 'newURL'
                    } catch (MalformedURLException e) {
                        // To set the text of a label, you must use setText() method.
                        labelDoing.setText("WARNING: clip 2 didn't load");
                if (clipTwo != null) {
                    clipOne.stop();
                    clipThree.stop();
                    clipTwo.loop();
                    whichIsPlaying = 2;
                break;
            case 3:
                if (clipThree == null) {
                    try {
                        // To set the text of a label, you must use setText() method.
                        labelDoing.setText("Loading clip 3...");
                        clipThree = newAudioClip(new URL(getCodeBase(), clipName[3])); // 'new URL' instead of 'newURL'
                    } catch (MalformedURLException e) {
                        // To set the text of a label, you must use setText() method.
                        labelDoing.setText("WARNING: clip 3 didn't load");
                if (clipTwo != null) {
                    clipOne.stop();
                    clipTwo.stop();
                    clipThree.loop();
                    whichIsPlaying = 3;
                break;
        public void actionPerformed(ActionEvent evt) {
            Button source = (Button)evt.getSource();
            if (source.getLabel().equals("Play 1")) {
                loadClip(1);
            if (source.getLabel().equals("Play 2")) {
                loadClip(2);
            if (source.getLabel().equals("Play 3")) {
                loadClip(3);
            if (source.getLabel().equals("Stop")) {
                clipOne.stop();
                clipTwo.stop();
                clipThree.stop();
        // Extending MouseAdapter instead of implementing MouseListener
        // allows NOT to code ALL the methods from MouseListener
        // MouseAdapter already implements MouseListener with empty methods
        // You then just code the method(s) that is (are) needed.
        class wifflesaudioMouseListener extends MouseAdapter {
    }Please next time paste your code between code tags exactly like this:
    &#91;code&#93;
    your code
    &#91;/code&#93;
    Thank you

Maybe you are looking for

  • Can not receive data 10054

    My version of Essbase is 6.5.1.4. On the server machine it self when I am adding members to outline I get "Can not receive data 10054". To resolve this problem I tried to increase the server page file size but the problem persist.Does anyone know a s

  • Is the non-multi-room DVR also 500 hours?

    My ReplayTV just died and I am thinking of upgrading to a FiOS DVR. We currently have a multi-room DVR that my daughter uses and I don't want to share it with her (and vice versa) plus it's the old 80 hour model. It seems like I can only get one mult

  • Need help with how to configure jumpers on new HD

    I'm replacing the Hard Drive in an iMac 350 with the same type of Seagate HD I just replaced in my cube. I have a question about the jumber arrangement. On the old Apple HD [that came out of the iMac], with the Apple sticker face down on the table, t

  • OSB 11g Configuration

    Hi, I am trying to install Oracle Service Bus 11g, the installation went successfully, but when trying to configure the WebLogic (10.3.2) Domain and selecting (Oracle Service Bus Extension - all domain Technologies 11.1.1.3[Oracle_OSB]) from the doma

  • IDM: Implementing Password Synchronization only

    Hello to everyone. We are currently implementing IDM (7.2) by phases. For the first phase, we are planing to cover u201Cpaswword synchronizationu201D only. Therefore we are going to continue administrating user accounts in a descentralized way (Activ