-
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.");
}
}
-
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.");
> }
>
> }
-
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
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|