Please help, java program terminating unexpectedly without reason

ok, so I have a project I'm working on, here's its description:
Create a new project named FML_Pig where F is your first initial, M is your middle initial, and L is your last initial. For example, if your name is Alfred Edward Neuman then you would name your project AEN_Pig. If necessary, add a new Java file to this project named FML_Pig.
Add a java file to the project named FML_Dice.
Design and implement a Dice class as follows. The Dice class has 2 twenty‑sided dice with numbers on the faces (1 � 20) and 2 twenty-six-sided dice with letters on the faces (a � z).
import java.util.Random;
public class FML_Dice
private static Random gen = new Random();
private final static int NUM_SIDES = 20;
private int die1, die2, numSnakeEyes, numVowels, totalPoints;
private char die3, die4;
Part 1
Add a rollDice() method to your FML_Dice class that sets die1 and die2 to a random number between 1 and 20 and it sets die3 and die4 to a random character between �a� and �z�.
Helpful Hint:
dice3 = (char)(�a� + gen.nextInt(26)); // sets dice3 to a random char between �a� and �z�.
Part 2
Write a constructor that sets die1 and die2 to a random number between 1 and 20 and it sets die3 and die4 to a random character. Your constructor can simply call rollDice() to do this. It should also initialize numSnakeEyes, numVowels, and totalPoints to 0 (after you roll the dice).
Part 3
Write methods getDie1(), getDie2(), getDie3(), and getDie4() that returns the value of the respective die. Write a method numSnakes() that returns the number of snake eyes that have been rolled. Write a method numVowels() that returns the number of vowels that have been rolled. Write a method totalPts() that returns the totalPoints.
Part 4
Write a toString() method that overwrites the default toString() method. It should return a String representation of the value of all 4 die. For example, 17 2 h w.
Part 5
Write a method updateTotals that updates numVowels, numSnakeEyes, and totalPoints based on the current values of die1, die2, die3, and die4. numVowels should be incremented by 1 if either die3 or die4 are a vowel. However, if both die3 and die4 are vowels, the totalPoints should be reset to 0 and numVowels should be reset to 0 also. numSnakeEyes should be incremented by 1 if either die1 or die2 have a face value of 1 (this is not truly a snake eyes, but it gives better odds for the game). totalPoints should be incremented by the sum of die1 and die2 multiplied by (numSnakeEyes + 1).
Part 6
Write a main program (use the one in FML_Pig.java) that plays a game of Pig. In this game, two people play against each other. Player1 begins by rolling the dice. The total of die1 and die2 is added to his total score. Player1�s turn continues until he/she rolls a total of 4 vowels then the turn switches to Player2. Whenever a turn switches to the other player, the number of vowels is reset to zero. Also, if at any time both die3 and die4 are vowels, the total score is reset to 0 and the turn switches to the other player. (So the turn switches to the other player whenever the total number of vowels reaches four or there are two vowels rolled at the same time.)
If a player rolls snakeeyes (for our game, snakeeyes occurs whenever either of the dice have a face value of one � in reality, both die1 and die2 should have a face value of one but then snakeeyes would occur only once every 400 rolls), then his point values are doubled from that point on (all future rolls for the rest of the game, point values for this player are doubled). When a player rolls snake eyes again, point values are tripled for that roll and all future rolls. (Three snake eyes, quadrupled, etc.)
(continued on the next page)
Be sure to display the results of the roll for each turn.
First player to get to 2000 points wins the game and gets to oink like a pig.
Note: Both players need their own set of Dice since the Dice keeps track of the totalPoints, the number of snake eyes rolled so far, and the number of vowels rolled so far for that particular player. You can do this simply by declaring it that way in the main program:
Dice player1 = new Dice();
Dice player2 = new Dice();
You may add additional methods and instance variables to the class as needed. For example, I would probably write a private helper method isVowel() that is passed a char argument ch and returns true if ch is a vowel.
Also, you can have the computer play for both player 1 and player 2. Simply loop it until somebody wins. Print out the result for each turn including who rolled the dice (player 1 or player 2), what they rolled, how many snakeeyes do they have, how many points did they get for this turn, and how many total points do they have.
When you are completely finished, hand in just the java files (FLM_Dice & FLM_Pig). If you happened to write any other classes, make sure they are named with the FML format, and turn these in as well. I do not need EasyReader or p.
Oink! Oink!
This pig won the game --------->
so here's my code:
this isn't my code but is required to compile my code: // package com.skylit.io;
import java.io.*;
*  @author Gary Litvin
*  @version 1.2, 5/30/02
*  Written as part of
*  <i>Java Methods: An Introduction to Object-Oriented Programming</i>
*  (Skylight Publishing 2001, ISBN 0-9654853-7-4)
*   and
*  <i>Java Methods AB: Data Structures</i>
*  (Skylight Publishing 2003, ISBN 0-9654853-1-5)
*  EasyReader provides simple methods for reading the console and
*  for opening and reading text files.  All exceptions are handled
*  inside the class and are hidden from the user.
*  <xmp>
*  Example:
*  =======
*  EasyReader console = new EasyReader();
*  System.out.print("Enter input file name: ");
*  String fileName = console.readLine();
*  EasyReader inFile = new EasyReader(fileName);
*  if (inFile.bad())
*    System.err.println("Can't open " + fileName);
*    System.exit(1);
*  String firstLine = inFile.readLine();
*  if (!inFile.eof())   // or:  if (firstLine != null)
*    System.out.println("The first line is : " + firstLine);
*  System.out.print("Enter the maximum number of integers to read: ");
*  int maxCount = console.readInt();
*  int k, count = 0;
*  while (count < maxCount && !inFile.eof())
*    k = inFile.readInt();
*    if (!inFile.eof())
*      // process or store this number
*      count++;
*  inFile.close();    // optional
*  System.out.println(count + " numbers read");
*  </xmp>
public class EasyReader
  protected String myFileName;
  protected BufferedReader myInFile;
  protected int myErrorFlags = 0;
  protected static final int OPENERROR = 0x0001;
  protected static final int CLOSEERROR = 0x0002;
  protected static final int READERROR = 0x0004;
  protected static final int EOF = 0x0100;
   *  Constructor.  Prepares console (System.in) for reading
  public EasyReader()
    myFileName = null;
    myErrorFlags = 0;
    myInFile = new BufferedReader(
                            new InputStreamReader(System.in), 128);
   *  Constructor.  opens a file for reading
   *  @param fileName the name or pathname of the file
  public EasyReader(String fileName)
    myFileName = fileName;
    myErrorFlags = 0;
    try
      myInFile = new BufferedReader(new FileReader(fileName), 1024);
    catch (FileNotFoundException e)
      myErrorFlags |= OPENERROR;
      myFileName = null;
   *  Closes the file
  public void close()
    if (myFileName == null)
      return;
    try
      myInFile.close();
    catch (IOException e)
      System.err.println("Error closing " + myFileName + "\n");
      myErrorFlags |= CLOSEERROR;
   *  Checks the status of the file
   *  @return true if en error occurred opening or reading the file,
   *  false otherwise
  public boolean bad()
    return myErrorFlags != 0;
   *  Checks the EOF status of the file
   *  @return true if EOF was encountered in the previous read
   *  operation, false otherwise
  public boolean eof()
    return (myErrorFlags & EOF) != 0;
  private boolean ready() throws IOException
    return myFileName == null || myInFile.ready();
   *  Reads the next character from a file (any character including
   *  a space or a newline character).
   *  @return character read or <code>null</code> character
   *  (Unicode 0) if trying to read beyond the EOF
  public char readChar()
    char ch = '\u0000';
    try
      if (ready())
         ch = (char)myInFile.read();
    catch (IOException e)
      if (myFileName != null)
        System.err.println("Error reading " + myFileName + "\n");
      myErrorFlags |= READERROR;
    if (ch == '\u0000')
      myErrorFlags |= EOF;
    return ch;
   *  Reads from the current position in the file up to and including
   *  the next newline character.  The newline character is thrown away
   *  @return the read string (excluding the newline character) or
   *  null if trying to read beyond the EOF
  public String readLine()
    String s = null;
    try
      s = myInFile.readLine();
    catch (IOException e)
      if (myFileName != null)
        System.err.println("Error reading " + myFileName + "\n");
      myErrorFlags |= READERROR;
    if (s == null)
      myErrorFlags |= EOF;
    return s;
   *  Skips whitespace and reads the next word (a string of consecutive
   *  non-whitespace characters (up to but excluding the next space,
   *  newline, etc.)
   *  @return the read string or null if trying to read beyond the EOF
  public String readWord()
    StringBuffer buffer = new StringBuffer(128);
    char ch = ' ';
    int count = 0;
    String s = null;
    try
      while (ready() && Character.isWhitespace(ch))
        ch = (char)myInFile.read();
      while (ready() && !Character.isWhitespace(ch))
        count++;
        buffer.append(ch);
        myInFile.mark(1);
        ch = (char)myInFile.read();
      if (count > 0)
        myInFile.reset();
        s = buffer.toString();
      else
        myErrorFlags |= EOF;
    catch (IOException e)
      if (myFileName != null)
        System.err.println("Error reading " + myFileName + "\n");
      myErrorFlags |= READERROR;
    return s;
   *  Reads the next integer (without validating its format)
   *  @return the integer read or 0 if trying to read beyond the EOF
  public int readInt()
    String s = readWord();
    if (s != null)
      return Integer.parseInt(s);
    else
      return 0;
   *  Reads the next double (without validating its format)
   *  @return the number read or 0 if trying to read beyond the EOF
  public double readDouble()
    String s = readWord();
    if (s != null)
      return Double.parseDouble(s);
      // in Java 1, use: return Double.valueOf(s).doubleValue();
    else
      return 0.0;
}same with this:
public class p
     public static void l(String S)
      { System.out.println(S);}
     public static void o(String S)
      {System.out.print(S);}
     public static void l(int i)
      { System.out.println(i);}
     public static void o(int i)
      {System.out.print(i);}
     public static void l(boolean b)
      { System.out.println(b);}
     public static void o(boolean b)
      {System.out.print(b);}
    public static void l(char c)
      { System.out.println(c);}
     public static void o(char c)
      {System.out.print(c);}     
     public static void l(double d)
      { System.out.println(d);}
     public static void o(double d)
      {System.out.print(d);} 
    public static void l(Object obj)
      { System.out.println(obj.toString());}
     public static void o(Object obj)
      {System.out.print(obj.toString());}
     public static void l()
      {System.out.println();}
}       here's my code:
import java.util.*;
public class JMM_Pig
     public static void main(String[] args)
          int winner=0;
          int pts=0;
               JMM_Dice player1=new JMM_Dice();
               JMM_Dice player2=new JMM_Dice();
               p.l("Player 1 rolls the dice...");
               player1.rollDice();
               player1.updateTotals();
               boolean loop=true;
               while(loop)
               while(player1.numVowels()<=4)
                    p.l("Player 1 continues his turn...");
                    player1.rollDice();
                    player1.updateTotals();
                    p.l("Player 1 rolled a "+player1.getDie1()+" and a "+player1.getDie2()+" and a '"+player1.getDie3()+"' and a '"+player1.getDie4()+"'");
                    p.l("Player 1 rolled "+player1.currvowels()+" vowels.");
                    p.l("Player 1 has "+player1.totalvowels()+" total vowels.");
                    //if(player1.getMagic()==1)
                    //player1.totalPoints=(player1.totalPoints+player1.getDie1()+player1.getDie2())*player1.mult;
                    //pts=(player1.totalPts()+player1.getDie1()+player1.getDie2())*player1.getMult();
                    //player1.setTpts(pts);
                    //if(player1.getMagic()!=1)
                         //player1.totalPoints=player1.totalPoints+player1.getDie1()+player1.getDie2();
                    //pts=player1.totalPts()+player1.getDie1()+player1.getDie2();
                    //player1.setTpts(pts);
                    p.l("Player 1 has "+player1.numSnakes()+" snake eyes.");
                    p.l("Player 1 earned "+player1.ptsreturn()+" points this turn.");
                    p.l("Player 1 has "+player1.totalPts()+" total points.");
                    pts=0;
                    if(player1.totalPts()>=2000)
                         winner=1;
                         player1.setNv(4);loop=false;
                    if((player1.isavowel(player1.getadice()))&&player1.isavowel(player1.getadice2()))
                         player1.setTpts(0);player1.setNv(0);player1.setNv(4);
               p.l("Player 1's turn has ended...");
               player1.setNv(0);
               p.l("Player 2 rolls the dice...");
               player2.rollDice();
               player2.setTpts(player2.totalPts()+player2.getDie1()+player2.getDie2());
               while(player2.numVowels()<=4)
                    p.l("Player 2 continues his turn...");
                    player2.rollDice();
                    player2.updateTotals();
                    p.l("Player 2 rolled a "+player2.getDie1()+" and a "+player2.getDie2()+" and a '"+player2.getDie3()+"' and a '"+player2.getDie4()+"'");
                    p.l("Player 2 rolled "+player2.currvowels()+" vowels.");
                    p.l("Player 2 has "+player2.totalvowels()+" total vowels.");
                    //if(player1.getMagic()==1)
                    //player1.totalPoints=(player1.totalPoints+player1.getDie1()+player1.getDie2())*player1.mult;
                    //pts=(player1.totalPts()+player1.getDie1()+player1.getDie2())*player1.getMult();
                    //player1.setTpts(pts);
                    //if(player1.getMagic()!=1)
                         //player1.totalPoints=player1.totalPoints+player1.getDie1()+player1.getDie2();
                    //pts=player1.totalPts()+player1.getDie1()+player1.getDie2();
                    //player1.setTpts(pts);
                    p.l("Player 2 has "+player2.numSnakes()+" snake eyes.");
                    p.l("Player 2 earned "+player2.ptsreturn()+" points this turn.");
                    p.l("Player 2 has "+player2.totalPts()+" total points.");
                    pts=0;
                    if(player2.totalPts()>=2000)
                         winner=2;
                         player2.setNv(4);loop=false;
                    if((player2.isavowel(player2.getadice()))&&player2.isavowel(player2.getadice2()))
                         player2.setTpts(0);player2.setNv(0);player2.setNv(4);
               p.l("Player 2's turn has ended...");
               player2.setNv(0);
               if(player1.totalPts()>=2000)
                    winner=1;
                    loop=false;
               if(player2.totalPts()>=2000)
                    winner=2;
                    loop=false;
               }  //main loop
               if(winner==1)
                    p.l("It ended with the following statistics...");
                    p.l("Player 1's score was: "+player1.totalPts()+" and Player 2's score was: "+player2.totalPts());
                    p.l("Player 1 had: "+player1.numSnakes()+" snake eye(s) and Player 2 had: "+player2.numSnakes()+" snake eye(s)");
                    p.l("Player 1 wins, oink oink!");
               if(winner==2)
                    p.l("It ended with the following statistics...");
                    p.l("Player 1's score was: "+player1.totalPts()+" and Player 2's score was: "+player2.totalPts());
                    p.l("Player 1 had: "+player1.numSnakes()+" snake eye(s) and Player 2 had: "+player2.numSnakes()+" snake eye(s)");
                    p.l("Player 2 wins, oink oink!");
