Hi I'm new to java

Hi,
When i tried to run the Servlet it is showing the following warning:
"serializable class ProfileServlet doesn't declare a static final serialversionUID field of type long"
ProfileServlet.java
package flowers;
import java.io.IOException;
import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ProfileServlet extends HttpServlet{
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
          defaultAction(request,response);
public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
          defaultAction(request,response);
public void defaultAction(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
          String name=request.getParameter("UserID");
          String pwd=request.getParameter("PassWord");
          response.setContentType("text/html");
          PrintWriter out=response.getWriter();
          out.println("<html><head><title>Form Data Processing</title></head></html>");
          out.println("<body>");
          out.println("<h1>Welcome<h1>");
          out.println("<hr>");
                    out.println("<h3>Name is:"+name+"</h3></body></html>");
                    out.println("<h3>PassWord is:"+pwd+"</h3></body></html>");
          out.println("<hr>");          
ProfilePage.html
<p><HTML></p>
<p><HEAD></p>
<p><TITLE>ProfilePage.html</HTML></p>
<p></HEAD></p>
<p><BODY></p>
<p><FORM Action="http://localost:9080/BeautifulFlowers/ProfileServlet" Method="POST"></p>
<p>UserID:<INPUT TYPE="TEXT" NAME="UserID"><br></p>
<p>PassWord:<INPUT TYPE="TEXT" NAME="PassWord"><br></p>
<p><center></p><p><input type="submit" value="submit"
size="16"></p>
<p><input type="reset" value="reset" size="16"></p><p></center></p><p></FORM></p>
<p></BODY></p>
<p></HTML></p>
<p></p>
<p></p>
Please help me with this

duffymo wrote:
Terrible code, by the way. Yours is an example of how not to write good servlets. You're new to Java, so it can be excused. If you're new, why start with a servlet? Most people begin with "Hello, world". Are you already beyond that?I don't know the story with this newbie, but there are just too many instructors that must be introducing Java in heinous ways, like via scriptlets stuck in JSP. It used to be the misconception that Java was mainly for writing applets; now the misconception is that it's mainly for scriptlets.
It's gotten to the point that I don't want to look at any posted question about JSP or servlets. I know the code will be so bad that only first advice is to start over, but the only thing the poster wants to hear is how to hack their code further.

Similar Messages

  • How can I open help file (HTML or .chm) from Java Web Start (new to JAVA)

    Hi All,
    Im trying to open the help file of my application.
    When trying to access the help file from the GUI (pressing F1 for launching the help file), I'm geting the an error, something like:
    "Can't show help URL: jar:file:C:\Documents and Settings\%USER%\Application Data\Sun\Java\Deployment\javaws\cache\http\Dlocalhost\P7001\DMwebstart\RMjar-name!/com/resources/helpFiles/MyHelpFile.html"
    It seems that the file which is packed in a jar, was downloaded to the Java Web Start cache directory:
    C:\Documents and Settings\%USER%\Application Data\Sun\Java\Deployment\javaws\cache\http\Dlocalhost\P7001\DMwebstart
    The code which is activated when launching the help file is:
    try
                ResourceBundle resourceBundle = DoubleResourceBundle.getBundle("Resource", "ResourceImpl");
                RuntimeUtil.launchFile(new File(resourceBundle.getString("help.file")));
            } catch (IOException e)
                // TODO Auto-generated catch block
                e.printStackTrace();
            }where the property "help.file" is in some property file in the resource bundle named "Resource", and looks like this :
    help.file="com/trax/docs/help/global/MyHelpFile.html"
    The function "RuntimeUtil.launchFile" knows how to launch any file in its default application, and indeed it does launches the html, when giving it an absolute path to the file on my PC, as "C:\Helpfiles\MyHelpFile.html" as such:
    RuntimeUtil.launchFile("C:\Helpfiles\MyHelpFile.html");My question is :
    The application is going to be deployed on a Customer PC. How can I access the html file from the code, with a relative path and not its absolute path on the customer pc, which I can't know?
    I found these restrictions regarding web start:
    (copied from "http://rachel.sourceforge.net/"):
    *Rule 1: Java Archives only. No loose files.* All your resources have to be packaged in Java Archives (jar) if you want to have
    them delivered to the user's machine and kept up-to-date automatically by Java Web Start.
    *Rule 2: No file paths.* You can't use absolute or relative file paths to locate your
    jars holding your resources (e.g. <code>jar:file:///c:/java/jws/.cache/resources.jar</code>).
    Absolute file paths won't work because you never know where Java Web Start
    will put your jar on the user's machine. Relative file paths won't work because Java Web Start
    mangles the names of your jars (e.g. <code>venus.jar</code> becomes <code>RMvenus.jar</code>)
    and every JNLP client implementation has the right to mangle your names
    in a different way and you, therefore, can't predict the name with
    which your jar will be rechristend and end up on the user's machine in
    the application cache.Seems complex or impossible, to perform a simple task like opening a file.
    Please advise (I'm new to Java and Web Start).
    BTW, I'm working with IntelliJ IDEA 5.0.
    Thanks,
    Zedik.
    {font:Tahoma}{size:26pt}
    {size}{font}

    the follwing method i have used to open html file ...
    so to access html file i am shipping resources folder with jar file ..
    private void openHtmlPages(String pageName) {
         String cmd[] = new String[2];
         String browser = null;
         File file = null;
         if(System.getProperty("os.name").indexOf("Linux")>-1) {
              file = new File("/usr/bin/mozilla");
              if(!file.exists() ) {
              }else     {
                   browser = "mozilla";
         }else {
              browser = "<path of iexplore>";
         cmd[0] = browser;
         File files = new File("");
         String metaData = "/resources/Help/Files/"+pageName+".html"; // folder inside jar file
         java.net.URL url = this.getClass().getResource(metaData);
         String fileName = url.getFile();
         fileName = fileName.replaceAll("file:/","");
         fileName = fileName.replaceAll("%2520"," ");
         fileName = fileName.replaceAll("%20"," ");
         fileName = fileName.replaceAll("jarfilename.jar!"," ").trim();
         cmd[1] = fileName;     
         try{
              Process p = Runtime.getRuntime().exec(cmd);
         }catch(java.io.IOException io){
                   //Ignore
    can anyone give me the solution..???
    Regards
    Ganesan S

  • What is new in Java syntaxes in new Java versions?

    What is new in Java syntaxes in new Java versions?
    What about this sentenses
    1. for (int c:data), where data is array of integer
    2. ArrayList<Object> () ...
    3. Class<?>...
    I can't find this syntaxes in my books and documentation...
    And what Java version is latest?

    dont crosspost
    Edited by language police

  • What's new in Java 4

    Anybody can quickly explain the things are added in Java 4 newly.
    Thnx in advance.

    Nothing's new in Java 4 because there is no Java 4.
    Maybe you mean Java 5?
    Or maybe you mean Java 1.4?
    In either case, either the download page for that version, or the installation, should have release notes that answer your question.
    In fact, here they are for Java 5:
    http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html

  • 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: how to replace an image extending a JComponent?

    Hi,
    I'm new to Java and I have a question about Swing:
    I have a class called ActiveImage (entends JComponent, implements     MouseMotionListener, MouseWheelListener) which takes an Image and displays it. It also receives some mouse events for zooming and moving it around. I display it in a JFrame using:
    content = getContentPane();
    content.setLayout(new BorderLayout());
    image = toolkit.getImage (filename);
    ActiveImage activeImage = new ActiveImage(image);
    content.add(activeImage, BorderLayout.CENTER);
    (This code is in a class extending JFrame.)
    This works fine. However, this JFrame also contains a JToolbar with two buttons. Now when I click one of them, I want to replace the image with another one. I've tried removing it and creating a new ActiveImage to add that to content, but that didn't work very well. remove() resulted in a NullPointerException.
    My question: what would be the best way to go about this?
    Many thanks for any help,
    Diederick de Vries

    B.T.W., this is the trace:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at ActiveImage.ActiveImageFrame$1.actionPerformed(ActiveImageFrame.java:60)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
            at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
            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:234)
            at java.awt.Component.processMouseEvent(Component.java:5488)
            at javax.swing.JComponent.processMouseEvent(JComponent.java:3093)
            at java.awt.Component.processEvent(Component.java:5253)
            at java.awt.Container.processEvent(Container.java:1966)
            at java.awt.Component.dispatchEventImpl(Component.java:3955)
            at java.awt.Container.dispatchEventImpl(Container.java:2024)
            at java.awt.Component.dispatchEvent(Component.java:3803)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
            at java.awt.Container.dispatchEventImpl(Container.java:2010)
            at java.awt.Window.dispatchEventImpl(Window.java:1766)
            at java.awt.Component.dispatchEvent(Component.java:3803)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)Just before this, it says "button clicked". The function that calls the setImage() goes:
    theButton.addActionListener (new ActionListener() {
         public void actionPerformed(ActionEvent ae) {
              System.out.println("button clicked");
              activeImage.setImage(image);
    });Reading the trace, I would think that the exception has something to do with this last code, since it stops there (line 60 is the setImage()). If the setImage() function itself was where the fault was, wouldn't the trace end there?
    I'm really at a loss here ... :-(

  • New to Java(TM) ME Platform SDK 3.0 how to open multiple emulators?

    Hi im new to Java Mobile Phone apps.
    I want to make a bluetooth game and theres a great bluetooth example in the package but i just cant find anywhere i can open 2 or more emulators.
    The compiler does'nt allow multiple instances either, Havent found a setting to change that either.
    Please help thank you.

    ooo apperently you have to "copy" the project and then change the emulator settings for the project to use a diffrent emulator shell. also you have to fix all build errors.

  • 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

  • Im new to java and hope somebody can help me with my question

    Hi!
    Im quite new to java and I just have some simple questions..
    can someone please tell what kinds of error are considered as language violation for java? where can I find more info about these errors?
    can someone give me a simple example on a kind of error that cannot be caught in both compilation and runtime? I hope someone can help me out. Thanks in advance!!

    knightz211 wrote:
    Im just asking about errors that might go against the language definition but cant be detected.. If it "goes against the language defintion," it will be detected by the compiler. That's half of the compiler's job is to tell you what you've done that violates the language spec.
    because it confuses me when they say that such errors might occur so I just want to know what might these errors be.. sorry for that..Who's "they"? What exactly* did "they" say about "such errors"? It sounds to me like you're just confused, and you think there's something mysterious and inexplicable going on but you don't know what and don't even know what you're asking.
    I would suggest not worrying about hypothetical problems that you can't even put into words and focussing on learning Java. Along the way, if you encounter real, specific, actual problems, ask about them, and you'll probably get answers about the problems themselves and the language or theory behind them.

  • New To Java. Learning About Java Applet.

    Hi all, i am new to java. Actually i am facing problem with java applet. I am trying to use my cellphone to surf web. When i open a webpage from cellphone, the part which contain the java applet, it cannot be shown and appeared blank. I am using Nokia 7610, can it be solve?
    Can anybody help me? Thank You.

    JSE JRE stand for Sun Java Studio Enterprise 8.1 Final Release or Java SE Runtime Environment (JRE)? Which Shall i download? By the way the file type are .exe and .sh , how to let it become .sis?

  • New to Java RMI

    I am having problems with the following code that I am currently trying to understand RMI from Java head First, the following are meant to be part of an universal browser that the browser downloads and displays interactive Java GUIs. Can someone explain what I am doing wrong as I am still new to Java please?
    import java.awt.*;
    import javax.swing.*;
    import java.rmi.*;
    import java.awt.event.*;
    public class ServiceBrowser {
       JPanel mainPanel;
       JComboBox serviceList;
       ServiceServer server;
       public void buildGUI() {
          JFrame frame = new JFrame("RMI Browser");
          mainPanel = new JPanel();
          frame.getContentPane().add(BorderLayout.CENTER, mainPanel);
          Object[] services = getServicesList();
          serviceList = new JComboBox(services);
          frame.getContentPane().add(BorderLayout.NORTH, serviceList);
          serviceList.addActionListener(new MyListListener());    
          frame.setSize(500,500);
          frame.setVisible(true);
       void loadService(Object serviceSelection) {
           try {
              Service svc = server.getService(serviceSelection);
              mainPanel.removeAll();
              mainPanel.add(svc.getGuiPanel());
              mainPanel.validate();
              mainPanel.repaint();
            } catch(Exception ex) {
               ex.printStackTrace();
       Object[] getServicesList() {
          Object obj = null;
          Object[] services = null;
          try {
              obj = Naming.lookup("rmi://127.0.0.1/ServiceServer");   
         catch(Exception ex) {
           ex.printStackTrace();
         server = (ServiceServer) obj;
          try {
            services = server.getServiceList();
          } catch(Exception ex) {
             ex.printStackTrace();
         return services;
       class MyListListener implements ActionListener {
          public void actionPerformed(ActionEvent ev) {
              // do things to get the selected service
              Object selection =  serviceList.getSelectedItem();
              loadService(selection);
      public static void main(String[] args) {
         new ServiceBrowser().buildGUI();
    }I am able to compile the code but come up with the following error messages at runtime
    java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
         java.net.ConnectException: Connection refused
         at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
         at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
         at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
         at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
         at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
         at java.rmi.Naming.lookup(Naming.java:84)
         at ServiceBrowser.getServicesList(ServiceBrowser.java:53)
         at ServiceBrowser.buildGUI(ServiceBrowser.java:19)
         at ServiceBrowser.main(ServiceBrowser.java:82)
    Caused by: java.net.ConnectException: Connection refused
         at java.net.PlainSocketImpl.socketConnect(Native Method)
         at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
         at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
         at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
         at java.net.Socket.connect(Socket.java:529)
         at java.net.Socket.connect(Socket.java:478)
         at java.net.Socket.<init>(Socket.java:375)
         at java.net.Socket.<init>(Socket.java:189)
         at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
         at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
         at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
         ... 8 more
    java.lang.NullPointerException
         at ServiceBrowser.getServicesList(ServiceBrowser.java:64)
         at ServiceBrowser.buildGUI(ServiceBrowser.java:19)
         at ServiceBrowser.main(ServiceBrowser.java:82)
    Exception in thread "main" java.lang.NullPointerException
         at javax.swing.DefaultComboBoxModel.<init>(DefaultComboBoxModel.java:53)
         at javax.swing.JComboBox.<init>(JComboBox.java:175)
         at ServiceBrowser.buildGUI(ServiceBrowser.java:21)
         at ServiceBrowser.main(ServiceBrowser.java:82)
    The code for the remote implementation compile and runs, but the other code for services compiles but come back with the following error message at runtime:
    Exception in thread "main" java.lang.NoSuchMethodError: main
    I have included one of the services code below this happens with:
    import javax.swing.*;
    import java.awt.event.*;
    import java.io.*;
    public class DiceService implements Service {
        JLabel label;
        JComboBox numOfDice;
        public JPanel getGuiPanel() {
           JPanel panel = new JPanel();
           JButton button = new JButton("Roll 'em!");
           String[] choices = {"1", "2", "3", "4", "5"};
           numOfDice = new JComboBox(choices);
           label = new JLabel("dice values here");
           button.addActionListener(new RollEmListener());
           panel.add(numOfDice);
           panel.add(button);
           panel.add(label);
           return panel;
       public class RollEmListener implements ActionListener {
          public void actionPerformed(ActionEvent ev) {
             // roll the dice
             String diceOutput = "";
             String selection = (String)  numOfDice.getSelectedItem();
             int numOfDiceToRoll = Integer.parseInt(selection);
             for (int i = 0; i < numOfDiceToRoll; i++) {
                int r = (int) ((Math.random() * 6) + 1);
                diceOutput += (" " + r);
            label.setText(diceOutput);
    }

    how I do get suitable server running, can I not test the code on a local ip address first, i have included the remote implementation code below, can you advise how I can resolve this please or point me in the right direction?
    import java.rmi.*;
    import java.util.*;
    import java.rmi.server.*;
    public class ServiceServerImpl extends UnicastRemoteObject implements ServiceServer  {
        HashMap<String, Service> serviceList;
        public ServiceServerImpl() throws RemoteException {
           // start and set up services
           setUpServices();
       private void setUpServices() {
           serviceList = new HashMap<String, Service>();
           serviceList.put("Dice Rolling Service", new DiceService()); 
           serviceList.put("Day of the Week Service", new DayOfTheWeekService()); 
           serviceList.put("Visual Music Service", new MiniMusicService());  
        public Object[] getServiceList() {
           System.out.println("in remote");
           return serviceList.keySet().toArray();
        public Service getService(Object serviceKey) throws RemoteException {       
           Service theService = (Service) serviceList.get(serviceKey);      
           return theService;
        public static void main (String[] args) {
           try {
             Naming.rebind("ServiceServer", new ServiceServerImpl());
            } catch(Exception ex) { }
            System.out.println("Remote service is running");
    }

  • Issue with new EWS Java 1.2 license and ambiguity

    If this isn't the proper place for this thread, then please let me know where it should go.
    I noticed that EWS Java 1.2 has been marked with an Apache 2.0 license. Let me just say this...
    FINALLY!
    If ever there was a project that needed it, it's EWS Java. That API has seemingly turned into abandonware and the old license forbade redistribution of modified source, so the many bugs in it had to be independently fixed by devs around the world. Not fun.
    With a proper open source license, this problem can be alleviated.
    HOWEVER...
    After downloading the zip file from the new EWS Java page, I've found that while the Apache 2.0 license is present in the root directory, the earlier and more restrictive license is still present in the project directory. This introduces ambiguity into the
    license terms. Not good. I would not be comfortable redistributing modified (or even original) source code with this kind of ambiguity, even if it's just an oversight on Microsoft's part. Please remove the old license entirely from the API.
    Also, if possible, can this get an official repository? The new license is great, but with only a zip file as an "official" source, it's begging for fragmentation across who-knows-how-many repositories and accounts, especially since it's not even
    a proper Maven project.
    I'd love to do some work on EWS Java myself (I've already fixed a number of bugs), but with the license issues and lack of an official repository, that doesn't seem terribly feasible.

    I'm not sure if you're going to be able to reliably find an actual fulltime MSFT person (especially targeted towards a specific product group) in any of these forums. You might try posting a comment on this blog post though, that might help get someone's
    attention:
    http://blogs.msdn.com/b/exchangedev/archive/2013/01/03/ews-java-api-1-2-get-started.aspx?Redirected=true#comments
    We do have a Microsoft employee who moderates this forum, but since this forum is only meant for feedback on the defunct TechNet subscriptions I don't think he'll be able to help you out very much. We'll see though, maybe Mike has some Exchange team connections
    that I don't know about.
    Don't retire TechNet! -
    (Don't give up yet - 12,950+ strong and growing)

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

  • Very New to Jave, need to do totals/subtotals

    Hi, (I hope this is the right place)
    I'm VERY new to Java (I mainly do wourk with php interfaces for MyAQL databases).
    Up until now, there hasn't been anything I couldn't do with PHP that I needed to...
    My boss recently requested subtotals/totals at various points on an input sheet. The sheet inputs numbers of people, so I'm not worried about rounding (The php already takes care of people trying to input parts of people....) or tax.
    It's a rather large form (~144 lines) and the math is already in place to do the subtotaling (among other things) before entering the information into the database.
    How would I go about writing script that would display sub totals, and recalculate them every time one of the boxes value's is modified?
    Is this something javascript is designed to do? Is there a better language out there for this task?
    I've found sites out there that have canned subtotal/total scripts, but I don't want something pre-made unless it comes with a detailed explaination of what everything does; if I'm going to maintain it, I have to understand it.
    Thanks

    Is this a web form? e.g. a html form with input fields?
    You can add onchange or onblur events to your input fields to detect changes. Then you can use javascript to retrieve the values from the form and do the calculation.
    -S

Maybe you are looking for

  • Opening Balance and closing balance

    Dear All,              Can i create a calculated field for ledger opening balance and closing balance. we are using  epicor. I dont know the exact table which captures opening balance and closing balance, where as i got credit balances and debit bala

  • Information on : MMS in EU

    If you can not send MMS +(Even when you have activated the mms in the settings of your iPhone)+ the problem lies with your mobile carrier in EU. Until T-Mobile, Orange, A1 and co have done their work, you may help your self here: For iPhone users in

  • Business user  needs to view tables with out SE16 access

    Hi , There is a requirement where  business user  ( Data team)    need to view some master and transactional data tables  in  production . But , as per our process , end users will not  be given SE16  access . Is there any solution where we can allow

  • Request through http, but I cannot get a Computer certificate

    Hello, From a client I type in my browser: http://dc1/certsrv. Then I get to a screen where I can choose among these certificates: User, Basic EFS, Administrator....and a few more ; but I don't see "Computer certificate" in that list. Does anyone kno

  • Run Time Error when starting photoshop elements9

    Run Time error keeps crashing photoshop elements 9 when i try to start up.