Writing a class using random generator in bluej

Hello
Im trying to write a class for a deck of cards. Im using a random generator but I dont know how to write the instance variable.
I have to make 4 suits heart, club, spade, dimonds. and 13 for face value. I know how to random generate numbers. Like if I were making a slot machine to give me 3 numbers in a rage from 0-10. Thats just numbers. How do I random generate values of 1-13 and have it output a random suit? Also how do I make it say if its a jack king or queen? Do I need a constructor or how would I make the card with the face value of 13 suit heart and the card be a queen.
before jumping down my throat about this being a homework assignment...yes it is but this step Im seeking help on there is no example for this type of generating.
Thanks for any help
Rewind

Well, this is far from bullet-proof, but I think gets the basic idea across. This does sampling with replacement; if you wanted to do something like shuffle a deck of cards you'll need a smarter approach than this.
import java.util.*;
public class RandomCards {
  public static void main(String[] args) {
    Suit suit=new Suit();
    for (int i=0; i < 10; i++) {
      System.out.println(suit.nextSuit());
  private static class Suit {
    public static final String HEART="Heart";
    public static final String DIAMOND="Diamond";
    public static final String SPADE="Spade";
    public static final String CLUB="Club";
    private final String[] SUITS={ HEART, DIAMOND, SPADE, CLUB };
    private Gen suitGen=new Gen(0,3);
    public String nextSuit() {
      return SUITS[suitGen.nextInt()];
  private static class Gen {
    private int floor,ceiling;
    private Random rand;
    public Gen(int floor, int ceiling) {
      this.floor=floor;
      this.ceiling=ceiling;
      rand=new Random();
    public int nextInt() {
      return rand.nextInt(ceiling-floor)+floor;

Similar Messages

  • Odd behavior in class using Random

    Hi all, I am learning C# and built a simple Windows Form app using C# 2010 to experiment with generating random numbers. The app has two buttons and a list box. The code in the button click event is the following:
    private void button1_Click(object sender, EventArgs e)
    Random rx = new Random();
    listBox1.Items.Clear();
    for (int i = 0; i<3;i++)
    listBox1.Items.Add(rx.NextDouble());
    This behaves as expected generating 3 random numbers between 0 and 1.
    In the second button click event I have the following code which is similar tothe previous snippet, but uses a function to get the random number:
    private void button2_Click(object sender, EventArgs e)
    listBox1.Items.Clear();
    for (int i = 0; i < 3; i++)
    listBox1.Items.Add(GetRnd());
    private double GetRnd()
    Random rx = new Random();
    return rx.NextDouble();
    This also works, but I noticed that each time I clicked the button I would generally get the same 2 or 3 random number. After some research and experimentation I concluded that the random # generator was being called so quickly between each iteration that
    the same time seed was being used. To solve the problem I moved the Random rx declaration outside of the GetRnd function.
    This fixed this issue. I then wanted to see how this function would behave if I placed it in a class:
    class clsExample
    //Declarations...
    Random rx = new Random();
    private static double GetRnd()
    //Random rx = new Random();
    return rx.NextDouble();
    This does not work. The source editor places a red squiggly line under the instance name "rx" in the function's return statement. The message provided by the editor: An object reference is required for the non-static field , method or property
    'WindowsFormsApplication1.clsExample.rx'.
    This error goes away if I instantiate the Random class inside the function, as shown in the snippet above. But if I do this then the randoms numbers repeat. What am I missing? Why does this solution work in the form class and not in the class that I added?
    As always, thank you for your help! Saga
    Insanity is the prelude to discovery

    It seemed to me, from the code you posted previously, that you maybe wanted to use something static. So, rather than remove the static modifier from the method, as Stefan suggested, it might be preferable to add a static modifier to the rx field instead.
    // I changed the class name
    public class MyRandom
    //Declarations...
    private static Random rx = new Random();
    public static double GetRnd()
    return rx.NextDouble();
    Then, you'd use it like this:
    listBox1.Items.Add(MyRandom.GetRnd());
    ~~Bonnie DeWitt [C# MVP]
    http://geek-goddess-bonnie.blogspot.com

  • Random generator question

    I can't understand how to use Random generator when it requires minimum number and maxium number.
    import java.util.Random;
    public class Random
    public static void main(String[]args)
    Random generator = new Random();
    int num1;
    num1 = generator.nextInt(15) + 20;
    System.out.println("From 20 to 34: " +num1);
    num1 = generator.nextInt(20)-10;
    System.out.println("From -10 to 9: " +num1);
    }Can someone explain to me how the first Random generator is from 20 to 34 and the second Random genertor is rom -10 to 9?
    Edited by: CloneMe on May 31, 2009 1:06 PM

    CloneMe wrote:
    num1 = generator.nextInt(15) + 20;
    java.util.Random's nextInt() method generates a pseudo-random integer value that falls within 0 and the value supplied as the argument but not including that value.

  • How to use the random generator in java

    hey peeps, this is the class in which i am trying to implement the random generator in;
    public class Matchlist
        private studentdetails sd = new studentdetails();
        /** matchList StringBuilder stores the match list in progress */
        private StringBuilder matchList = new StringBuilder();
        private int loop = 0;
        private int matches = 0;
        public Matchlist()
            sd.createstudentdetails();
        /** Method to create the actual match list, returns the list as a string */
        public String CreateMatch()
            int g;
            int y;
                for (g = 0; g < 4; g++)//g = game
                    for (y = 17; y > -1; y--)//y = green house
                        /** Check to see if the game is empty */
                        if (sd.getgh(y).getGame(g).equalsIgnoreCase(""))
                            for (int x = 0; x < 18; x++) //x = yellow house
                                if (sd.getyh(x).getGame(g).equalsIgnoreCase(""))
                                    if (sd.getgh(y).getC_lass() != sd.getyh(x).getC_lass())
                                        /** Check to see if the person has played the other person */
                                        if (sd.getgh(y).checkPlayed(sd.getyh(x).getName()) == false)
                                            /** Set the game to the name of the opponent played */
                                            sd.getyh(x).changeGame(g, sd.getgh(y).getName());
                                            sd.getgh(y).changeGame(g, sd.getyh(x).getName());
                                            /** Build the match list step by step using append with \n at the end to create a new line */
                                            matchList.append(sd.getyh(x).getName() + " vs " + sd.getgh(y).getName() + "\n");
                                            matches++;
                                            break;
                /** Convert the stringbuilder into an actual string, then return it */
                String completeMatchList = matchList.toString();
                System.out.println(matches);
                for (int i = 0; i <18; i++)
                    sd.getyh(i).getEmptyMatches();
                    sd.getgh(i).getEmptyMatches();
                return completeMatchList;
        }what i dont understand is how to implement it to pick my matches at random using the http://java.sun.com/j2se/1.4.2/docs/api/java/util/Random.html java tutorials from here
    regards

    How to use Random ?
    First you open API then you read it, then you use it.
    You mention you try to use it but i just see a horrible nested for for for if if if loop.
    Restructure code and question and maybe it makes more sense.
    Edited by: pgeuens on 10-mrt-2008 22:58

  • Generating unique no.'s using random function

    Hi,
    I'm trying to generate unique values for row and column say from 0-3
    and I read some where that if we use random.nextInt() we will get unique values but I'm getting repeated values.I'll appreciate if anyone can help me in this matter.Here's the code:
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    public class random{
    public static void main(String args[])
    int b[]=new int[4];
    int c[]=new int[4];
    int i;
    Date date;
    Random random;
    date=new Date();
    random = new Random(date.getTime());
    for(i=0;i<4;i++)
    digit = random.nextInt(4);
    b=digit;
    for(i=0;i<4;i++)
    digit = random.nextInt(4);
    c[i] = digit;
    for(i=0;i<4;i++)
    System.out.println("column array is" + c[i]);
    for(i=0;i<4;i++)
    System.out.println("row array is" + b[i]);
    }//end main
    }//end class
    Thanks
    Suneetha.

    here is my code for generating a random number but not a unique number. with a big enough number the possibility getting a unique is high so you may modify it to suit you need:
      private void initial_node()
        float Qxyd = -1, Qyzd = -1, Cxyd = -1, Cyzd = -1;
        long seed;
        Q_table = new float[row][col];
        seed = (long)( Math.random() * System.currentTimeMillis() * 100000000 );
        Random rand1 = new Random( seed );
        seed = (long)( Math.random() * System.currentTimeMillis() * 100000000 );
        Random rand2 = new Random( seed );
        seed = (long)( Math.random() * System.currentTimeMillis() * 100000000 );
        Random rand3 = new Random( seed );
        seed = (long)( Math.random() * System.currentTimeMillis() * 100000000 );
        Random rand4 = new Random( seed );
        for( int i = 0; i < row; i++ )
          do
            Qxyd = (float)( rand1.nextFloat() + (float)rand1.nextFloat() / 3 );
          while( Qxyd < 0.35 || Qxyd == -1 );
          Q_table[5] = Math.abs( Qxyd );
    do
    Qyzd = (float)( rand2.nextFloat() + (float)rand2.nextFloat() / 7 );
    while( Qyzd < 0.45 || Qyzd == -1 );
    Q_table[i][3] = Math.abs( Qyzd );
    do
    Cxyd = (float)( rand3.nextFloat() + (float)rand3.nextFloat() / 9 );
    while( Cxyd > 0.15 || Cxyd == -1 );
    Q_table[i][8] = Math.abs( Cxyd );
    do
    Cyzd = (float)( rand4.nextFloat() + (float)rand4.nextFloat() / 11 );
    while( Cyzd > 0.10 || Cyzd == -1 );
    Q_table[i][9] = Math.abs( Cyzd );

  • Writing a class to open jDialog that can be used over and over

    Hi All
    I am hoping that some out there can help me with this.
    I have a lot of Dialogs that I what to open and close.
    I am using the code to do that , and it works fine.
    What i would like to do is write a class that I can call and just pass in the name of the dialog that I what to open.
    Something like this
    private String dialogeName;
    dialogeName = Contacts;
    So from another class using a button I could do this type of call
    some way of passing into this class the Dialog name. I don't know how to do that ether .
    Is there some way of getting to this private String dialogeName; from another class ??
    Is this posable ??
    PLEASE SOMEONE HELP ME .....................
        Contacts dlg = new Contacts();   // Works fine  but to have to call the same code over and over
       // is a pain and the only difference is the name of the dialog.
        dialogeName = Contacts;  // this is what I would like to be able to do
       // dialogeName dlg = new dialogeName();
        Dimension dlgSize = dlg.getPreferredSize();
        Dimension frmSize = getSize();
        Point loc = getLocation();
        dlg.setLocation( (frmSize.width - dlgSize.width) / 2 + loc.x,
                        (frmSize.height - dlgSize.height) / 2 + loc.y);
        dlg.setModal(true);
        dlg.pack();
        dlg.show();Thanks to all that have taken the time to look and to help
    Craig

    Why not simply create a method that wraps all the redundant stuff?
    public JDialog showDialog(JDialog dlg)
        Dimension dlgSize = dlg.getPreferredSize();
        Dimension frmSize = dlg.getSize();
        Point loc = dlg.getLocation();
        dlg.setLocation( (frmSize.width - dlgSize.width) / 2 + loc.x,
                        (frmSize.height - dlgSize.height) / 2 + loc.y);
        dlg.setModal(true);
        dlg.pack();
        dlg.show();
        return dlg;
    }Then you could call it with all your various dialog types:
    Contacts dlg = (Contacts)showDialog(new Contacts());
    OtherDialog dlg2 = (OtherDialog)showDialog(new OtherDialog());Of course in this example Contacts and OtherDialog classes must extend JDialog.

  • I need help with this program ( Calculating Pi using random numbers)

    hi
    please understand that I am not trying to ask anymore to do this hw for me. I am new to java and working on the assignment. below is the specification of this program:
    Calculate PI using Random Numbers
    In geometry the ratio of the circumference of a circle to its diameter is known as �. The value of � can be estimated from an infinite series of the form:
    � / 4 = 1 - (1/3) + (1/5) - (1/7) + (1/9) - (1/11) + ...
    There is another novel approach to calculate �. Imagine that you have a dart board that is 2 units square. It inscribes a circle of unit radius. The center of the circle coincides with the center of the square. Now imagine that you throw darts at that dart board randomly. Then the ratio of the number of darts that fall within the circle to the total number of darts thrown is the same as the ratio of the area of the circle to the area of the square dart board. The area of a circle with unit radius is just � square unit. The area of the dart board is 4 square units. The ratio of the area of the circle to the area of the square is � / 4.
    To simuluate the throwing of darts we will use a random number generator. The Math class has a random() method that can be used. This method returns random numbers between 0.0 (inclusive) to 1.0 (exclusive). There is an even better random number generator that is provided the Random class. We will first create a Random object called randomGen. This random number generator needs a seed to get started. We will read the time from the System clock and use that as our seed.
    Random randomGen = new Random ( System.currentTimeMillis() );
    Imagine that the square dart board has a coordinate system attached to it. The upper right corner has coordinates ( 1.0, 1.0) and the lower left corner has coordinates ( -1.0, -1.0 ). It has sides that are 2 units long and its center (as well as the center of the inscribed circle) is at the origin.
    A random point inside the dart board can be specified by its x and y coordinates. These values are generated using the random number generator. There is a method nextDouble() that will return a double between 0.0 (inclusive) and 1.0 (exclusive). But we need random numbers between -1.0 and +1.0. The way we achieve that is:
    double xPos = (randomGen.nextDouble()) * 2 - 1.0;
    double yPos = (randomGen.nextDouble()) * 2 - 1.0;
    To determine if a point is inside the circle its distance from the center of the circle must be less than the radius of the circle. The distance of a point with coordinates ( xPos, yPos ) from the center is Math.sqrt ( xPos * xPos + yPos * yPos ). The radius of the circle is 1 unit.
    The class that you will be writing will be called CalculatePI. It will have the following structure:
    import java.util.*;
    public class CalculatePI
    public static boolean isInside ( double xPos, double yPos )
    public static double computePI ( int numThrows )
    public static void main ( String[] args )
    In your method main() you want to experiment and see if the accuracy of PI increases with the number of throws on the dartboard. You will compare your result with the value given by Math.PI. The quantity Difference in the output is your calculated value of PI minus Math.PI. Use the following number of throws to run your experiment - 100, 1000, 10,000, and 100,000. You will call the method computePI() with these numbers as input parameters. Your output will be of the following form:
    Computation of PI using Random Numbers
    Number of throws = 100, Computed PI = ..., Difference = ...
    Number of throws = 1000, Computed PI = ..., Difference = ...
    Number of throws = 10000, Computed PI = ..., Difference = ...
    Number of throws = 100000, Computed PI = ..., Difference = ...
    * Difference = Computed PI - Math.PI
    In the method computePI() you will simulate the throw of a dart by generating random numbers for the x and y coordinates. You will call the method isInside() to determine if the point is inside the circle or not. This you will do as many times as specified by the number of throws. You will keep a count of the number of times a dart landed inside the circle. That figure divided by the total number of throws is the ratio � / 4. The method computePI() will return the computed value of PI.
    and below is what i have so far:
    import java.util.*;
    public class CalculatePI
      public static boolean isInside ( double xPos, double yPos )
         double distance = Math.sqrt( xPos * xPos + yPos * yPos );        
      public static double computePI ( int numThrows )
        Random randomGen = new Random ( System.currentTimeMillis() );
        double xPos = (randomGen.nextDouble()) * 2 - 1.0;
        double yPos = (randomGen.nextDouble()) * 2 - 1.0;
        int hits = 0;
        int darts = 0;
        int i = 0;
        int areaSquare = 4 ;
        while (i <= numThrows)
            if (distance< 1)
                hits = hits + 1;
            if (distance <= areaSquare)
                darts = darts + 1;
            double PI = 4 * ( hits / darts );       
            i = i+1;
      public static void main ( String[] args )
        Scanner sc = new Scanner (System.in);
        System.out.print ("Enter number of throws:");
        int numThrows = sc.nextInt();
        double Difference = PI - Math.PI;
        System.out.println ("Number of throws = " + numThrows + ", Computed PI = " + PI + ", Difference = " + difference );       
    }when I tried to compile it says "cannot find variable 'distance' " in the while loop. but i thought i already declare that variable in the above method. Please give me some ideas to solve this problem and please check my program to see if there is any other mistakes.
    Thanks a lot.

    You've declared a local variable, distance, in the method isInside(). The scope of this variable is limited to the method in which it is declared. There is no declaration for distance in computePI() and that is why the compiler gives you an error.
    I won't check your entire program but I did notice that isInside() is declared to be a boolean method but doesn't return anything, let alone a boolean value. In fact, it doesn't even compute a boolean value.

  • How to create a new user in IDM 8.1 with random generated password?

    Hi, i want create a new user using a modified tabbed user fom that cannot ask for password and confirm password to the administrator but randomly generate a new password (only when the form is opened in user creation) according to password policy and display it on the form.
    I think it is possible because Reset User Password Form does it, but i don't know how put this kind og logic in an other form.
    thanks
    Marco

    If you want to generate a users password randomly then you could take a look at the com.waveset.provision.PasswordGenerator class inside the Identity Mgr REF kit. Here's an example:
    <Rule name='generateRandomPassword'>
           <Comments>generate a random password</Comments>
           <RuleArgument name='accountId' value='Configurator'>
             <Comments>accountId of the user</Comments>
             <String>Configurator</String>
           </RuleArgument>
           <RunAsUser>
             <ObjectRef type='User' id='#ID#Configurator' name='Configurator'/>
           </RunAsUser>
           <block trace='true'>
             <defvar name='session'>
               <or>
                 <ref>context</ref>
                 <ref>display.session</ref>
               </or>
             </defvar>
             <defvar name='wsuser'>
               <invoke name='getObject' class='com.waveset.ui.FormUtil'>
                 <ref>session</ref>
                 <s>User</s>
                 <ref>accountId</ref>
               </invoke>
             </defvar>
              <defvar name='pwgenerator'>
               <new class='com.waveset.provision.PasswordGenerator'>
                 <ref>session</ref>
               </new>
             </defvar>
             <invoke name='generatePassword'>
               <ref>pwgenerator</ref>
               <ref>wsuser</ref>
             </invoke>
           </block>
        </Rule> You'll want to take the password.password field and inside the Default event handler check to see if waveset.id is null, if it is then call the Rule above.
    HTH,
    Paul

  • Implementing the random generator

    Hello, i have posrted this question in the forum yesterday, and didnt get a reply, so i am reposting, hope i havent violated any of the forum rules? If i have can a mod tell me, delete it and ill try and find my old post
    The problem i am having is trying to implement thwe random generator in to my code, it hasnt been done correctly as its not printing out a list of matches based on the conditons, can someone tell me what is wrong? thanks
    import java.util.Random;
    public class Matchlist
        private studentdetails sd = new studentdetails();
        /** matchList StringBuilder stores the match list in progress */
        private StringBuilder matchList = new StringBuilder();
        private Random studentPicker = new Random();
        private int loop = 0;
        private int matches = 0;
        public Matchlist()
            sd.createstudentdetails();
        /** Method to create the actual match list, returns the list as a string */
        public String CreateMatch()
            int game;
            int yellowStudent = 0;
            int currentGame = 0;
            int matchAttempt = 0;
            while (matches < 70)
                makeMatches:
                for (game = 0; game < 4; game++)//g = game
                    for (int greenStudent = 0; greenStudent < 17; greenStudent++)
                        while (sd.getgh(greenStudent).getGame(game).equalsIgnoreCase(""))
                            matchAttempt++;
                            if (matchAttempt > 800)
                                sd = new studentdetails();
                                game = 0;
                                matches = 0;
                                break makeMatches;
                            yellowStudent = studentPicker.nextInt(17);
                            if (sd.getyh(yellowStudent).getGame(game).equalsIgnoreCase(""))
                                if (sd.getgh(greenStudent).getC_lass() != sd.getyh(yellowStudent).getC_lass())
                                    /** Check to see if the person has played the other person */
                                    if (sd.getgh(greenStudent).checkPlayed(sd.getyh(yellowStudent).getName()) == false)
                                        /** Set the game to the name of the opponent played */
                                        sd.getyh(yellowStudent).changeGame(game, sd.getgh(greenStudent).getName());
                                        sd.getgh(greenStudent).changeGame(game, sd.getyh(yellowStudent).getName());
                                        /** Build the match list step by step using append with \n at the end to create a new line */
                                        matchList.append(sd.getyh(yellowStudent).getName() + " vs " + sd.getgh(greenStudent).getName() + "\n");
                                        matches++;
                                        currentGame++;
                                        if (currentGame == 18)
                                            currentGame = 0;
                                            break;
            /** Convert the stringbuilder into an actual string, then return it */
            String completeMatchList = matchList.toString();
            System.out.println(matches);
            for (int i = 0; i < 18; i++)
                sd.getyh(i).getEmptyMatches();
                sd.getgh(i).getEmptyMatches();
            return completeMatchList;
        }

    Where is it occuring? What are the values of the variabels at that point? We can't even run your code to find out because it could be in the studentdetails class which you haven't posted. I suggest you use an IDE to set breakpoints and step through it in a debugger which will allow you to examine the state of the program a any given point and identify where the NPE is coming from.
    For Netbeans
    http://www.netbeans.org/kb/55/using-netbeans/debug.html
    For Eclipse
    http://pages.cs.wisc.edu/~cs302/resources/EclipseDebugTutorial/

  • Random generator

    Peeps, to the following match list how do i implent the random generator so that each match is picked at random but still checks the following conditions? help is desperatley needed, i tried using the guide
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/Random.html
    but to no avail - im REALLY stuck, thanks
    public class Matchlist
        private studentdetails sd = new studentdetails();
        /** matchList StringBuilder stores the match list in progress */
        private StringBuilder matchList = new StringBuilder();
        private int loop = 0;
        private int matches = 0;
        public Matchlist()
            sd.createstudentdetails();
        /** Method to create the actual match list, returns the list as a string */
        public String CreateMatch()
            int g;
            int y;
                for (g = 0; g < 4; g++)//g = game
                    for (y = 17; y > -1; y--)//y = green house
                        /** Check to see if the game is empty */
                        if (sd.getgh(y).getGame(g).equalsIgnoreCase(""))
                            for (int x = 0; x < 18; x++) //x = yellow house
                                if (sd.getyh(x).getGame(g).equalsIgnoreCase(""))
                                    if (sd.getgh(y).getC_lass() != sd.getyh(x).getC_lass())
                                        /** Check to see if the person has played the other person */
                                        if (sd.getgh(y).checkPlayed(sd.getyh(x).getName()) == false)
                                            /** Set the game to the name of the opponent played */
                                            sd.getyh(x).changeGame(g, sd.getgh(y).getName());
                                            sd.getgh(y).changeGame(g, sd.getyh(x).getName());
                                            /** Build the match list step by step using append with \n at the end to create a new line */
                                            matchList.append(sd.getyh(x).getName() + " vs " + sd.getgh(y).getName() + "\n");
                                            matches++;
                                            break;
                /** Convert the stringbuilder into an actual string, then return it */
                String completeMatchList = matchList.toString();
                System.out.println(matches);
                for (int i = 0; i <18; i++)
                    sd.getyh(i).getEmptyMatches();
                    sd.getgh(i).getEmptyMatches();
                return completeMatchList;
        }

    jermaindefoe wrote:
    lol, ok then, the code above is a match list generator that works on a set of conditions, the conditions dont need to be mentioned at the moment as that part of the code works, what does need to be mentioned though is the fact that in another class there is a student list, 2 lots of groups with 18 students each. what i want is to implement the random generator on my code so that players are picked at random and then the conditons are checked, if a match isnt found then another is picked randomly
    i just dont no how, i really would like some help if poss?Are you allowed to use java.util.Random?

  • "encoding = UTF-8" missing while writing XML file using file Adapter

    Hi,
    We are facing an unique problem writing xml file using file adapter. The file is coming without the encoding part in the header of xml. An excerpt of the file that is getting generated:
    <?xml version="1.0" ?>
    <customerSet>
    <user>
    <externalID>51017</externalID>
    <userInfo>
    <employeeID>51017</employeeID>
    <employeeType>Contractor</employeeType>
    <userName/>
    <firstName>Gail</firstName>
    <lastName>Mikasa</lastName>
    <email>[email protected]</email>
    <costCenter>8506</costCenter>
    <departmentCode/>
    <departmentName>1200 Corp IT Exec 8506</departmentName>
    <businessUnit>1200</businessUnit>
    <jobTitle>HR Analyst 4</jobTitle>
    <managerID>49541</managerID>
    <division>290</division>
    <companyName>HQ-Milpitas, US</companyName>
    <workphone>
    <number/>
    </workphone>
    <mobilePhone>
    <number/>
    </customerSet>
    </user>
    So if you see the header the "encoding=UTF-8" is missing after "version-1.0".
    Do we need to configure any properties in File Adapter?? Or is it the standard way of rendering by the adapter.
    Please advice.
    Thanks in advance!!!

    System.out.println(nodeList.item(0).getFirstChild().getNodeValue());

  • Reading/Writing .xlsx files using Webdynpro for Java

    Dear All
    I have a requirement to read/write excel files in .xlsx format. I am good in doing it with .xls format using jxl.jar. The jxl.jar doesn't support .xlsx format. Kindly help me in understanding how do I need to proceed on reading/writing .xlsx files using Webdynpro for Java.
    Thanks and Regards
    Ramamoorthy D

    i am using jdk 1.6.22 and IBM WebSphere
    when i use poi-3.6-20091214.jar and poi-ooxml-3.6-20091214.jar  to read .xlsx file. but i am getting following errors
    The project was not built since its classpath is incomplete. Cannot find the class
    file for java.lang.Iterable. Fix the classpath then try rebuilding this project.
    This compilation unit indirectly references the missing type java.lang.Iterable
    (typically some required class file is referencing a type outside the classpath)
    how can i resolve it
    here is the code that i have used
    public class HomeAction extends DispatchAction {
         public ActionForward addpage(
                             ActionMapping mapping,
                             ActionForm form,
                             HttpServletRequest request,
                             HttpServletResponse response)
                             throws Exception {     
                             String name = "C:/Documents and Settings/bharath/Desktop/Book1.xlsx";
               FileInputStream fis = null;
               try {
                   Object workbook = null;
                    fis = new FileInputStream(name);
                    XSSFWorkbook wb = new XSSFWorkbook(fis);
                    XSSFSheet sheet = (XSSFSheet) wb.getSheetAt(0);
                    Iterator rows = sheet.rowIterator();
                    int number=sheet.getLastRowNum();
                    System.out.println(" number of rows"+ number);
                    while (rows.hasNext())
                        XSSFRow row = ((XSSFRow) rows.next());
                        Iterator cells = row.cellIterator();
                        while(cells.hasNext())
                    XSSFCell cell = (XSSFCell) cells.next();
                    String Value=cell.getStringCellValue();
                    System.out.println(Value);
               } catch (IOException e) {
                    e.printStackTrace();
               } finally {
                    if (fis != null) {
                         fis.close();
                return mapping.findForward("returnjsp");

  • How to display value from java class with output generated with toplink

    i hava a requirement of displaying (distance ie calculated in java class) with output generated by query.
    ie if output is like
    school name (distance)
    physical address
    here the school name and physical address are retrived from database.

    Hi,
    ValueHolders are used by the JSF internal framework. To work with an object (attributes) in a managed bean you don't need to make it returning a value holder.
    Create a POJO, provide accessor methods and register it as a managed bean. Access it from JSF with EL
    Frank

  • A way to reuse existing classes instead of generating the stub ones?

    Hello to all,
    I am using eclipse and weblogic 10.3 as an application server.
    I have a 1st project deployed with some exposed web services. I need to access these services from a 2nd project, so i run the clientgen ant task, which generates the client interface, along with some stub classes. These stub classes are basically a copy of the ones from the 1st project.
    My question is this:
    Is there a way to reuse the original objects that the 1st project is using, by putting the first project as a dependency on the second? Or do i have to use the generated stub classes?
    Thanks in advance! Any help is appreciated.

    hi raja,
    no, DB6CONV cannot reuse the existing compression dictionary - this is in general not possible.
    BUT:  the good news is, that the next version V5 of DB6CONV will (amongst other new features) handle compression in a much better way! like R3load and online_table_move the compression dictionary will then be created based on  (if possible) 20MB of sampled data ensuring optimal compression.
    this new version will become generally available within the next few weeks.
    regards, frank

  • Accessing a different class using ActionPerformed

    hi
    im trying to access a method in a different class using
    public void actionPerformed (ActionEvent e) {
              if(e.getSource() == AuthorCombo) {
                   ComboAction();
              else if(e.getSource() == SearchButton){
                        SearchSystem();
    }and then using
    public class Book extends ViewPanel{
    public void SearchSystem(){// this is used to get the information from
                      //the combo boxs whixh can latter show
                      //the data in the text area
    tempBookNoList.clear();
              for(int a=0; a<AuthorList.size(); a++) {
                                  if(((String)AuthorCombo.getSelectedItem()
                                  ==AuthorList.get(a))
                                  &&((String)BookCombo.getSelectedItem()
                                  ==BookList.get(a))) {
                                       tempBookNoList.add((String)BookNoList.get(a));
                        String result = (String)tempBookNoList.get(a);
                        InfoArea.setText ((String)tempBookNoList.get(a));
    }          }//End neither random situation.to manipulate some data within the other class
    i keep getting the error
    .\ViewPanel.java:314: cannot resolve symbol
    symbol : method SearchSystem ()
    location: class ViewPanel
                        SearchSystem();
    ^
    1 error
    can anyone help me spot the problem

    in that case i do not know what could be the cause in this program
    the only area i think it could be is when the SearchSystem method in the Book class gets using the Action Performed method in the Viewpanel method, shown below
    public class Book extends ViewPanel{
    public void SearchSystem(){// this is used to get the information from
                      //the combo boxs whixh can latter show
                      //the data in the text area
              for(int a=0; a<AuthorList.size(); a++) {
                                  if(((String)AuthorCombo.getSelectedItem()
                                  ==AuthorList.get(a))
                                  &&((String)BookCombo.getSelectedItem()
                                  ==BookList.get(a))) {
                                  InfoArea.setText((String)BookNoList.get(a));
                   }which is called using
    public void actionPerformed (ActionEvent e) {
              if(e.getSource() == AuthorCombo) {
                   ComboAction();
              else if(e.getSource() == SearchButton){
                        theBook.SearchSystem();
    }but i cant see this being a problem as it all compiles

Maybe you are looking for

  • Upgrade Trial To Paid

    I have a paid version of Lightroom 2.0 coming in the mail in a few days. If I download and install the 2.6 version now will there be a problem converting it to a paid version when I get the DVD? I've read of some having headaches doing that with some

  • Help- can't connect airport to Netgear router?

    I posted yesterday then thought I had solved the problem but I hadn't so here goes again: I've never used Airport before, so i'm green I have a G4 sawtooth tower connected to a Netgear wireless router MR814v2. I don't think I have an airport card in

  • JLayeredPane - keeping all contained components filling the layeredPane

    I'm having some troubles keeping contained components inside a JLayeredPane so they're all filling the pane. The desired effect I want is to have a region of the window that contains two panels -- one for standard view/editing, and an overlayed trans

  • Bad Airport Extreme 802.11n reception since move.

    Yesterday I moved my base station from 1.5 metres away from my iMac (20" Intel core 2 duo) to 5 metres distance. It is still in the same room and in line of sight with no obstructions. The signal strngth has dropped from 65 percent (at 1.5 metres dis

  • Proxy error after installing 8u25 or 7u71

    Updated from java 7r67 to 8r25 and noticed that java is ignoring all my proxy settings. 7r67 works just fine, 8r25 does not. I can uninstall 8r25 and reinstall 7r67 and things start to work again. This is the error in the java console (just connectin