and dice class:
import java.util.*;
public class JMM_Dice {
     private static Random gen = new Random();
    private final static int NUM_SIDES = 21;
    private int die1, die2, numSnakeEyes, numVowels, totalPoints;
    private char die3, die4;
    private int dice=0;
       //dice=
       private int dice2=0;
       //dice2=;
       private String adice="";
       //adice=;
       private String adice2="";
       //adice2;
       private int magic=0;
       private int mult=0;
       private int currvowels=0;
       private int totalvowels=0;
  public static EasyReader key = new EasyReader();
  public JMM_Dice()
      dice=0;dice2=0;
       String alpha="abcdefghijklmnopqrstuvwxyz";
      adice="";adice2="";
       rollDice();
       numSnakeEyes=0;numVowels=0;totalPoints=0;
  public void setTpts(int tpts)
       this.totalPoints=tpts;
  public void setNv(int nv)
       this.numVowels=nv;
  public int getDie1()
       return dice;
  public int getDie2()
       return dice2;
  public String getDie3()
       return adice;
  public String getDie4()
       return adice2;
  public int numSnakes()
       return numSnakeEyes;
  public void setSnakes(int s)
       this.numSnakeEyes=s;
  public String getadice()
       return this.adice;
  public String getadice2()
       return this.adice2;
  public int numVowels()
       return numVowels;
  public int getMagic()
       return this.magic;
  public int getNv()
       return this.numVowels;
  public void setMagic(int mag)
       this.magic=mag;
  public int getMult()
       return this.mult;
  public void setMult(int m)
       this.mult=m;
  public int totalPts()
       return totalPoints;
  public String toString()
       return dice+""+dice2+""+adice+""+adice2;
  public boolean isavowel(String str)
       if(str.equals("a")||str.equals("e")||str.equals("i")||str.equals("o")||str.equals("u"))
            return true;
       else
            return false;
  public int ptsreturn()
       return dice+dice2;
  public int currvowels()
       int tmp=currvowels;
       currvowels=0;
       return tmp;
  public int totalvowels()
       return numVowels;
  public void updateTotals()
       if(adice.equalsIgnoreCase("a")||adice.equalsIgnoreCase("e")||adice.equalsIgnoreCase("i")||adice.equalsIgnoreCase("o")||adice.equalsIgnoreCase("u")||adice2.equalsIgnoreCase("a")||adice2.equalsIgnoreCase("e")||adice2.equalsIgnoreCase("i")||adice2.equalsIgnoreCase("o")||adice2.equalsIgnoreCase("u"))
            numVowels++;currvowels++;
       if((isavowel(adice))&&isavowel(adice2))
            totalPoints=0;numVowels=0;
       if(dice==1||dice2==1)
            numSnakeEyes++;
       int fd=dice;
       int sd=dice2;
       int sum=fd+sd;
       totalPoints+=sum*(numSnakeEyes+1);
  public void rollDice()
       dice=gen.nextInt(20)+1;
       dice2=gen.nextInt(20)+1;
       String alpha="abcdefghijklmnopqrstuvwxyz";
       adice=String.valueOf(alpha.charAt(gen.nextInt(26)));
       adice2=String.valueOf(alpha.charAt(gen.nextInt(26)));
  public static void sleep (int wait)
  {     long timeToQuit = System.currentTimeMillis() + wait;
       while (System.currentTimeMillis() < timeToQuit)
            ;   // take no action
}the program works fine except it's supposed to terminate when one of the two AIs get a score of 2000, right now it terminates no matter what score the AIs get and no matter what I've tried to do it keeps doing that...can someone please tell me why it's terminating so oddly? Thanks! :)

Here's how my code works in a nutshell, the main program starts with the boolean loop=true;
               while(loop)
               {then comes the loops for the two AIs, first the player 1 AI goes with this loop: while(player1.numVowels()<=4)
               {there the player 1 roles the dice and it keeps going until player 1 gets a total of 2000 points at which time this is supposed to execute: if(player1.totalPts()>=2000)
                         winner=1;
                         player1.setNv(4);loop=false;
                    }, player1.setNv(4); sets numVowels to 4 so that the inner loop exits, loop=false exits the other loop and winner=1; specifies that player 1 won which is used outside of the loops here: if(winner==1)
                    p.l("It ended with the following statistics...");
                    p.l("Player 1's score was: "+player1.totalPts()+" and Player 2's score was: "+player2.totalPts());
                    p.l("Player 1 had: "+player1.numSnakes()+" snake eye(s) and Player 2 had: "+player2.numSnakes()+" snake eye(s)");
                    p.l("Player 1 wins, oink oink!");
               if(winner==2)
                    p.l("It ended with the following statistics...");
                    p.l("Player 1's score was: "+player1.totalPts()+" and Player 2's score was: "+player2.totalPts());
                    p.l("Player 1 had: "+player1.numSnakes()+" snake eye(s) and Player 2 had: "+player2.numSnakes()+" snake eye(s)");
                    p.l("Player 2 wins, oink oink!");
               } the same thing happens for player 2 if player 1 didn't already get 2000 points...but the if statement despite everything pointing to the variables containing the right values don't seem to be working, as shown by the example program output I posted it just ends at any random number...hopefully this helps make figuring out what's wrong easier :) ...so can anyone please help me out? thanks! :)

Similar Messages

