random numbers


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: random numbers

Hybrid View

  1. #1
    max Guest

    random numbers


    Here is my code. This should print out a random number, but it instead gives
    me a loverly exception:
    "exception in thread "main" java.lang.NoClassDefFoundError: Merge/Java"
    Please help!!



    import java.io.*;
    import java.util.Random;

    class Merge {

    public static void main(String[] arg) {
    Random r = new Random();
    for (int i=0; i<10; i++) {
    System.out.println(50+r.nextInt()%50);
    }
    System.out.println("Done.");
    }

    }

  2. #2
    Paul Clapham Guest

    Re: random numbers

    Try this:

    java Merge

    instead of this:

    java Merge.java

    PC2

    "max" <mntf398@aol.com> wrote in message news:3aecabd6$1@news.devx.com...
    >
    > Here is my code. This should print out a random number, but it instead

    gives
    > me a loverly exception:
    > "exception in thread "main" java.lang.NoClassDefFoundError: Merge/Java"
    > Please help!!
    >
    >
    >
    > import java.io.*;
    > import java.util.Random;
    >
    > class Merge {
    >
    > public static void main(String[] arg) {
    > Random r = new Random();
    > for (int i=0; i<10; i++) {
    > System.out.println(50+r.nextInt()%50);
    > }
    > System.out.println("Done.");
    > }
    >
    > }




  3. #3
    Mike Petitjean Guest

    Re: random numbers


    You may also need to set the classpath on the command line. For example
    if your Merge.class file is in C:\Temp\ the on the command line type: java
    -classpath C:\Temp\ Merge



    "max" <mntf398@aol.com> wrote:
    >
    >Here is my code. This should print out a random number, but it instead

    gives
    >me a loverly exception:
    >"exception in thread "main" java.lang.NoClassDefFoundError: Merge/Java"
    >Please help!!
    >
    >
    >
    >import java.io.*;
    >import java.util.Random;
    >
    >class Merge {
    >
    > public static void main(String[] arg) {
    > Random r = new Random();
    > for (int i=0; i<10; i++) {
    > System.out.println(50+r.nextInt()%50);
    > }
    > System.out.println("Done.");
    > }
    >
    >}



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center