Jave help MEGA PLEASE

k so heres the first program
The game of Nim has two players alternately taking marbles from a pile. In each move the player must take at least one marble, but at most half of the marbles in the pile. The player who takes the last marble loses. Write a program in which the computer plays against a human opponent. Generate a random integer between 10 and 100 (inclusively) to denote the initial size of the pile of marbles. Generate a random integer between 0 and 1 to decide whether or the computer or the human takes the first turn. Generate a random integer between 0 and 1 to decide whether the computer plays smart or stupid. In stupid mode, the computer simply takes a random legal value between 1 and n/2 from the pile whenever it has a turn. In smart mode, the computer takes off enough marbles to make the size of the pile a power of 2 - 1 ---that is, 3, 7, 15, 31, or 63. That is always a legal move, except if the size of the pile is one less than a power of 2. In that case the computer makes a random legal move. Note that the computer can not be beaten in smart mode when it has the first move, unless the pile size happens to be 15, 31, or 63.
heres the class code
code:--------------------------------------------------------------------------------/*
* @(#)Nim.java 1.0 03/07/02
* Name: Alex Ionescu
* Period: 1
* Date: 9/18/03
* Assignment: Nim
* Purpose: Program Nim game in Java
package n;
import javax.swing.JOptionPane;
import java.util.Random;
import java.lang.Math;
import java.lang.String;
class Nim
     private int pile;
     private int turn;
     private int firstturn;
     private int stupid;
     private int smart;
     private int computer;
     private int user;
     private int first;
     public Nim()
          pile=(int)(Math.random()*90+10);
          smart=(int)(Math.random()*100);
          stupid=(int)(Math.random()*100);
          System.out.println("Pile size is "+pile);
          firstturn=(int)(Math.random()*100 + 1); //heres the 1/100 error
          computer=0;
          user=1;
          if(firstturn>50)
               firstturn=user;
          else
               firstturn=computer;
          firstturn=turn;
     public void play()
          if(smart>50)
               System.out.println("Computer is playing smart");
          else
               System.out.println("Computer is playing stupid");
          if(firstturn==user)
               System.out.println("You go first");
          else
               System.out.println("Computer goes first");
turn = firstturn;
          while(pile-1>0)
               if(turn==user)
                    String take = JOptionPane.showInputDialog("How many marbles do you want to take away?");
                    int take2= Integer.parseInt(take);
                    while(take2>(int)(pile/2))
                         JOptionPane.showMessageDialog(null, "Only take away half or less from the pile");
                         take = JOptionPane.showInputDialog("How many marbles do you want to take away?");
                         take2= Integer.parseInt(take);
                    pile= pile-take2;
                    System.out.println("There are "+pile+" marbles left");
                    turn=computer;
               else
                    if(smart>50)
                         pile -= smartTake();
                    else
                         pile -= stupidTake();
               turn=user;
     private int smartTake()
          int x = (int)(Math.random())*2-1;
          int sMarbles= (int)Math.pow(2,x);
          while (sMarbles > (.5 * pile) || sMarbles==0)
               x = (int)(Math.random())*2-1;
               sMarbles = (int)Math.pow(2,x);
               System.out.println("The computer took away " + sMarbles +" marbles");
               return sMarbles;
     private int stupidTake()
          int stMarbles = pile/2;
          while (stMarbles > (.5*pile) || pile==0)
                    stMarbles = pile/2;
          System.out.println("The Computer took away " + stMarbles +" marbles");
          return stMarbles;
the smartTake method is fucked because i just tried to make some shitty method to turn in so i had a grade
my errors are here...
in stupidTake method "In stupid mode, the computer simply takes a random legal value between 1 and n/2 from the pile whenever it has a turn."
im just plain stumped on this one
next error is in smart take.. it should take enough marbles away to make the size of the pile a power of 2 -1, which is 3, 7, 15, 31, or 63
i had something in mind like if pile>63 sMarbles = pile-63; pile=63;
but i did want to do it without making a bunch of if statements (think i might have to)
also in my constructor, i have firstturn Math.random() * 100 +1 but the user should only go first once in 100 turns, so this is fucked

k heeres the second program help
heres the driver
*@(#)Decode.java 1.0 03/12/10
*@author Alex Ionescu
*@since             Date 03/12/10
*@period 1
*@assignment Topic 6 Lab 1
*@purpose Replicate the postal service's method of translating bar codes and zip codes
package bar;
import javax.swing.JOptionPane;
class BarCodeDriver
     public static void main(String args[])
          String ask = JOptionPane.showInputDialog("Please enter a zipcode or barcode");
          Decode b = new Decode();
          Encode a = new Encode();
          char whatever = ask.charAt(0);
          if(whatever>=48 && whatever <=57)
               a.Encoding(ask);
          else
               if(whatever=='|')
                    b.Decoding(ask);
               else
                    JOptionPane.showMessageDialog(null, "You didn't enter a zipcode or barcode, please try again");
          System.out.println(" ");
          System.exit(0);          
}and the class
*@(#)Decode.java 1.0 03/12/10
*@author Alex Ionescu
*@since             Date 03/12/10
*@period 1
*@assignment Topic 6 Lab 1
*@purpose Replicate the postal service's method of translating bar codes and zip codes
package bar;
import javax.swing.JOptionPane;
class Decode
     private String Barcode;
     private int Digit;
     private int zipcode;
     private int count;
     private int startstring;
     private int endstring;
     private String digit;
     public Decode()
          count = 0;
          startstring = 1;
          endstring = 6;
          Digit = 0;
          zipcode= 0;
     //pre- expect 27 lines long barcode
     //post- return the barcode translated into a zipcode
     public void bartonum(String digit)
          if(digit.equals("||:::"))
               Digit=0;     
          else
               if(digit.equals(":::||"))
                    Digit=1;
                    else
                         if(digit.equals("::|:|"))
                              Digit=2;
                         else
                              if(digit.equals("::||:"))
                                   Digit=3;
                              else
                                   if(digit.equals(":|::|"))
                                        Digit=4;
                                   else
                                        if(digit.equals(":|:|:"))
                                             Digit=5;
                                        else
                                             if(digit.equals(":||::"))
                                                  Digit=6;
                                             else
                                                  if(digit.equals("|:::|"))
                                                       Digit=7;
                                                  else
                                                       if(digit.equals("|::|:"))
                                                            Digit=8;
                                                       else
                                                            if(digit.equals("|:|::"))
                                                                 Digit=9;
          System.out.print(Digit);
          zipcode= Digit + zipcode;
     //pre- expect a barcode with checkdigit,
     //post- return the bar code in zip code form     
     //convert barcode
     public void Decoding(String b)
          //Barcode = JOptionPane.showInputDialog("Please enter a bar code");               
          String digit = b.substring(startstring,endstring);
          for(count=0;count<=4;count++)
               bartonum((digit));
               startstring+=5;
               endstring+=5;
               digit = b.substring(startstring,endstring);
          //store sum of zipcode and checkdigit
          int woah = zipcode + Digit;
          //check to see if checkdigit is right
          if(woah % 10 == 0)
               System.out.println("...is the zipcode");
          else
               System.out.println("...that is not a correct bar code");
}it prints out this
11111Exception in thread "main" java.lang.StringIndexOutOfBoundsException: Strin
g index out of range: 31
at java.lang.String.substring(String.java:1477)
at bar.Decode.Decoding(Decode.java:123)
at bar.BarCodeDriver.main(BarCodeDriver.java:30)
its suppose to print out the 11111 but not the exception lol;

Similar Messages

  • Java help needed(PLEASE)

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

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

  • Too large java heap error while starting the domain.Help me please..

    I am using weblogic 10.2,after creating the domain, while starting the domain,I am getting this error.Can anyone help me.Please treat this as urgent request..
    <Oct 10, 2009 4:09:24 PM> <Info> <NodeManager> <Server output log file is "/nfs/appl/XXXXX/weblogic/XXXXX_admin/servers/XXXXX_admin_server/logs/XXXXX_admin_server.out">
    [ERROR] Too large java heap setting.
    Try to reduce the Java heap size using -Xmx:<size> (e.g. "-Xmx128m").
    You can also try to free low memory by disabling
    compressed references, -XXcompressedRefs=false.
    Could not create the Java virtual machine.
    <Oct 10, 2009 4:09:25 PM> <Debug> <NodeManager> <Waiting for the process to die: 29643>
    <Oct 10, 2009 4:09:25 PM> <Info> <NodeManager> <Server failed during startup so will not be restarted>
    <Oct 10, 2009 4:09:25 PM> <Debug> <NodeManager> <runMonitor returned, setting finished=true and notifying waiters>

    Thanks Kevin.
    Let me try that.
    Already more than 8 domains were successfully created and running fine.Now the newly created domain have this problem.I need 1GB for my domain.Is there any way to do this?

  • Hello Sorry for the inconvenience, but I have a problem in Java I can not open files, audio chat, which type of jnlp after the last update of the Java 2012-004 Please help me in solving this problem.

    Hello Sorry for the inconvenience, but I have a problem in Java I can not open files, audio chat, which type of jnlp after the last update of the Java 2012-004
    Please help me in solving this problem. 

    Make sure Java is enable in your browser's security settings.
    Open Java Preferences (in Utilities folder)
    Make sure Web-start applications are enabled.
    Drag Java 32-bit to the top of the list.
    jnlp isn't an audio file format. It's just a java web-start program (Java Network Launching Protocol).

  • Please tell me some conversion tools to generate java help

    hello,
    I am doing some project of migration, and I need some tools to convert from windows help file (chm) to java help file.
    Anyone has some experience of that?
    If not possible, what's the fastest way to do the conversion?
    Thanks

    Hello,
    You don't mention what format the source files are in, so I'm assuming that you only have access to the actual .chm files and not whatever those were created from. Given that, you'll need a tool that is capable of backward converting Help output into some source format, and then converting that to JavaHelp. I don't know of anything that would convert directly from .chm to JavaHelp.
    I believe that RoboHelp is capable of taking Window Help output and converting it backwards to source, and it is also supports JavaHelp, so this would be one tool to investigate.
    HelpBreeze is another tool that supports both formats and is also a lot cheaper that RoboHelp.
    I apologize for not having first-hand experience with either of these. We currently use a CMS tool, AuthorIT, to single source publish to JavaHelp and other outputs.

  • Can anyone help me, please

    Hello again:
    Please run my coding first, and get some view from my coding.
    I want to add a table(it is from TableRenderDemo) to a JFrame when I click on the button(from DrawCalendar) of the numer 20, and I want the table disply under the buttons(from DrawCalendar), and the table & buttons all appear on the frame. I added some code for this problem(in the EventHander of the DrawCalendar class), but I do
    not known why it can not work.Please help me to solve this problem.
    Can anyone help me, please.
    Thanks.
    *This program for add some buttons to JPanel
    *and add listeners to each button
    *I want to display myTable under the buttons,
    *when I click on number 20, but why it doesn't
    *work, The coding for these part are indicated by ??????????????
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.GridLayout;
    public class DrawCalendar extends JPanel {
         private static DrawCalendar dC;
         private static TestMain tM;
         private static TableRenderDemo myTable;
         private static GridLayout gL;
         private static final int nlen = 35;
        private static String names[] = new String[nlen];
        private static JButton buttons[] = new JButton[nlen];
         public DrawCalendar(){
              gL=new GridLayout(5,7,0,0);
               setLayout(gL);
               assignValues();
               addJButton();
               registerListener();
        //assign values to each button
           private void assignValues(){
              names = new String[35];
             for(int i = 0; i < names.length; i++)
                names[i] = Integer.toString(i + 1);
         //create buttons and add them to Jpanel
         private void addJButton(){
              buttons=new JButton[names.length];
              for (int i=0; i<names.length; i++){
                   buttons=new JButton(names[i]);
         buttons[i].setBorder(null);
         buttons[i].setBackground(Color.white);
         buttons[i].setFont(new Font ("Palatino", 0,8));
    add(buttons[i]);
    //add listeners to each button
    private void registerListener(){
         for(int i=0; i<35; i++)
              buttons[i].addActionListener(new EventHandler());          
    //I want to display myTable under the buttons,
    //when I click on number 20, but why it doesn't
    //work
    private class EventHandler implements ActionListener{
         public void actionPerformed(ActionEvent e){
         for(int i=0; i<35; i++){
    //I want to display myTable under the buttons,
    //when I click on number 20, but why it doesn't
    //work
         if(i==20){  //???????????               
              tM=new TestMain(); //???????
              tM.c.removeAll(); //??????
              tM.c.add(dC); //???????
              tM.c.add(myTable); //????
              tM.validate();
         if(e.getSource()==buttons[i]){
         System.out.println("testing " + names[i]);
         break;
    *This program create a table with some data
    import javax.swing.table.AbstractTableModel;
    import javax.swing.table.TableColumn;
    import javax.swing.DefaultCellEditor;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.table.DefaultTableCellRenderer;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class TableRenderDemo extends JScrollPane {
    private boolean DEBUG = true;
    public TableRenderDemo() {
    // super("TableRenderDemo");
    MyTableModel myModel = new MyTableModel();
    JTable table = new JTable(myModel);
    table.setPreferredScrollableViewportSize(new Dimension(700, 70));//500,70
    //Create the scroll pane and add the table to it.
    setViewportView(table);
    //Set up column sizes.
    initColumnSizes(table, myModel);
    //Fiddle with the Sport column's cell editors/renderers.
    setUpSportColumn(table.getColumnModel().getColumn(2));
    * This method picks good column sizes.
    * If all column heads are wider than the column's cells'
    * contents, then you can just use column.sizeWidthToFit().
    private void initColumnSizes(JTable table, MyTableModel model) {
    TableColumn column = null;
    Component comp = null;
    int headerWidth = 0;
    int cellWidth = 0;
    Object[] longValues = model.longValues;
    for (int i = 0; i < 5; i++) {
    column = table.getColumnModel().getColumn(i);
    try {
    comp = column.getHeaderRenderer().
    getTableCellRendererComponent(
    null, column.getHeaderValue(),
    false, false, 0, 0);
    headerWidth = comp.getPreferredSize().width;
    } catch (NullPointerException e) {
    System.err.println("Null pointer exception!");
    System.err.println(" getHeaderRenderer returns null in 1.3.");
    System.err.println(" The replacement is getDefaultRenderer.");
    comp = table.getDefaultRenderer(model.getColumnClass(i)).
    getTableCellRendererComponent(
    table, longValues[i],
    false, false, 0, i);
    cellWidth = comp.getPreferredSize().width;
    if (DEBUG) {
    System.out.println("Initializing width of column "
    + i + ". "
    + "headerWidth = " + headerWidth
    + "; cellWidth = " + cellWidth);
    //XXX: Before Swing 1.1 Beta 2, use setMinWidth instead.
    column.setPreferredWidth(Math.max(headerWidth, cellWidth));
    public void setUpSportColumn(TableColumn sportColumn) {
    //Set up the editor for the sport cells.
    JComboBox comboBox = new JComboBox();
    comboBox.addItem("Snowboarding");
    comboBox.addItem("Rowing");
    comboBox.addItem("Chasing toddlers");
    comboBox.addItem("Speed reading");
    comboBox.addItem("Teaching high school");
    comboBox.addItem("None");
    sportColumn.setCellEditor(new DefaultCellEditor(comboBox));
    //Set up tool tips for the sport cells.
    DefaultTableCellRenderer renderer =
    new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for combo box");
    sportColumn.setCellRenderer(renderer);
    //Set up tool tip for the sport column header.
    TableCellRenderer headerRenderer = sportColumn.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer) {
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText(
    "Click the sport to see a list of choices");
    class MyTableModel extends AbstractTableModel {
    final String[] columnNames = {"First Name",
    "Last Name",
    "Sport",
    "# of Years",
    "Vegetarian"};
    final Object[][] data = {
    {"Mary ", "Campione",
    "Snowboarding", new Integer(5), new Boolean(false)},
    {"Alison", "Huml",
    "Rowing", new Integer(3), new Boolean(true)},
    {"Kathy", "Walrath",
    "Chasing toddlers", new Integer(2), new Boolean(false)},
    {"Sharon", "Zakhour",
    "Speed reading", new Integer(20), new Boolean(true)},
    {"Angela", "Lih",
    "Teaching high school", new Integer(4), new Boolean(false)}
    public final Object[] longValues = {"Angela", "Andrews",
    "Teaching high school",
    new Integer(20), Boolean.TRUE};
    public int getColumnCount() {
    return columnNames.length;
    public int getRowCount() {
    return data.length;
    public String getColumnName(int col) {
    return columnNames[col];
    public Object getValueAt(int row, int col) {
    return data[row][col];
    * JTable uses this method to determine the default renderer/
    * editor for each cell. If we didn't implement this method,
    * then the last column would contain text ("true"/"false"),
    * rather than a check box.
    public Class getColumnClass(int c) {
    return getValueAt(0, c).getClass();
    * Don't need to implement this method unless your table's
    * editable.
    public boolean isCellEditable(int row, int col) {
    //Note that the data/cell address is constant,
    //no matter where the cell appears onscreen.
    if (col < 2) {
    return false;
    } else {
    return true;
    * Don't need to implement this method unless your table's
    * data can change.
    public void setValueAt(Object value, int row, int col) {
    if (DEBUG) {
    System.out.println("Setting value at " + row + "," + col
    + " to " + value
    + " (an instance of "
    + value.getClass() + ")");
    if (data[0][col] instanceof Integer
    && !(value instanceof Integer)) {
    //With JFC/Swing 1.1 and JDK 1.2, we need to create
    //an Integer from the value; otherwise, the column
    //switches to contain Strings. Starting with v 1.3,
    //the table automatically converts value to an Integer,
    //so you only need the code in the 'else' part of this
    //'if' block.
    try {
    data[row][col] = new Integer(value.toString());
    fireTableCellUpdated(row, col);
    } catch (NumberFormatException e) {
    JOptionPane.showMessageDialog(TableRenderDemo.this,
    "The \"" + getColumnName(col)
    + "\" column accepts only integer values.");
    } else {
    data[row][col] = value;
    fireTableCellUpdated(row, col);
    if (DEBUG) {
    System.out.println("New value of data:");
    printDebugData();
    private void printDebugData() {
    int numRows = getRowCount();
    int numCols = getColumnCount();
    for (int i=0; i < numRows; i++) {
    System.out.print(" row " + i + ":");
    for (int j=0; j < numCols; j++) {
    System.out.print(" " + data[i][j]);
    System.out.println();
    System.out.println("--------------------------");
    *This program for add some buttons and a table on JFrame
    import java.awt.*;
    import javax.swing.*;
    public class TestMain extends JFrame{
    private static TableRenderDemo tRD;
         private static TestMain tM;
    protected static Container c;
    private static DrawCalendar dC;
         public static void main(String[] args){
         tM = new TestMain();
         tM.setVisible(true);
         public TestMain(){
         super(" Test");
         setSize(800,600);
    //set up layoutManager
    c=getContentPane();
    c.setLayout ( new GridLayout(3,1));
    tRD=new TableRenderDemo();
    dC=new DrawCalendar();
    addItems();//add Buttons to JFrame
    private void addItems(){
         c.add(dC); //add Buttons to JFrame
         //c.add(tRD); //add Table to JFrame     

    Click Here and follow the steps to configure your Linksys Router with Version FIOS.

  • A serious question  ,could someone help me please just a little problem

    this is a program to let me open a file and read birthday and related name, and then type name we can fetch the birthday, everything is ok ,whenever i input a name, it always find nothing, can some experts help me please
    there are three class i defined, one is birth_reader, another is date to record the date have been read from specified file, one is the name stored firstname and last name, the file my lecture give me is just a simple txt file which is example like:
    1 31 1984 robin ralu
    i realised maybe i shoud add a equals() to test ,but how can i do that , i have really no idea
    please
    import java.util.Scanner.*;
    import java.util.*;
    import java.io.*;
    public class birth_reader
    public static void main(String[] args)throws IOException
    birth_reader haha=new birth_reader();
    Map <name,date> book=new HashMap<name,date>();
    Scanner input=new Scanner(System.in);
    name b;
    FileReader fin = new FileReader("birthday.txt");
    Scanner sc = new Scanner(fin);
    while(sc.hasNext())
    int cat=sc.nextInt();
    int cta=sc.nextInt();
    int atc=sc.nextInt();
    String first_name=sc.next();
    String last_name=sc.next();
    date a=new date(cat,cta,atc);
    b=new name(first_name,last_name);
    book.put(b,a);
    System.out.println(book);
    System.out.println("please enter the name");
    String f=input.next();
    String l=input.next();
    b.firstname=f;
    b.lastname=l;
    date p=book.get(b);
    if((p!=null))
    System.out.println(b+":"+p);
    else{ System.out.println("no person here"+" "+b);
    public class name
    String firstname,lastname;
    public name(String firstname,String lastname)
    this.firstname=firstname;
    this.lastname=lastname;
    public String toString()
    return firstname+" "+lastname;
    public class date
    int year,month,day;
    public date(int year,int month,int day)
    this.year=year;
    this.month=month;
    this.day=day;
    public String toString()
    return year+" "+month+" "+day;
    public int getyear()
    return year;
    public int getmonth()
    return month;
    public int getday()
    return day;
    }

    Why do you suppose you should add an equals method?
    In what class would you add it?
    How would that change the behaviour of your code?
    What else should you keep in mind when overriding equals?

  • XSLT Mapping : RFC Lookup using java helper class

    Hi All,
    I am doing RFC Lookup in xslt mapping using java helper class. I have found blog for the same (http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/05a3d62e-0a01-0010-14bc-adc8efd4ee14) However this blog is very advanced.
    Can anybody help me with step by step approach for the same?
    My basic questions are not answered in the blog as:
    1) where to add the jar file of the java class used in xslt mapping.
    I have added zip file of XSLT mapping in imported archived and using that in mapping.
    Thanks in advace.
    Regards,
    Rohan

    Hi,
    Can u please have look at this in detail , u can easily point out yourself the problem...
    http://help.sap.com/saphelp_nw04/helpdata/en/55/7ef3003fc411d6b1f700508b5d5211/content.htm
    Please observe the line,
    xmlns:javamap="java:com.company.group.MappingClass
    in XSLT mapping..
    The packagename of class and class name and XSLT namespace should be matching...
    Babu
    Edited by: hlbabu123 on Sep 29, 2010 6:04 PM

  • How to set the CLASSPATH for an  Sql Server 2005 database... help me please

    Hello! Guys I want to access a Sql Server 2005 database from Java.I've downloaded the JDBC 2.0 driver from Microsoft.I've copied the sqljdbc4.jar file to C:\Java\jdk1.6.0_14\db\lib.And I've added this to the classpath C:\Java\jdk1.6.0_14\db\lib\sqljdbc4.jar.The classpath variable is defined as a user variable.Well the point is that I get that nasty exception:Exception in thread "main" java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver.So if you know how to help me,please do so.Thank you :)

    Hi Timo,
    My jdev version is 10.1.3.3.0, this is for R12. By PR i mean to say process request and PFR process form request in the controller.
    In the Process request of the controller, i am finding the checkbox bean and assigning the firepartialaction for it.
    Later in the process form request for the fired event, i am trying to handle the rendered property of the messagetextinput. Is this a right approach?
    my code below
    public void processRequest(OAPageContext oapagecontext, OAWebBean oawebbean)
    super.processRequest(oapagecontext, oawebbean);
    OAApplicationModule oaapplicationmodule = oapagecontext.getApplicationModule(oawebbean);
    OAMessageCheckBoxBean oamessagecheckboxbean = (OAMessageCheckBoxBean)oawebbean.findChildRecursive("X_FLAG");
    if(oamessagecheckboxbean != null)
    oapagecontext.writeDiagnostics(this, "Message check box Bean found:", 1);
    FirePartialAction firepartialaction = new FirePartialAction("change");
    oamessagecheckboxbean.setAttributeValue(PRIMARY_CLIENT_ACTION_ATTR, firepartialaction);
    oamessagecheckboxbean.setFireActionForSubmit("change", null, null, true);
    oapagecontext.writeDiagnostics(this, "setting fire event", 1);
    public void processFormRequest(OAPageContext oapagecontext, OAWebBean oawebbean)
    super.processFormRequest(oapagecontext, oawebbean);
    oapagecontext.writeDiagnostics(this, "Inside Process Form Request", 1);
    if("change".equals(oapagecontext.getParameter(OAWebBeanConstants.EVENT_PARAM)))
    OAMessageTextInputBean bean = (OAMessageTextInputBean)oawebbean.findChildRecursive("X_NUMBER");
    if(bean!=null){
    bean.setRendered(Boolean.TRUE);}
    Thanks,
    Malar

  • Help me please~ non-static variable rs cannot be referenced ...

    i make counter
    but this error occurrence
    only i doing resultset make and closed
    why non-static variable rs ....
    i am sorry i don't speak English ...
    help me please..
    error message
    non-static variable rs cannot be referenced from a static context
    source
    ===============================================
    package jjaekim;
    import java.sql.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class Count{
              Statement stmt;
              ResultSet rs;
              ResultSet rs2;
              Connection conn;
              //DBPoolManager dbpm;
         public static String add(HttpServletRequest request){
              try{
                        int year =0;
                        int month=0;
                        int date =0;
                        int hour =0;
                        int min     =0;
                        int week =0;
                        String str_date=new String();
                        String str_time=new String();
                        String referer_url     =request.getHeader("Referer");
                        String infomation     =request.getHeader("User-Agent");
                        String ip               =request.getRemoteAddr();
                        int access_date=0;
                        int access_time=0;
                        Calendar cal     =Calendar.getInstance();
                        year               =cal.get(cal.YEAR);
                        month               =cal.get(cal.MONTH) + 1;
                        date               =cal.get(cal.DATE);
                        hour               =cal.get(cal.HOUR_OF_DAY);
                        min                    =cal.get(cal.MINUTE);
                        week               =cal.get(cal.DAY_OF_WEEK);
                        access_date          =(month*100)+date;
                        access_time          =(hour*100)+min;
                        if(access_date<1000)
                             str_date="0"+new Integer(access_date).toString();
                        else
                             str_date=new Integer(access_date).toString();
                        if(access_time<100)
                             str_time="0"+new Integer(access_time).toString();
                        else
                             str_time="0"+new Integer(access_time).toString();
                   }catch(Exception e){
                        //System.out.print("Exc"+e.getMessage());
                        //return false;
                   finally{
                             if(rs!=null){
                                  try{     rs.close();}catch(Exception e){}
                             if(rs2!=null){
                                  try{     rs2.close();}catch(Exception e){}
                             if (stmt!=null){
                                  try{     stmt.close();}catch(Exception e){}
                             //if (conn!=null){
                                  try{     conn.close(); }catch(Exception e){}
                        //return back;
    /*     public static void main(String[] args)
              System.out.println("Hello World!");

    Hello jjaekim,
    if rs is a class variable (the same value for all objects),
    try this (more likely to be the right solution) :
    static ResultSet rs;
    instead of :
    ResultSet rs;
    if rs has a different values in different objects,
    then you should add the object name when using it like this :
    myObject.rs or this.rs

  • Can not run jcwde (Somebody help me please !)

    Hi all, I'm a newbie in java card development.
    Let's get to the point. I have some problem with jcwde and I've been searching for the similar problems in this forum such as : here here and here here
    Other sources that I've referred to is : here and here
    I'm trying to set environment variable for java card development.
    Before running jcwde, i also run samples_build.bat but I don't know whether it OK or not.
    When I try to run jcwde for testing demo file (I type : jcwde -jcwde.app in command prompt) the only message that i got is :
    C:\java_card_kit-2_1_2\samples\src\demo>jcwde jcwde.app
    'C:\Program' is not recognized as an internal or external command, operable program or batch files
    Is there any problem with my enviromnent variables setting ? since I'm not sure how to fix it
    here is mine :
    JAVA_HOME : C:\Program Files\Java\jdk1.5.0_04
    JC21_HOME : C:\java_card_kit-2_1_2
    CLASSPATH : .;C:\java_card_kit-2_1_2\lib\api21.jar
    PATH : C:\Program Files\Java\jdk1.5.0_04\bin;C:\java_card_kit-2_1_2\bin
    Oh yeah, I almost forgotten that I'm using Windows XP Professional Edition SP 1, and Java Card Development Kit 2.1.2
    Can somebody help me please or maybe give me advice about what I'm doing is right or wrong ?
    Thanks in advance,
    Best Regards,
    iCH1
    Edited by: ichiwan on Mar 12, 2008 10:00 PM

    dear kicklee,
    Thank you for your response to the topic. By the way, do you mean that all CLASSPATH variable must not be more than 8 characters ?
    I just did it, but still the same error occur.
    Is there any solution for this ?
    I need you to copy-paste all your succesfull CLASSPATH configuration here for better explanation.
    thx in advance.
    Best Regards,
    iCH1
    Edited by: ichiwan on Mar 18, 2008 8:09 AM
    Edited by: ichiwan on Mar 18, 2008 8:13 AM
    Edited by: ichiwan on Mar 18, 2008 8:15 AM

  • How to run robocode? Help me please

    Hi everyone,
    I try to develop java applets and programs for a software development course.
    We have to work with the software called "Robocode" which a program about writing codes to see little robots fighting each other.
    Actually my real problem is that when I launch the file robocode.command I just have an error message saying "The file “robocode.command” could not be executed because you do not have appropriate access privileges."
    Did one of you ever met this type of problem? if yes help me please because even by creating a super user account nothing worked and to say the truth I'm really disappointed about that.
    Thank you =)

    Actually my real problem is that when I launch the file robocode.command I just have an error message saying "The file “robocode.command” could not be executed because you do not have appropriate access privileges."
    Under Mac OS X any file that ends with .command is assumed to be a double-clickable Unix shell script. However, the file needs to have the Unix execute permissions bit set.
    Applications -> Utilities -> Terminal
    chmod +x robocode.command
    I'm not sure any of the Apple discussion forum would be idea for discussing "RoboCode", however, the closest might be something like Mac OS X Technologies -> Software Development 101
    <http://discussions.apple.com/forum.jspa?forumID=728>
    If there are Unix specific questions, such as setting the execute permission bit on robocode.command file, then the Unix forum would be the best place to ask
    <http://discussions.apple.com/forum.jspa?forumID=735>

  • Special double quotes and apostrophes in java help

    We are writing help for an application and using doctor help to generate it. The help is written in Word and converted to html. Word however, converts all the " characters to those "squiggly ones" which point towards the word they're quoting.
    When we viewed the generated help with java help those squiggly were not rendered. They are rendered as a square which means java help does not understand them.
    I'm sure someone else must have encountered this issue.
    Please can you tell me how to successfully render the squiggly double quotes in java help?

    You need the following encoding for those characters:
    &#8220;
    &#8221;
    using an xml encoder, e.g. xmlenc solves this issue, otherwise you must do it manually.
    But I have a related problem. When characters in the XML file are encoded
    they are only displayed correctly if some non encoded character follows.
    When there are two successive encoded characters then only the first one
    is displayed correctly. Putting a whitespace in between them displays both
    characters correctly, but with the whitespace in between.
    I guess there is an issue with the XML parser. Changing the encoding of the XML file does not help.
    example: TOC.xml file (displayed correctly in IE)
    <?xml version='1.0' encoding='ISO-8859-9' standalone='yes' ?>
    <!DOCTYPE toc PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp TOC Version 1.0//EN" "http://java.sun.com/products/javahelp/toc_1_0.dtd"><!--generated by JHelpDev Version: 0.4, 18 August 2005, see jhelpdev.sourceforge.net-->
    <toc version="1.0">
    <tocitem text="images "/>
    <tocitem text="&#286;&#286;RENC&#304; MOD&#220;L&#220; " target="index"/>
    </toc>
    Any ideas?

  • Reading Modbus (Help me PLEASE!!!)

    Hi everyone. Can anyone HELP me PLEASE ! I�m trying to communicate Java with a PLC using ModBus protocol (RTU - Remote Terminal Unit). I�m working with java.comm class. I read an article that to read a serial port you need just the command read(). I managed to write but I don�t know to read the values storage in the PLC. Someone that understand ModBus knows that the message field for a typical message is:
    Station Adress, Function Code, Information, Erro Check
    I know that Station adress need to be between 1 and 247, because 0 means broadcasting (No response). Even I put the address 1, I can�t read. Part of the my program I�m putting below (just the parte to open the communication and the parte to read(). The parte to write is correct and there is no problem ).
    //Open the communication
    public void openConnection(String name, int baud,
    int timeout) {
    try {
    CommPortIdentifier portId =
    CommPortIdentifier.getPortIdentifier( name );
    serialPort = (SerialPort)portId.open
    ( "openConnection", timeout );
    serialPort.setSerialPortParams(baud, SerialPort.DATABITS_8,
    SerialPort.STOPBITS_2,
    SerialPort.PARITY_NONE);
    serialPort.setFlowControlMode( SerialPort.FLOWCONTROL_NONE);
              serialPort.enableReceiveThreshold( 1 );
         // Set receive timeout to allow breaking out of polling
         // loop during input handling.
         serialPort.enableReceiveTimeout( 200 );
         os = serialPort.getOutputStream();
    is = serialPort.getInputStream();
         open = true;
         System.out.println("Conexao aberta: " + portId.getName());
    } catch (Exception e) {
    System.err.println("Erro ao abrir conexao com a porta serial");
    System.exit ( 0 );
    Get a sequence of n chars from inputStream with 1 sec time-out
    between chars. It returns the number of chars read even if a
    time-out has occurred. */
    public int tgetchar(int n, int stream[])
    int c = 0;
    int i, T = 10;     
    int status = -1;     /* assume time-out */
    try {
    do {
    i = T;
    do {
    if (( stream[c] = is.read() ) != -1) {
    //THIS IS MY PROBLEM. IT ALWAYS
    // RETURN -1.
         status = 0;
         c++;
    else {
         status = -1;
         i--;
    } while (( i < T ) && ( i > 0 ) && ( status != 0 ));
    } while (( c < n ) && ( status == 0 ));
    } catch ( Exception e ) {
    System.err.println("Erro na leitura de dados");
    return c;      
    I call the method getchar() after I wrote the command to PLC. I can check the changes in the PLC but I can�t read the response message.
    Thank you very much.
    Carlos Martins

    I assume by this time you've either given up or found a solution. Just thought I'd put it here anyway. The following is a link to a Modbus API
    http://jamod.sourceforge.net/
    There is no tutorial but they do give the source code and javadocs

  • ATT 8900 help! please - can't even open texting

    Last night I tried to text my mother that I was home and it kept acting like it was sending but it wouldnt, so i took out battery to try and give it a fresh start, but when it reopened it said: "Uncaught exception: Java.Lamg.NullPointerException" with a button to press OK, so I did and now I cant even open the SMS/MMS subsection, I tried hitting the button and looking for it but it is almost as if it was deleted off my phone because I cant even find the icon to press it. please help, I can't live without texting! haha

    I  would try one more simple reboot:  With the BlackBerry device powered ON, remove the battery a few seconds and then reinsert the battery to reboot.
    If still nothing, do this: On your device, go to your Messages folder > press the Menu key > Options > scroll down to Email and SMS Inboxes > and make that choice = Combined.
    Now, look in your main Messages folder to see if you see your SMS messages.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

Maybe you are looking for

  • Installation of Config: All in one best practice

    Hi, I have download the Config: All in one doc from SAP service market place. After extracting what I see is the *.SAR files. can anybody guide how to use and install. DP

  • Outlook 2010 Advanced Find Contacts Not Working

    Some Outlook 2010 Advanced Find criteria work but the "email is not empty" and "email is empty" criteria return no results though there are contacts that have the Email field populated.

  • OPMN service still running but Essbase is not

    I have had a few cases of recursion causing Essbase to crash, but the OPMN service still says it's running in the services monitor. Any clues why? Reason I ask is that we have taken the trouble to monitor (and be notified of failures) all Hyperion se

  • Home screen woes

    I've recently got the 8820 with Orange in the UK. I love the phone and what it does... I do have an issue which I can't fathom. I was sent 2 SMS messages by someone, which I deleted. There is no trace of them in any of the folders but they still show

  • How to get only the last part of the URL in the doGet() method?

    In the doGet() method is there a way to check what URL it was called from ? For example the URL was: http://localhost:8080/myproject/jsp/randomPhrase.php (the php here is purely for misleading purposes - it's all Java really). in the doGet() method I