  • Urgent please help, this program should work

    Urgent please help.
    I need to solve or I will be in big trouble.
    This program works at my home computer which is not networked.
    The hard disk was put onto another computer at another location whihc is networked. Here my program worked on Monday 14 october but since for the last two days it is not working without me changing any code. Why do I receive this error message???
    Error: 500
    Location: /myJSPs/jsp/portal-project2/processviewfiles_dir.jsp
    Internal Servlet Error:
    javax.servlet.ServletException
    at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
    at jsp.portal_0002dproject2.processviewfiles_dir_1._jspService(processviewfiles_dir_1.java:162)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java)
    at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
    at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
    at org.apache.tomcat.core.Handler.service(Handler.java:235)
    at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
    at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
    at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
    at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
    at java.lang.Thread.run(Thread.java:536)
    Root cause:
    java.lang.NullPointerException
    at jsp.portal_0002dproject2.processviewfiles_dir_1._jspService(processviewfiles_dir_1.java:132)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java)
    at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
    at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
    at org.apache.tomcat.core.Handler.service(Handler.java:235)
    at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
    at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
    at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
    at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
    at java.lang.Thread.run(Thread.java:536)

    foolishmatt,
    The code is quit large.
    to understand the program I think all the code needs to be examined.
    I would need to send to you in an email.
    Here is my e-mail
    [email protected]
    if you contact me than I can send the code to you.
    Thank you in advance.

  • Please Help!   My error=== 'else' without 'if'

    I am a student trying to figure out what i did wrong. The program looks like it will work to me, but i keep getting this error
    phone_chg.java:24: 'else' without 'if'
    Here is what my code looks like
    import java.util.*;
    public class phone_chg
    static Scanner sc = new Scanner(System.in);
    static final double CONN_FEE = 1.99;
    static final double FIRST_T = 2.00;
    static final double ADD_CHG = .45;
    static final int INCLUDED = 3;
    public static void main(String[] args)
         int mins;
         double ad_mins;
         double chg;
         System.out.println("Please enter the length of the phone call in minutes: ");
         mins = sc.next();
         System.out.println();
         if (mins > INCLUDED)
         ad_mins = mins - INCLUDED;
         chg = (ad_mins * ADD_CHG) + CONN_FEE + FIRST_T;
         else
    chg = CONN_FEE + FIRST_T;
         System.out.printf("Total Fee Assessed: $ %.2f", chg);
    I would really appreciate any help you guys can give me. This is my 4th week of Java Programming and i want to stay on this good start i am.

    Use the braces for your construct. The general for is
    if (someCondition) {
        //  code to run if true
    } else {
        //  code to run if not true
    }http://java.sun.com/docs/books/tutorial/java/nutsandbolts/if.html
    That link should help you.

  • Help, java programs cannot display properly

    Hello,
    I installed redhat 8.0 on my laptop ( Compaq Presario 1120, video
    card ATI Mobility Radeon 9000, not sure, how to check?). Then I
    installed j2re1.4.1, but when I run java program, it can only show
    the frame, just a frame.
    In the terminal, it gave the following message:
    java.lang.InternalError: not implemented yet
    at sun.awt.X11SurfaceData.getRaster(X11SurfaceData.java:155)
    at sun.java2d.loops.OpaqueCopyAnyToArgb.Blit(CustomComponent.java:67)
    at sun.java2d.loops.GraphicsPrimitive.convertFrom(GraphicsPrimitive.java:451)
    at sun.java2d.loops.MaskBlit$General.MaskBlit(MaskBlit.java:186)
    at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:749)
    at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2803)
    at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2793)
    If somebody knows what's the problem, please tell me, thanks!

    I had exactly the same problem with RH8.
    I fixed the swing problem by editing /etc/X11/XF86Config and adding
    the following line in the Screen section:
    DefaultFbBpp     32I restarted X (telinit 3; telinit 5 from root) and SwingSet2
    ran perfectly without any console exceptions.
    Thanks to Juergen Kreileder, Blackdown Java-Linux Team for this

  • Please Help SL - Everything 'quits unexpectedly' and top menu bar flashing

    Please Help. Snow Leopard - Everything 'quits unexpectedly' and top menu bar flashing.
    Basically, I have been using snow leopard for about 1-2 weeks now without any problems, apart from the strange trackpad expose glitch, but I can live with that. But a new problem has arisen that I CANNOT live with. Basically I plugged in my MiniDisplay > VGA adaptor and a Wacom internet tablet for the first time. And when it booted up rather than just the usual spinning gear, their was a progress bar as-well. Then it booted into Safe Mode.?
    Everything was fine in safe mode apart from spotlight didn't work properly so I rebooted and this time it loaded normally. EXCEPT about 5 minutes after I logged on the top menu bar started to flash on and off about ever 1-2 seconds and virtually every single application would quit unexpectedly before even loading. I haven't really looked into it apart from a quick search on google which doesn't seem to bring up anything similar, but atm I am having to use my bootcamp partition with windows installed (shock horror :D) just so I can browse the internet.
    Additional details -
    I have tried resetting PRAM + NVRAM with no joy
    While logging on (before it crashes), menu items (e.g. Airport, Battery Indicator, Facebook Notifier) all load up on the far right BEFORE the clock, which never happened before the problem, don't know if this will help isolate the problem, but its worth mentioning..
    Don't really want to go down the fresh install route if possible, as I did this with leopard about 2 months before Snow Leopard was released

    I noticed it some weeks after installing Snow Leopard, and didn't think much about it since I have a Wacom mouse, and the Wacom driver often has some little peculiarities at startup with the Mac OS--sometimes everything is perfectly ordinary, there will be an OS update and a little oddness shows up, the driver eventually gets updated and the oddness disappears until some other OS update, and so on. I just figured that was what it was until my brother asked about the missing the menu bar after startup, which reappears with a click. He doesn't use a Wacom mouse, but he does have some other 3rd party mouse. I don't know whether 3rd party mouse drivers are at fault or not. But it is not a problem with the SystemUIServer.....the entire menu bar is missing, not just a goof-up on the Spotlight end, where SystemUIServer is in charge of things. Since simply clicking the mouse brings the menu bar up I've never even bothered to check the logs to see if anything is noted there.
    Francine
    Francine
    Schwieder

  • Please help! "activateSettings quit unexpectedly"

    When I turn on my machine - MacBook Pro MAC OS X 10.6.8 I keep getting a message saying: "activateSettings quit unexpectedly". When I scroll through the data on the window, the reason given is: image not found. How do I resolve this issue?
    I can browse online and I can access my files but I cannot adjust volume, change light or brightness etc. Please help!
    I already tried software update - none was available. I did a PRAM reset, nothing improved. I did the holding down of SHIFT key, nothing improved either.

    When I turn on my machine - MacBook Pro MAC OS X 10.6.8 I keep getting a message saying: "activateSettings quit unexpectedly". When I scroll through the data on the window, the reason given is: image not found. How do I resolve this issue?
    I can browse online and I can access my files but I cannot adjust volume, change light or brightness etc. Please help!
    I already tried software update - none was available. I did a PRAM reset, nothing improved. I did the holding down of SHIFT key, nothing improved either.

  • Running Java Program on machine without JKD1.3 loaded

    I have written a Java progam that I want to run on a machine without installing the entire JDK1.3 package. What are the files that must be installed on a machine to run a Java program. We also do not want to run the program through a browser. Can anyone help???

    Thanks --- that was the exact information I needed. I wish I had some Duke dollars left, I would award you some. Well anyway thanks!!!

  • Please help with - program that continues to accept a movie name.. capacity

    Hi
    Could somebody help me to write program
    Write a program that continues to accept a movie name (a max
    of 30 characters), its ticketing capacity, and the number of the tickets sold
    until the user indicates to stop. The program should display the column
    headings given below, the movie name, ticketing capacity, number of tickets
    sold, and number of seats available.
    Sample Input and Output:
    Enter a movie name: Blood Diamond
    Enter its ticketing capacity: 500
    Enter number of the tickets sold: 492
    Additional data (Y/N)? Y
    Enter a movie name: Shooter
    Enter its ticketing capacity: 600
    Enter number of the tickets sold: 600
    Additional data (Y/N)? N
    Movie/Capacity/Tickets Sold/Seats Available
    Blood Diamond/500/492/8           
    Shooter/600/600/0     
    Thanks!

    what do you have so far?He has 10 duke stars to generously award to the first kind soul to do it for him, obviously.
    As an aside, this guy sure hasn't learned much (actually nothing) from the end of last October.
    http://forum.java.sun.com/thread.jspa?threadID=781524
    But he thinks he graduated from "New to Java" to "Java Programming", because now he's posting here.

  • How to run java programs on machines without JDK

    I want to make an installer for my java program that would work on machines even without JDK or Java runtime. How should I go?

    Here's another point.
    There is no particular need to "install" anything to run java. You can simply copy the jre to a directory of your choice, and from that directory invioke the JVM as you need it.

  • Please Help java.policy signedBy can't access file local

    i create keystore and signjar in web applet
    run tomcat access file in local but not acess file denied
    i goto edit file java.policy
    grant {
         permission java.security.AllPermission;
    can access file
    but put SignedBy cannot access file
    grant SignedBy fuangchai{
         permission java.security.AllPermission;
    Please help me example file keystore,applet.jar,java.policy
    to signedby access file local in webapplet
    env JDE 1.5 ,javascript yui 2.8 ,prototype js,tomcat6
    File html
    <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    codebase="http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#Version=5,0,0,5"
    width="1" height="1" >
    <param name=code value="com.arg.aes.test.FileDirectoryBS.class" >
    <param name=archive value="app.jar">
    <param name=codebase value="." >
    <param name="type" value="application/x-java-applet;version=1.5">
    <param name="scriptable" value="true">
    <param name="mayscript" value="true">
    <param name="debug" value="false">
    <comment>
    <embed name="myApplet" id="myApplet"
    type="application/x-java-applet;version=1.5"
    code="com.arg.aes.test.FileDirectoryBS.class"
    archive="app.jar"
    java_codebase="."
    width="1"
    height="1"
    scriptable="true"
    mayscript="true"
    pluginspage="http://java.sun.com/products/plugin/index.html#download">
    <noembed>
    </noembed>
    </embed>
    </comment>
    </object>
    <applet
    code="com.arg.aes.test.FileDirectoryBS"
    width="1"
    height="1"
    archive="app.jar"
    name="myApplet"
    codebase="."
    MAYSCRIPT="true"
    >
    </applet>
    javascript
    initlistfile : function() {
              try
                   var list = $("myApplet").initlistfileInDir();     
                   var jsondata = list.evalJSON();
                   /*alert(jsondata.dirname);
                   alert(jsondata.dirpath);
                   alert(jsondata.listfile.length);*/
                   initTableLeft(jsondata.listfile);
              catch(e)
                   alert("Exception : access denied.");
                   return;
    import java.applet.Applet;
    import java.io.File;
    import java.security.Permission;
    import java.security.PermissionCollection;
    import java.security.Policy;
    import java.security.ProtectionDomain;
    import java.text.DecimalFormat;
    import java.text.NumberFormat;
    import java.util.ArrayList;
    import java.util.Enumeration;
    import java.util.List;
    * @author fuangchai
    public class FileDirectoryBS extends Applet{
    public static File[] ROOTS = File.listRoots();
    public static String HOME = System.getProperty("user.home");
    public String listDir()
    return JsonObj.makeTopDir((ROOTS.length > 0)?ROOTS : new Object[]{HOME});
    public String initlistfileInDir()
    return listfileInDir(null);
    public String listfileInDir(String dirName)
    if(null == dirName || dirName.equals(""))
    System.out.println("root = " + ROOTS.length);
    try {
    dirName = (ROOTS.length > 0)?ROOTS[0].getPath():HOME;
    catch (Exception e) {
    e.printStackTrace();
    return "";
    System.out.println("#########################");
    DirectoryDescImp obj = makeObjDir(dirName);
    return (null == obj)?null:JsonObj.makeDir(obj);
    public String listlinkInDir(String dirName)
    if(null == dirName || dirName.equals(""))
    System.out.println("root = " + ROOTS.length);
    try {
    dirName = (ROOTS.length > 0)?ROOTS[0].getPath():HOME;
    catch (Exception e) {
    e.printStackTrace();
    return "";
    System.out.println("#listlinkInDir#");
    try {
    File obj = new File(dirName);
    return (null == obj)?null:JsonObj.makelinkDir(obj.getName(),obj.getPath());
    } catch (Exception e) {
    System.out.println("I can't access a file here! Access Denied!");
    e.printStackTrace();
    return null;
    public boolean isEnc(File f)
    //TODO
    return false;
    public DirectoryDescImp makeObjDir(String dirName)
    System.out.println("dirName = " + dirName);
    try{
    File dir = new File(dirName);
    String[] entries = dir.list();
    if(null == dir || null == entries || entries.length <= 0)
    System.out.println("Data is null or not obj." );
    return null;
    System.out.println("Dir List = " + dir.list().length);
    System.out.println("Dir Name = " + dir.getName());
    System.out.println("Dir Path = " + dir.getPath());
    DirectoryDescImp dirDesc = new DirectoryDescImp();
    dirDesc.setDirName(dir.getName());
    dirDesc.setDirPath(dir.getPath());
    List<FileDescImp> list = new ArrayList<FileDescImp>();
    for(int i=0; i < entries.length; i++) {
    File f = new File(dir, entries);
    FileDescImp fDesc = new FileDescImp();
    fDesc.setFile(f);
    fDesc.setFileEncrept(isEnc(f));
    list.add(fDesc);
    dirDesc.setListfile(list);
    return dirDesc;
    catch(Exception e){
    System.out.println("I can't access a file here! Access Denied!");
    e.printStackTrace();
    return null;
    Thank you
    Fuangchai Jum
    Mail [email protected]
    Edited by: prositron on Jan 13, 2010 7:35 AM

    OK,
    Let's say I have to intialize Environment, and call method initEnvironment() in Applet's init(). Environment class:
    class Environment
         private KeyStore keyStore;
         private Enumeration<String> aliases;
         public void initEnvironment() {
              Security.addProvider(new sun.security.mscapi.SunMSCAPI());
              keyStore = KeyStore.getInstance("Windows-MY");
              keyStore.load(null);
              aliases = keyStore.aliases();
    }Applet is signed, I trust signer.
    Since Applet is signed I'm able to overwrite existing .java.policy under user.home.
    This doesn't work if I don't have .java.policy:
    grant {
      permission java.security.SecurityPermission "insertProvider.SunMSCAPI";
      permission java.security.SecurityPermission "authProvider.SunMSCAPI";
      permission java.util.PropertyPermission "jsr105Provider", "read";
      permission java.util.PropertyPermission "com.sun.xml.internal.ws.api.pipe.Fiber.serialize", "read";
      permission java.lang.RuntimePermission "setContextClassLoader";
      permission java.util.PropertyPermission "com.sun.xml.internal.ws.api.streaming.XMLStreamWriterFactory.noPool", "read";
      permission java.lang.RuntimePermission "accessDeclaredMembers";
      permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
      permission java.lang.RuntimePermission "accessClassInPackage.com.sun.xml.internal.ws.fault";
      permission java.util.PropertyPermission "com.sun.xml.internal.ws.api.streaming.XMLStreamWriterFactory.woodstox", "read";
    };P.S.
    Does it make sense to be able to make changes to file system and not be able to make actions from above policy?!?!

  • Please Help ~ Java Problems

    Please help me.. I have an error that says in a box that pops up when I start my computer that says this as the Title: "WJViewError" and then this in the middle of the box: "ERROR: java.lang.NoClassDefFoundError" . I don't know how to fix this, maybe I have to re-install something... please help. I can't get into any Yahoo.com free games (Spades) or pogo.com games (Spades). others too, and that's what i want to fix. please post things i should download, i looked around everywhere and can't find anything to help me. my email is [email protected]

    Try reinstall Java or the JRE *Try after reading bottom
    Try install/updateing JRE *Try after reading bottom
    but first try/check the CLASSPATH & PATH variables in autoexec.bat in your c root directory, make sure that (PATH)they point to your jre/bin dir or your javaSDK/bin dir, and make sure CLASSPATH point to class files of java installion. Also, in Control Panel if installed make sure the java console applet handles the java code for your web browser and make sure that the Classpath & path that is in that java console applet points to the correct directories.
    ----- hope that help, Jimdogee

  • Run java programs on computers without a SDK

    Alright. So I wrote a java program on my computer. It has the SDK with JCreator and everything. However, I want to be able to run the program on my Laptop which doesnt have the SDK. It has Java installed yes, but no SDK. How would I run the program? I got the source code but its no use. I have the compilied .class files from my main computer but I have no clue how to run them on the laptop. Do I have ot install the SDK and compile the source code or is there a way to just run the program directly?
    Thanks!

    Basically you just make certain that the manifest file has a "Main-Class" attribute, which is the name of a class that has the main() method that you want to invoke when the use double-clicks the jar. It's remarkably simple.
    I've never used JCreator, but if it's an IDE for Java it probably has a way to create these automatically. In Eclipse, you use the "Export" menu item on the "File" menu; it may be something similar in JCreator.
    Otherwise, you can use the "jar" utility that's part of the SDK. Read the docs on that. The docs also have links to the jar format and manifest files.

  • Please help... For some reason I can not import any photos on to my elements 10 organier.

    Please help... I can not import any photos on to my elements 10 organizer, it is saying files corrupt!!!!! What do I do?????  I have am using an apple, and i usually always get photos from iphoto but it is just not doing it. Please help!

    How are you trying to import the files? Are you using the import from iphoto command? What happens if you export the photos from iphoto to the desktop and use from files and folders? Does it work that way?

  • Help please with java programming

    ok so i need a little help on getting started on this program.
    i need to make a program where the user can enter the last names of candidates and the votes recieved by each candidate. then the program should output both the candidates names and the total votes recieved by each candidate and the perctage of votes each recieved.
    can anyone help me get started with some sample code. thanks.

    ok so this is what i have so far . . . . it goes through the array and works.
    im suppose to also have these two methods . . .
    sumVotes- Which will receive the votes array by reference.
    Calculate the total votes.- Return the calculated integral total votes.winnerIndex- Which will receive the votes array by reference.- Identify the top candidate who received more votes. - Return the identified index.
    my program is suppose to do this . . .The program should then output each candidate?s name, votes received by that candidate, and the percentage of the total votes received by the candidate. The program should also output the winner of the election.
    ok so anyone out there nice enough to tutor me through making these 2 methods i need?
    here is code of what i have so far
    package assign11942;
    import javax.swing.*;
    public class Assign11942 {
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              String strLast[],strNumCand, strVotes[];
              int numCand;
              double votes[], percentage, totalVotes[];
              strNumCand = JOptionPane.showInputDialog("Enter Number of Candidates: ");
              numCand = Integer.parseInt(strNumCand);
              strLast=new String[numCand];
              strVotes=new String[numCand];
              votes=new double[numCand];
              totalVotes=new double[numCand];
              for (int i =0 ; i < numCand; i++)  {
                   strLast= JOptionPane.showInputDialog("Enter Candidates Last Name: ");
                   strVotes[i]=JOptionPane.showInputDialog("Enter Number of Votes: ");

  • Please Help! - Program changes photo colours automatically when photos uploaded?

    I use photoshop elements 2.0.
    When I upload photos the program automatically changes the photo colours to a duller shade across the whole photo... brighter rich colours are lost.
    (i have tested that it isnt just that the colours appear different in photoshop but not when saved by uploading photos into photoshop, doing nothing to them but save it, then compare the original and the saved photo - the colours differ significantly.)
    Restoring the original colours is difficult but I attempt to get close using the Enhance - adjust brightness/ contrast.
    I am sure that this isn't a universal program fault so perhaps one of my settings is wrong?? It has done it since I bought it but up to now I have lived with it however it is really starting to put me off using photoshop when the striking natural colours are lost.
    I am sure other photographers dont have this problem so there must be something i can do to solve it.
    Please any help would be grately appreciated as to why this may be happening
    Amy

    This is not a Photography issue but an application specific question.  Try posting in the Photoshop Elements forum:
    http://forums.adobe.com/community/photoshop_elements
    If you're lucky, you'll find someone there who still remembers that ancient version of Elements.  Currently they're at version 9.

Maybe you are looking for